Skip to content

Commit

Permalink
Allow submodule cache to persist across runs
Browse files Browse the repository at this point in the history
Although it only takes a few minutes to do the shallow clones, and we
don't trigger runs that frequently, let's keep the submodule cache
around, and invalidate it based on the hash of the 'git submodules'
command, instead on each run. This will save us space on the repo's
cache storage (10GB) and speed up the process a bit.

Signed-off-by: Nick Kossifidis <[email protected]>
  • Loading branch information
mickflemm committed Nov 10, 2024
1 parent 00efc94 commit 4e699b4
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,39 @@ jobs:
submodule_cache:
name: Initialize submodule cache
runs-on: ubuntu-latest
outputs:
key: ${{ steps.keygen.outputs.smcache_key }}
steps:
- uses: actions/checkout@v4

- name: Remove unneeded frameworks to recover disk space
run: sudo ./.github/cleanup-rootfs.sh

- name: Generate submodule cache key
id: keygen
run: echo "smcache_key=smcache-$(printf $(git submodule | sha1sum))" >> $GITHUB_OUTPUT

- name: Setup submodule cache
id: smcache
uses: actions/cache@v4
with:
path: ${{ env.submodule_paths }}
key: ${{ steps.keygen.outputs.smcache_key }}

- name: Checkout required submodules
if: steps.smcache.outputs.cache-hit != 'true'
run: git submodule update --init -j $(nproc) --depth 1 $(echo ${submodule_paths} | sed '$d' | tr '\n' ' ')

- name: Storage size optimization
if: steps.smcache.outputs.cache-hit != 'true'
run: |
git submodule foreach 'git maintenance run'
- name: Setup submodule cache
uses: actions/cache@v4
with:
path: ${{ env.submodule_paths }}
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}

build:
runs-on: ${{ matrix.os }}
needs: [submodule_cache]
env:
smcache_key: ${{ needs.submodule_cache.outputs.key }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
Expand All @@ -75,7 +86,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ${{ env.submodule_paths }}
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
key: ${{ env.smcache_key }}

- name: build toolchain
run: |
Expand Down Expand Up @@ -134,6 +145,8 @@ jobs:
test-sim:
runs-on: ${{ matrix.os }}
needs: [submodule_cache]
env:
smcache_key: ${{ needs.submodule_cache.outputs.key }}
strategy:
matrix:
os: [ubuntu-24.04]
Expand All @@ -153,7 +166,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ${{ env.submodule_paths }}
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
key: ${{ env.smcache_key }}

- name: build toolchain
run: |
Expand All @@ -170,6 +183,8 @@ jobs:
if: ${{ false }} # Disable until multilib errors are triaged
runs-on: ${{ matrix.os }}
needs: [submodule_cache]
env:
smcache_key: ${{ needs.submodule_cache.outputs.key }}
strategy:
matrix:
os: [ubuntu-24.04]
Expand All @@ -188,7 +203,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ${{ env.submodule_paths }}
key: submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
key: ${{ env.smcache_key }}

- name: build toolchain
run: |
Expand Down

0 comments on commit 4e699b4

Please sign in to comment.