From 21c51f80ecf1d831377e2d86321bbb48c624b210 Mon Sep 17 00:00:00 2001 From: Andrew Scribner Date: Fri, 3 May 2024 15:05:26 -0400 Subject: [PATCH 1/3] update integration CI to preserve charmcraft's cache between builds --- .github/workflows/integrate.yaml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 1c312cc4..c22cb285 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -38,6 +38,8 @@ jobs: strategy: matrix: charm: [controller, ui] + env: + CRAFT_SHARED_CACHE: /home/runner/.cache/shared_charmcraft_cache steps: - name: Check out code uses: actions/checkout@v3 @@ -50,8 +52,34 @@ jobs: microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49" juju-channel: 3.1/stable + - name: Setup Charmcraft's cache + id: cache + uses: actions/cache@v4 + with: + path: ${{ env.CRAFT_SHARED_CACHE }} + # Cache keys must be unique - there is no overwrite mechanic. Add IDs to avoid this (is there a better set of IDs?) + # partial ref: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache + # To match the most recent previous cache, use restore-keys with the craft-shared-cache prefix. This will hit the + # "first" match, which will be from the most recent run. + # ref: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + key: craft-shared-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }} + restore-keys: craft-shared-cache + + # DEBUG: remove this + - name: emit charmcraft cache directory contents + run: | + find $CRAFT_SHARED_CACHE | wc -l + find $CRAFT_SHARED_CACHE/wheels | wc -l + - run: tox -e ${{ matrix.charm }}-integration + # DEBUG: remove this + - name: emit charmcraft cache directory contents + run: | + find $CRAFT_SHARED_CACHE | wc -l + find $CRAFT_SHARED_CACHE/wheels | wc -l + + lint: name: Lint Code runs-on: ubuntu-20.04 @@ -67,6 +95,8 @@ jobs: bundle-integration: name: Bundle Integration runs-on: ubuntu-20.04 + env: + CRAFT_SHARED_CACHE: /home/runner/.cache/shared_charmcraft_cache steps: - name: Check out code uses: actions/checkout@v3 @@ -79,6 +109,26 @@ jobs: microk8s-addons: "dns storage rbac ingress metallb:10.64.140.43-10.64.140.49" juju-channel: 3.1/stable + + - name: Setup Charmcraft's cache + id: cache + uses: actions/cache@v4 + with: + path: ${{ env.CRAFT_SHARED_CACHE }} + # Cache keys must be unique - there is no overwrite mechanic. Add IDs to avoid this (is there a better set of IDs?) + # partial ref: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache + # To match the most recent previous cache, use restore-keys with the craft-shared-cache prefix. This will hit the + # "first" match, which will be from the most recent run. + # ref: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + key: craft-shared-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }} + restore-keys: craft-shared-cache + + # DEBUG: remove this + - name: emit charmcraft cache directory contents + run: | + find $CRAFT_SHARED_CACHE | wc -l + find $CRAFT_SHARED_CACHE/wheels | wc -l + - name: Run test run: | sudo apt install tar wget @@ -89,6 +139,12 @@ jobs: juju add-model kubeflow sg snap_microk8s -c "tox -e integration -- --model kubeflow" + # DEBUG: remove this + - name: emit charmcraft cache directory contents + run: | + find $CRAFT_SHARED_CACHE | wc -l + find $CRAFT_SHARED_CACHE/wheels | wc -l + - run: kubectl get all -A if: failure() From 578bd4389738a2c3967ae51eca8a51ee2ff3c7e1 Mon Sep 17 00:00:00 2001 From: Andrew Scribner Date: Fri, 3 May 2024 15:40:15 -0400 Subject: [PATCH 2/3] update integration charmcraft caching to point to default charmcraft cache dir --- .github/workflows/integrate.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index c22cb285..a4cb2332 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -39,7 +39,7 @@ jobs: matrix: charm: [controller, ui] env: - CRAFT_SHARED_CACHE: /home/runner/.cache/shared_charmcraft_cache + CRAFT_SHARED_CACHE: /home/runner/snap/charmcraft/common/cache/charmcraft/ steps: - name: Check out code uses: actions/checkout@v3 @@ -96,7 +96,7 @@ jobs: name: Bundle Integration runs-on: ubuntu-20.04 env: - CRAFT_SHARED_CACHE: /home/runner/.cache/shared_charmcraft_cache + CRAFT_SHARED_CACHE: /home/runner/snap/charmcraft/common/cache/charmcraft/ steps: - name: Check out code uses: actions/checkout@v3 From 52e71f74082b045d6615ef8a039244a357b2f07d Mon Sep 17 00:00:00 2001 From: Andrew Scribner Date: Fri, 3 May 2024 16:15:10 -0400 Subject: [PATCH 3/3] proc ci again --- .github/workflows/integrate.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index a4cb2332..11c30890 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -65,7 +65,7 @@ jobs: key: craft-shared-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }} restore-keys: craft-shared-cache - # DEBUG: remove this + # DEBUG: remove this after testing - name: emit charmcraft cache directory contents run: | find $CRAFT_SHARED_CACHE | wc -l @@ -73,7 +73,7 @@ jobs: - run: tox -e ${{ matrix.charm }}-integration - # DEBUG: remove this + # DEBUG: remove this after testing - name: emit charmcraft cache directory contents run: | find $CRAFT_SHARED_CACHE | wc -l @@ -123,7 +123,7 @@ jobs: key: craft-shared-cache-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }} restore-keys: craft-shared-cache - # DEBUG: remove this + # DEBUG: remove this after testing - name: emit charmcraft cache directory contents run: | find $CRAFT_SHARED_CACHE | wc -l @@ -139,7 +139,7 @@ jobs: juju add-model kubeflow sg snap_microk8s -c "tox -e integration -- --model kubeflow" - # DEBUG: remove this + # DEBUG: remove this after testing - name: emit charmcraft cache directory contents run: | find $CRAFT_SHARED_CACHE | wc -l