@@ -27,30 +27,41 @@ jobs:
2727 submodule_cache :
2828 name : Initialize submodule cache
2929 runs-on : ubuntu-latest
30+ outputs :
31+ key : ${{ steps.keygen.outputs.smcache_key }}
3032 steps :
3133 - uses : actions/checkout@v4
3234
3335 - name : Remove unneeded frameworks to recover disk space
3436 run : sudo ./.github/cleanup-rootfs.sh
3537
38+ - name : Generate submodule cache key
39+ id : keygen
40+ run : echo "smcache_key=smcache-$(printf $(git submodule | sha1sum))" >> $GITHUB_OUTPUT
41+
42+ - name : Setup submodule cache
43+ id : smcache
44+ uses : actions/cache@v4
45+ with :
46+ enableCrossOsArchive : true
47+ path : ${{ env.submodule_paths }}
48+ key : ${{ steps.keygen.outputs.smcache_key }}
49+
3650 - name : Checkout required submodules
51+ if : steps.smcache.outputs.cache-hit != 'true'
3752 run : git submodule update --init -j $(nproc) --depth 1 $(echo ${submodule_paths} | sed '$d' | tr '\n' ' ')
3853
3954 - name : Storage size optimization
55+ if : steps.smcache.outputs.cache-hit != 'true'
4056 run : |
4157 echo "Submodules env var: ${submodule_paths}"
4258 git submodule foreach 'git maintenance run'
4359
44- - name : Setup submodule cache
45- uses : actions/cache@v4
46- with :
47- enableCrossOsArchive : true
48- path : ${{ env.submodule_paths }}
49- key : submodule-cache-${{ github.run_id }}-${{ github.run_attempt }}
50-
5160 build :
5261 runs-on : ${{ matrix.os }}
5362 needs : [submodule_cache]
63+ env :
64+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
5465 strategy :
5566 matrix :
5667 os : [ubuntu-22.04, ubuntu-24.04]
7687 with :
7788 enableCrossOsArchive : true
7889 path : ${{ env.submodule_paths }}
79- key : submodule-cache- ${{ github.run_id }}-${{ github.run_attempt }}
90+ key : ${{ env.smcache_key }}
8091
8192 - name : build toolchain
8293 run : |
@@ -129,6 +140,8 @@ jobs:
129140 test-sim :
130141 runs-on : ${{ matrix.os }}
131142 needs : [submodule_cache]
143+ env :
144+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
132145 strategy :
133146 matrix :
134147 os : [ubuntu-24.04]
@@ -149,7 +162,7 @@ jobs:
149162 with :
150163 enableCrossOsArchive : true
151164 path : ${{ env.submodule_paths }}
152- key : submodule-cache- ${{ github.run_id }}-${{ github.run_attempt }}
165+ key : ${{ env.smcache_key }}
153166
154167 - name : build toolchain
155168 run : |
0 commit comments