Skip to content

Commit 06bf72f

Browse files
tbrosveitser
andauthored
Improve runtime of tests (#1854)
Improves CI runtime by working around slow tests. The last commit on main, tests took 36min. Tests are currently completing in this PR in 12m. * switch to nextest * separate build and test steps * use --retries (retries and marks tests that succeed upon retry as FLAKY * split slow dev-node tests to separate workflow. That new workflow is *not* required for merge --------- Co-authored-by: tbro <[email protected]> Co-authored-by: sveitser <[email protected]>
1 parent c75c813 commit 06bf72f

File tree

5 files changed

+89
-11
lines changed

5 files changed

+89
-11
lines changed

.github/workflows/slowtest.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: SlowEst
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
tags:
9+
# YYYYMMDD
10+
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
11+
schedule:
12+
- cron: "0 0 * * 1"
13+
pull_request:
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ !contains(github.ref, 'main')}}
19+
20+
env:
21+
RUSTFLAGS: '--cfg async_executor_impl="async-std" --cfg async_channel_impl="async-std"'
22+
RUST_LOG: info,libp2p=off,node=error
23+
24+
jobs:
25+
slowest:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Fix submodule permissions check
29+
run: |
30+
git config --global --add safe.directory '*'
31+
32+
- name: Install Foundry
33+
uses: foundry-rs/foundry-toolchain@v1
34+
with:
35+
version: nightly
36+
37+
- uses: taiki-e/install-action@nextest
38+
39+
- name: Checkout Repository
40+
uses: actions/checkout@v4
41+
with:
42+
submodules: recursive
43+
44+
- name: Enable Rust Caching
45+
uses: Swatinem/rust-cache@v2
46+
47+
- name: Build
48+
# Build test binary with `testing` feature, which requires `hotshot_example` config
49+
run: |
50+
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
51+
export PATH="$PWD/target/release:$PATH"
52+
cargo build --locked --bin diff-test --release
53+
cargo nextest run --locked --release --workspace --all-features --no-run
54+
timeout-minutes: 90
55+
56+
- name: SlowEst
57+
env:
58+
CARGO_TERM_COLOR: always
59+
# Build test binary with `testing` feature, which requires `hotshot_example` config
60+
run: |
61+
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
62+
export PATH="$PWD/target/release:$PATH"
63+
cargo nextest run --locked --release --workspace --all-features --verbose -E 'test(slow_)'
64+
timeout-minutes: 25

.github/workflows/test.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ jobs:
3434
with:
3535
version: nightly
3636

37-
- name: Install just command runner
38-
run: |
39-
sudo snap install --edge --classic just
40-
just --version
37+
- uses: taiki-e/install-action@nextest
4138

4239
- name: Checkout Repository
4340
uses: actions/checkout@v4
@@ -47,12 +44,21 @@ jobs:
4744
- name: Enable Rust Caching
4845
uses: Swatinem/rust-cache@v2
4946

50-
- name: Test
47+
- name: Build
5148
# Build test binary with `testing` feature, which requires `hotshot_example` config
5249
run: |
5350
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
5451
export PATH="$PWD/target/release:$PATH"
5552
cargo build --locked --bin diff-test --release
56-
cargo test --locked --release --workspace --all-features --no-run
57-
cargo test --locked --release --workspace --all-features --verbose -- --test-threads 1 --nocapture
53+
cargo nextest run --locked --release --workspace --all-features --no-run
5854
timeout-minutes: 90
55+
56+
- name: Test
57+
env:
58+
CARGO_TERM_COLOR: always
59+
# Build test binary with `testing` feature, which requires `hotshot_example` config
60+
run: |
61+
export RUSTFLAGS="$RUSTFLAGS --cfg hotshot_example"
62+
export PATH="$PWD/target/release:$PATH"
63+
cargo nextest run --locked --release --workspace --all-features --retries 2 --verbose -E '!test(slow_)'
64+
timeout-minutes: 5

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
cargo-audit
198198
cargo-edit
199199
cargo-sort
200+
cargo-nextest
200201
typos
201202
just
202203
fenix.packages.${system}.rust-analyzer

justfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ anvil *args:
3434
docker run -p 127.0.0.1:8545:8545 ghcr.io/foundry-rs/foundry:latest "anvil {{args}}"
3535

3636
test:
37-
cargo build --bin diff-test --release
38-
cargo test --release --all-features
37+
@echo 'Omitting slow tests. Use `test-slow` for those. Or `test-all` for all tests.'
38+
cargo nextest run --locked --release --workspace --all-features --retries 2 --verbose -E '!test(slow_)'
39+
40+
test-slow:
41+
@echo 'Only slow tests are included. Use `test` for those deemed not slow. Or `test-all` for all tests.'
42+
cargo nextest run --locked --release --workspace --all-features --verbose -E 'test(slow_)'
43+
44+
test-all:
45+
cargo nextest run --locked --release --workspace --all-features --verbose
3946

4047
clippy:
4148
cargo clippy --workspace --all-features --all-targets -- -D warnings

sequencer/src/bin/espresso-dev-node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ mod tests {
541541
// - APIs update
542542
// - Types (like `Header`) update
543543
#[async_std::test]
544-
async fn dev_node_test() {
544+
async fn slow_dev_node_test() {
545545
setup_test();
546546

547547
let builder_port = pick_unused_port().unwrap();
@@ -849,7 +849,7 @@ mod tests {
849849
}
850850

851851
#[async_std::test]
852-
async fn dev_node_multiple_lc_providers_test() {
852+
async fn slow_dev_node_multiple_lc_providers_test() {
853853
setup_test();
854854

855855
let builder_port = pick_unused_port().unwrap();

0 commit comments

Comments
 (0)