Skip to content

Commit 9818f68

Browse files
authored
ci: build test data only once. (#243)
Signed-off-by: Piotr Sikora <[email protected]>
1 parent e67b546 commit 9818f68

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/cpp.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,51 @@ jobs:
5757
export PATH=$PATH:$(go env GOPATH)/bin
5858
addlicense -check .
5959
60+
test_data:
61+
name: build test data
62+
63+
runs-on: ubuntu-20.04
64+
65+
steps:
66+
- uses: actions/checkout@v2
67+
68+
- name: Bazel cache
69+
uses: actions/cache@v2
70+
with:
71+
path: |
72+
~/.cache/bazel
73+
key: test_data-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/crates.bzl') }}
74+
75+
- name: Bazel build
76+
run: >
77+
bazel build
78+
--verbose_failures
79+
--test_output=errors
80+
-c opt
81+
$(bazel query 'kind(was.*_rust_binary, //test/test_data/...)')
82+
83+
- name: Upload test data
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: test_data
87+
path: bazel-bin/test/test_data/*.wasm
88+
if-no-files-found: error
89+
retention-days: 3
90+
91+
- name: Cleanup Bazel cache
92+
run: |
93+
export OUTPUT=$(bazel info output_base)
94+
# Distfiles for Rust toolchains (350 MiB).
95+
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
96+
# Bazel's repository cache (650-800 MiB) and install base (155 MiB).
97+
rm -rf $(bazel info repository_cache)
98+
rm -rf $(bazel info install_base)
99+
60100
build:
61101
name: ${{ matrix.action }} with ${{ matrix.name }}
62102

103+
needs: test_data
104+
63105
runs-on: ${{ matrix.os }}
64106

65107
strategy:
@@ -147,6 +189,20 @@ jobs:
147189
${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.runtime }}-${{ steps.cache-key.outputs.uniq }}-
148190
${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.runtime }}
149191
192+
- name: Download test data
193+
uses: actions/download-artifact@v2
194+
with:
195+
name: test_data
196+
path: test/test_data/
197+
198+
- name: Mangle build rules to use existing test data
199+
run: >
200+
sed 's/\.wasm//g' test/BUILD > test/BUILD.tmp && mv test/BUILD.tmp test/BUILD;
201+
echo "package(default_visibility = [\"//visibility:public\"])" > test/test_data/BUILD;
202+
for i in $(cd test/test_data && ls -1 *.wasm | sed 's/\.wasm$//g');
203+
do echo "filegroup(name = \"$i\", srcs = [\"$i.wasm\"])" >> test/test_data/BUILD;
204+
done
205+
150206
- name: Bazel build/test
151207
run: >
152208
${{ matrix.run_under }}

0 commit comments

Comments
 (0)