Skip to content

ci: build test data only once. #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,51 @@ jobs:
export PATH=$PATH:$(go env GOPATH)/bin
addlicense -check .

test_data:
name: build test data

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Bazel cache
uses: actions/cache@v2
with:
path: |
~/.cache/bazel
key: test_data-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/dependencies.bzl', 'bazel/repositories.bzl', 'bazel/cargo/wasmsign/crates.bzl') }}

- name: Bazel build
run: >
bazel build
--verbose_failures
--test_output=errors
-c opt
$(bazel query 'kind(was.*_rust_binary, //test/test_data/...)')

- name: Upload test data
uses: actions/upload-artifact@v2
with:
name: test_data
path: bazel-bin/test/test_data/*.wasm
if-no-files-found: error
retention-days: 3

- name: Cleanup Bazel cache
run: |
export OUTPUT=$(bazel info output_base)
# Distfiles for Rust toolchains (350 MiB).
rm -rf ${OUTPUT}/external/rust_*/*.tar.gz
# Bazel's repository cache (650-800 MiB) and install base (155 MiB).
rm -rf $(bazel info repository_cache)
rm -rf $(bazel info install_base)

build:
name: ${{ matrix.action }} with ${{ matrix.name }}

needs: test_data

runs-on: ${{ matrix.os }}

strategy:
Expand Down Expand Up @@ -147,6 +189,20 @@ jobs:
${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.runtime }}-${{ steps.cache-key.outputs.uniq }}-
${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.runtime }}

- name: Download test data
uses: actions/download-artifact@v2
with:
name: test_data
path: test/test_data/

- name: Mangle build rules to use existing test data
run: >
sed 's/\.wasm//g' test/BUILD > test/BUILD.tmp && mv test/BUILD.tmp test/BUILD;
echo "package(default_visibility = [\"//visibility:public\"])" > test/test_data/BUILD;
for i in $(cd test/test_data && ls -1 *.wasm | sed 's/\.wasm$//g');
do echo "filegroup(name = \"$i\", srcs = [\"$i.wasm\"])" >> test/test_data/BUILD;
done

- name: Bazel build/test
run: >
${{ matrix.run_under }}
Expand Down