diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 1c312cc4..11c30890 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/snap/charmcraft/common/cache/charmcraft/ 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 after testing + - 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 after testing + - 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/snap/charmcraft/common/cache/charmcraft/ 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 after testing + - 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 after testing + - 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()