@@ -48,19 +48,34 @@ jobs:
48
48
steps :
49
49
- uses : actions/checkout@v2
50
50
51
- - name : Bazel cache
52
- uses : PiotrSikora/cache@v2.1.7-with-skip-cache
51
+ - name : set cache name
52
+ id : vars
53
+ # The cache tag consists of the following parts:
54
+ # * test-deps-bazel-cache- prefix
55
+ # * hash of WORKSPACE, .bazelrc, and .bazelversion, which is
56
+ # purely to differentiate caches for substantial changes in bazel.
57
+ # * github.sha, which is the commit hash of the commit used to generate
58
+ # the cache entry.
59
+ run : echo "CACHE_TAG=test-deps-bazel-cache-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT"
60
+
61
+ - name : bazel cache
62
+ uses : actions/cache/restore@v3
53
63
with :
54
- path : |
55
- ~/.cache/bazel
56
- key : test_data-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/crates.bzl') }}
64
+ path : /tmp/bazel/cache
65
+ key : ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
66
+ restore-keys : |
67
+ ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
68
+ ${{ steps.vars.outputs.CACHE_TAG }}-
69
+ test-deps-bazel-cache-${{ matrix.name }}-
70
+ test-deps-bazel-cache-
57
71
58
72
- name : Bazel build
59
73
run : >
60
74
bazel build
61
75
--verbose_failures
62
76
--test_output=errors
63
77
--config=clang
78
+ --disk_cache /tmp/bazel/cache
64
79
-c opt
65
80
$(bazel query 'kind(was.*_rust_binary, //test/test_data/...)')
66
81
$(bazel query 'kind(_optimized_wasm_cc_binary, //test/test_data/...)')
@@ -84,19 +99,12 @@ jobs:
84
99
if-no-files-found : error
85
100
retention-days : 3
86
101
87
- - name : Skip Bazel cache update
88
- if : ${{ github.ref != 'refs/heads/main' }}
89
- run : echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV
90
-
91
- - name : Cleanup Bazel cache
92
- if : ${{ github.ref == 'refs/heads/main' }}
93
- run : |
94
- export OUTPUT=$(bazel info output_base)
95
- # Distfiles for Rust toolchains (350 MiB).
96
- rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
97
- # Bazel's repository cache (650-800 MiB) and install base (155 MiB).
98
- rm -rf $(bazel info repository_cache)
99
- rm -rf $(bazel info install_base)
102
+ - name : save bazel cache
103
+ uses : actions/cache/save@v3
104
+ if : always()
105
+ with :
106
+ path : /tmp/bazel/cache
107
+ key : ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
100
108
101
109
build :
102
110
name : ${{ matrix.action }} with ${{ matrix.name }}
@@ -282,21 +290,27 @@ jobs:
282
290
if : startsWith(matrix.run_under, 'docker')
283
291
run : docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
284
292
285
- - name : Set cache key
286
- if : ${{ matrix.cache }}
287
- run : echo "::set-output name=uniq::$(bazel query --output build //external:${{ matrix.repo }} | grep -E 'sha256|commit' | cut -d\" -f2)-$(echo ${{ matrix.flags }} | sha256sum)"
288
- id : cache-key
289
-
290
- - name : Bazel cache
291
- if : ${{ matrix.cache }}
292
- uses : PiotrSikora/cache@v2.1.7-with-skip-cache
293
+ - name : set cache name
294
+ id : vars
295
+ # The cache tag consists of the following parts:
296
+ # * bazel-cache- prefix
297
+ # * matrix.name, which separates the cache for each build type.
298
+ # * hash of WORKSPACE, .bazelrc, and .bazelversion, which is
299
+ # purely to differentiate caches for substantial changes in bazel.
300
+ # * github.sha, which is the commit hash of the commit used to generate
301
+ # the cache entry.
302
+ run : echo "CACHE_TAG=bazel-cache-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT"
303
+
304
+ - name : bazel cache
305
+ uses : actions/cache/restore@v3
293
306
with :
294
- path : |
295
- ~/.cache/bazel
296
- /private/var/tmp/_bazel_runner/
297
- key : ${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.engine }}-${{ steps.cache-key.outputs.uniq }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}
307
+ path : /tmp/bazel/cache
308
+ key : ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
298
309
restore-keys : |
299
- ${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.engine }}-${{ steps.cache-key.outputs.uniq }}-
310
+ ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
311
+ ${{ steps.vars.outputs.CACHE_TAG }}-
312
+ bazel-cache-${{ matrix.name }}-
313
+ bazel-cache-
300
314
301
315
- name : Download test data
302
316
uses : actions/download-artifact@v4
@@ -321,6 +335,7 @@ jobs:
321
335
--verbose_failures
322
336
--test_output=errors
323
337
--define engine=${{ matrix.engine }}
338
+ --disk_cache /tmp/bazel/cache
324
339
${{ matrix.flags }}
325
340
-- //test/... ${{ matrix.targets }}
326
341
@@ -332,38 +347,15 @@ jobs:
332
347
--verbose_failures
333
348
--test_output=errors
334
349
--define engine=${{ matrix.engine }}
350
+ --disk_cache /tmp/bazel/cache
335
351
${{ matrix.flags }}
336
352
--per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -b9-)\"
337
353
//test:signature_util_test
338
354
339
- - name : Skip Bazel cache update
340
- if : ${{ matrix.cache && github.ref != 'refs/heads/main' }}
341
- run : echo "CACHE_SKIP_SAVE=true" >> $GITHUB_ENV
355
+ - name : save bazel cache
356
+ uses : actions/cache/save@v3
357
+ if : always()
358
+ with :
359
+ path : /tmp/bazel/cache
360
+ key : ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
342
361
343
- - name : Cleanup Bazel cache
344
- if : ${{ matrix.cache && github.ref == 'refs/heads/main' }}
345
- run : |
346
- export OUTPUT=$(${{ matrix.run_under }} bazel info output_base)
347
- echo "===== BEFORE ====="
348
- du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20
349
- # BoringSSL's test data (90 MiB).
350
- rm -rf ${OUTPUT}/external/boringssl/crypto_test_data.cc
351
- rm -rf ${OUTPUT}/external/boringssl/src/crypto/*/test/
352
- rm -rf ${OUTPUT}/external/boringssl/src/third_party/wycheproof_testvectors/
353
- # LLVM's tests (500 MiB).
354
- rm -rf ${OUTPUT}/external/llvm*/test/
355
- # V8's tests (100 MiB).
356
- if [ -d "${OUTPUT}/external/v8/test/torque" ]; then
357
- mv ${OUTPUT}/external/v8/test/torque ${OUTPUT}/external/v8/test_torque
358
- rm -rf ${OUTPUT}/external/v8/test/*
359
- mv ${OUTPUT}/external/v8/test_torque ${OUTPUT}/external/v8/test/torque
360
- fi
361
- # Unnecessary CMake tools (65 MiB).
362
- rm -rf ${OUTPUT}/external/cmake-*/bin/{ccmake,cmake-gui,cpack,ctest}
363
- # Distfiles for Rust toolchains (350 MiB).
364
- rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
365
- # Bazel's repository cache (650-800 MiB) and install base (155 MiB).
366
- rm -rf ${OUTPUT}/../cache
367
- rm -rf ${OUTPUT}/../install
368
- echo "===== AFTER ====="
369
- du -s ${OUTPUT}/external/* $(dirname ${OUTPUT})/* | sort -rn | head -20
0 commit comments