@@ -29,28 +29,39 @@ jobs:
2929 submodule_cache :
3030 name : Initialize submodule cache
3131 runs-on : ubuntu-latest
32+ outputs :
33+ key : ${{ steps.keygen.outputs.smcache_key }}
3234 steps :
3335 - uses : actions/checkout@v4
3436
3537 - name : Remove unneeded frameworks to recover disk space
3638 run : sudo ./.github/cleanup-rootfs.sh
3739
40+ - name : Generate submodule cache key
41+ id : keygen
42+ run : echo "smcache_key=smcache-$(printf $(git submodule | sha1sum))" >> $GITHUB_OUTPUT
43+
44+ - name : Setup submodule cache
45+ id : smcache
46+ uses : actions/cache@v4
47+ with :
48+ path : ${{ env.submodule_paths }}
49+ key : ${{ steps.keygen.outputs.smcache_key }}
50+
3851 - name : Checkout required submodules
52+ if : steps.smcache.outputs.cache-hit != 'true'
3953 run : git submodule update --init -j $(nproc) --depth 1 $(echo ${submodule_paths} | sed '$d' | tr '\n' ' ')
4054
4155 - name : Storage size optimization
56+ if : steps.smcache.outputs.cache-hit != 'true'
4257 run : |
4358 git submodule foreach 'git maintenance run'
4459
45- - name : Setup submodule cache
46- uses : actions/cache@v4
47- with :
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]
7586 uses : actions/cache/restore@v4
7687 with :
7788 path : ${{ env.submodule_paths }}
78- key : submodule-cache- ${{ github.run_id }}-${{ github.run_attempt }}
89+ key : ${{ env.smcache_key }}
7990
8091 - name : build toolchain
8192 run : |
@@ -134,6 +145,8 @@ jobs:
134145 test-sim :
135146 runs-on : ${{ matrix.os }}
136147 needs : [submodule_cache]
148+ env :
149+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
137150 strategy :
138151 matrix :
139152 os : [ubuntu-24.04]
@@ -153,7 +166,7 @@ jobs:
153166 uses : actions/cache/restore@v4
154167 with :
155168 path : ${{ env.submodule_paths }}
156- key : submodule-cache- ${{ github.run_id }}-${{ github.run_attempt }}
169+ key : ${{ env.smcache_key }}
157170
158171 - name : build toolchain
159172 run : |
@@ -170,6 +183,8 @@ jobs:
170183 if : ${{ false }} # Disable until multilib errors are triaged
171184 runs-on : ${{ matrix.os }}
172185 needs : [submodule_cache]
186+ env :
187+ smcache_key : ${{ needs.submodule_cache.outputs.key }}
173188 strategy :
174189 matrix :
175190 os : [ubuntu-24.04]
@@ -188,7 +203,7 @@ jobs:
188203 uses : actions/cache/restore@v4
189204 with :
190205 path : ${{ env.submodule_paths }}
191- key : submodule-cache- ${{ github.run_id }}-${{ github.run_attempt }}
206+ key : ${{ env.smcache_key }}
192207
193208 - name : build toolchain
194209 run : |
0 commit comments