Skip to content

Commit 1116a35

Browse files
committed
ci(test): Add cargo-nextest and optimize test firmware builds
- Install and cache cargo-nextest binary for faster test execution - Pre-build test firmware once before running tests - Replace cargo test with cargo nextest run --no-fail-fast - Set CALIPTRA_PREBUILT_FW_DIR to reuse pre-built firmware across tests - coverage now also runs objdump on prebuild firmware so add the right tools On my local system using ~cargo nextest run~ took 180s where ~cargo test~ took 240 so it seems significantly faster. Signed-off-by: Arthur Heymans <[email protected]>
1 parent 4fdecc7 commit 1116a35

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

.github/workflows/build-test.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,30 @@ jobs:
2626
# Compiler warnings should fail to compile
2727
EXTRA_CARGO_CONFIG: "target.'cfg(all())'.rustflags = [\"-Dwarnings\"]"
2828

29+
# Nextest version
30+
NEXTEST_VERSION: 0.9.114
31+
CACHE_BUSTER: f7c64774f37c
32+
2933
steps:
34+
- name: Restore cargo-nextest binary
35+
uses: actions/cache/restore@v3
36+
id: nextest_bin_restore
37+
with:
38+
path: ~/.cargo/bin/cargo-nextest
39+
key: nextest-bin-${{ env.NEXTEST_VERSION}}-${{ env.CACHE_BUSTER }}
40+
41+
- name: Install cargo-nextest
42+
if: steps.nextest_bin_restore.outputs.cache-hit != 'true'
43+
run: |
44+
cargo install cargo-nextest --version ${NEXTEST_VERSION} --locked --no-default-features --features=default-no-update
45+
46+
- name: Save cargo-nextest binary
47+
uses: actions/cache/save@v3
48+
if: steps.nextest_bin_restore.outputs.cache-hit != 'true'
49+
with:
50+
path: ~/.cargo/bin/cargo-nextest
51+
key: ${{ steps.nextest_bin_restore.outputs.cache-primary-key }}
52+
3053
- name: Checkout repo
3154
uses: actions/checkout@v3
3255

@@ -127,16 +150,24 @@ jobs:
127150
popd; \
128151
done
129152
153+
- name: Build test firmware
154+
run: |
155+
rustup target add riscv32imc-unknown-none-elf
156+
sudo apt-get install gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf
157+
mkdir /tmp/caliptra-test-firmware
158+
cargo run -p caliptra-builder -- --all_elfs /tmp/caliptra-test-firmware
159+
130160
- name: Run tests
131161
run: |
132-
CPTRA_COVERAGE_PATH=/tmp cargo --config "$EXTRA_CARGO_CONFIG" test --locked
162+
export CALIPTRA_PREBUILT_FW_DIR=/tmp/caliptra-test-firmware
163+
164+
CPTRA_COVERAGE_PATH=/tmp cargo --config "$EXTRA_CARGO_CONFIG" nextest run --locked --no-fail-fast
133165
CPTRA_COVERAGE_PATH=/tmp cargo --config "$EXTRA_CARGO_CONFIG" run --manifest-path ./coverage/Cargo.toml
134166
135-
CARGO_TARGET_DIR=target cargo --config "$EXTRA_CARGO_CONFIG" test --locked --manifest-path ci-tools/fpga-boss/Cargo.toml
167+
CARGO_TARGET_DIR=target cargo --config "$EXTRA_CARGO_CONFIG" nextest run --locked --no-fail-fast --manifest-path ci-tools/fpga-boss/Cargo.toml
136168
137169
- name: Run emulator conformance tests
138170
run: |
139-
sudo apt-get install gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf
140171
(cd /tmp/ && git clone --depth 1 --branch old-framework-2.x https://github.com/riscv-non-isa/riscv-arch-test)
141172
cargo --config "$EXTRA_CARGO_CONFIG" run --locked -p compliance-test -- --test_root_path /tmp/riscv-arch-test
142173

0 commit comments

Comments
 (0)