Skip to content

Commit af1728e

Browse files
authored
build: improve caching. (proxy-wasm#210)
There is a lot of unnecessary data in Bazel's cache, so this commit removes Bazel's repository cache (~700 MiB), install base (150 MiB) and tarballs from the Rust toolchain (350 MiB) before saving cache. This decreases the cache size for each OS+runtime combination from 1.8 GiB to 700 MiB, which means that we can save cache from 2 runs with 7 combinations using GitHub's 10 GiB total storage. Additionally, Wasmtime builds so fast that we can disable cache to free 2 slots for future OS+runtime combinations. While there, fix caching on macOS, which uses a different location. Signed-off-by: Piotr Sikora <[email protected]>
1 parent 5d1798b commit af1728e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

.github/workflows/cpp.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ jobs:
9999
if: startsWith(matrix.os, 'macos')
100100
run: brew install ninja
101101

102-
- name: Mount Bazel cache
102+
- name: Bazel cache
103+
if: matrix.runtime != 'wasmtime'
103104
uses: actions/cache@v2
104105
with:
105106
path: |
106107
~/.cache/bazel
107-
~/.cache/bazelisk
108+
/private/var/tmp/_bazel_runner/
108109
key: bazel-${{ matrix.os }}-${{ matrix.runtime }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}
109110

110111
- name: Test
@@ -114,3 +115,27 @@ jobs:
114115
- name: Test (signed Wasm module)
115116
run: |
116117
bazel test --test_output=errors --define runtime=${{ matrix.runtime }} --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-)\" //test:signature_util_test
118+
119+
- name: Cleanup Bazel cache
120+
if: matrix.runtime != 'wasmtime'
121+
run: |
122+
export OUTPUT=$(bazel info output_base)
123+
# BoringSSL's test data (90 MiB).
124+
rm -rf ${OUTPUT}/external/boringssl/crypto_test_data.cc
125+
rm -rf ${OUTPUT}/external/boringssl/src/crypto/*/test/
126+
rm -rf ${OUTPUT}/external/boringssl/src/third_party/wycheproof_testvectors/
127+
# LLVM's tests (500 MiB).
128+
rm -rf ${OUTPUT}/external/llvm*/test/
129+
# V8's tests (100 MiB).
130+
if [ -d "${OUTPUT}/external/v8/test/torque" ]; then
131+
mv ${OUTPUT}/external/v8/test/torque ${OUTPUT}/external/v8/test_torque
132+
rm -rf ${OUTPUT}/external/v8/test/*
133+
mv ${OUTPUT}/external/v8/test_torque ${OUTPUT}/external/v8/test/torque
134+
fi
135+
# Unnecessary CMake tools (65 MiB).
136+
rm -rf ${OUTPUT}/external/cmake-*/bin/{ccmake,cmake-gui,cpack,ctest}
137+
# Distfiles for Rust toolchains (350 MiB).
138+
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
139+
# Bazel's repository cache (650-800 MiB) and install base (155 MiB).
140+
rm -rf $(bazel info repository_cache)
141+
rm -rf $(bazel info install_base)

0 commit comments

Comments
 (0)