@@ -129,10 +129,38 @@ jobs:
129129 env :
130130 MATRIX_ARCH : ${{ matrix.arch }}
131131
132+ - name : Download artifact from spc-download.yml
133+ uses : dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
134+ with :
135+ workflow : spc-download.yml
136+ name : downloads-tarball
137+
138+ - name : Compute buildroot cache key
139+ id : cache-key
140+ run : |
141+ set -euo pipefail
142+ HASH=$(
143+ {
144+ sha256sum composer.lock craft.yml bin/spp Dockerfile.rhel downloads.tar.gz
145+ find src -type f -print0 | LC_ALL=C sort -z | xargs -0 sha256sum
146+ } | sha256sum | cut -c1-16
147+ )
148+ WEEK=$(date -u +%G-%V)
149+ echo "key=buildroot-rpm-alma${{ matrix.alma }}-${{ matrix.arch }}-gcc-${WEEK}-${HASH}" >> $GITHUB_OUTPUT
150+
151+ - name : Restore buildroot cache
152+ id : cache
153+ uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
154+ with :
155+ path : buildroot.tar.zst
156+ key : ${{ steps.cache-key.outputs.key }}
157+
132158 - name : Prepare cache directories
159+ if : steps.cache.outputs.cache-hit != 'true'
133160 run : composer config -g cache-dir
134161
135162 - name : Cache Composer downloads
163+ if : steps.cache.outputs.cache-hit != 'true'
136164 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
137165 with :
138166 path : ~/.cache/composer
@@ -141,26 +169,31 @@ jobs:
141169 composer-
142170
143171 - name : Composer install
172+ if : steps.cache.outputs.cache-hit != 'true'
144173 run : composer install --no-interaction --prefer-dist --no-progress
145174
146- - name : Download artifact from spc-download.yml
147- uses : dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
148- with :
149- workflow : spc-download.yml
150- name : downloads-tarball
151-
152175 - name : Extract with permissions
176+ if : steps.cache.outputs.cache-hit != 'true'
153177 run : |
154178 mkdir -p downloads
155179 tar -xzf downloads.tar.gz -C downloads
156180 rm downloads.tar.gz
157181
158182 - name : Build libs
183+ if : steps.cache.outputs.cache-hit != 'true'
159184 run : php bin/spp build --type=rpm --debuginfo --phpv=8.4 --libs-only
160185
161186 - name : Pack buildroot
187+ if : steps.cache.outputs.cache-hit != 'true'
162188 run : tar -cf - buildroot | zstd -o buildroot.tar.zst
163189
190+ - name : Save buildroot cache
191+ if : steps.cache.outputs.cache-hit != 'true'
192+ uses : actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
193+ with :
194+ path : buildroot.tar.zst
195+ key : ${{ steps.cache-key.outputs.key }}
196+
164197 - name : Upload buildroot
165198 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
166199 with :
@@ -211,10 +244,38 @@ jobs:
211244 env :
212245 MATRIX_ARCH : ${{ matrix.arch }}
213246
247+ - name : Download artifact from spc-download.yml
248+ uses : dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
249+ with :
250+ workflow : spc-download.yml
251+ name : downloads-tarball
252+
253+ - name : Compute buildroot cache key
254+ id : cache-key
255+ run : |
256+ set -euo pipefail
257+ HASH=$(
258+ {
259+ sha256sum composer.lock craft.yml bin/spp Dockerfile.rhel downloads.tar.gz
260+ find src -type f -print0 | LC_ALL=C sort -z | xargs -0 sha256sum
261+ } | sha256sum | cut -c1-16
262+ )
263+ WEEK=$(date -u +%G-%V)
264+ echo "key=buildroot-rpm-alma${{ matrix.alma }}-${{ matrix.arch }}-zig-${WEEK}-${HASH}" >> $GITHUB_OUTPUT
265+
266+ - name : Restore buildroot cache
267+ id : cache
268+ uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
269+ with :
270+ path : buildroot.tar.zst
271+ key : ${{ steps.cache-key.outputs.key }}
272+
214273 - name : Prepare cache directories
274+ if : steps.cache.outputs.cache-hit != 'true'
215275 run : composer config -g cache-dir
216276
217277 - name : Cache Composer downloads
278+ if : steps.cache.outputs.cache-hit != 'true'
218279 uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
219280 with :
220281 path : ~/.cache/composer
@@ -223,26 +284,31 @@ jobs:
223284 composer-
224285
225286 - name : Composer install
287+ if : steps.cache.outputs.cache-hit != 'true'
226288 run : composer install --no-interaction --prefer-dist --no-progress
227289
228- - name : Download artifact from spc-download.yml
229- uses : dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5 # v11
230- with :
231- workflow : spc-download.yml
232- name : downloads-tarball
233-
234290 - name : Extract with permissions
291+ if : steps.cache.outputs.cache-hit != 'true'
235292 run : |
236293 mkdir -p downloads
237294 tar -xzf downloads.tar.gz -C downloads
238295 rm downloads.tar.gz
239296
240297 - name : Build libs
298+ if : steps.cache.outputs.cache-hit != 'true'
241299 run : php bin/spp build --type=rpm --debuginfo --phpv=8.5 --libs-only
242300
243301 - name : Pack buildroot
302+ if : steps.cache.outputs.cache-hit != 'true'
244303 run : tar -cf - buildroot | zstd -o buildroot.tar.zst
245304
305+ - name : Save buildroot cache
306+ if : steps.cache.outputs.cache-hit != 'true'
307+ uses : actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
308+ with :
309+ path : buildroot.tar.zst
310+ key : ${{ steps.cache-key.outputs.key }}
311+
246312 - name : Upload buildroot
247313 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
248314 with :
0 commit comments