Skip to content

Commit

Permalink
slh-dsa: migrate to nextest, shard tests (#914)
Browse files Browse the repository at this point in the history
GitHub CI is too slow and most of the time times out before we can run
all the tests.

This migrates the tests to using nextest to use their sharding
implementation.
  • Loading branch information
baloo authored Feb 24, 2025
1 parent d3640f1 commit 647de14
Showing 1 changed file with 63 additions and 4 deletions.
67 changes: 63 additions & 4 deletions .github/workflows/slh-dsa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ defaults:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
CARGO_TERM_COLOR: always
NEXTEST_NO_TESTS: warn

jobs:
no_std:
Expand All @@ -35,19 +37,76 @@ jobs:
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --no-default-features

test:
# because we're sharding tests, we'll compile them once first
# upload that as artifact, and then re-download those artifacts
# and run the tests.
# This is heavily insired by https://github.com/nextest-rs/reuse-build-partition-example/blob/main/.github/workflows/ci.yml
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.81.0 # MSRV
- stable
test_config:
- --no-default-features
- --all-features
- default
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: taiki-e/install-action@nextest
- run: cargo check --all-features
- run: cargo test --no-default-features
- run: cargo test
- run: cargo test --all-features
- name: Build and archive tests
run: |
PROFILE="${{ matrix.test_config }}"
if [ "$PROFILE" = "default" ]; then
PROFILE="--features default"
fi
cargo nextest archive --archive-file nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}.tar.zst $PROFILE
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
name: nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}
# NOTE: upload-artifact does not respect the working directory, we need to prefix it.
# https://github.com/actions/upload-artifact/issues/294
path: slh-dsa/nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}.tar.zst

if-no-files-found: error
compression-level: 0
retention-days: 1

run-test:
name: slh-dsa/run tests
needs: build-test
runs-on: ubuntu-latest
strategy:
matrix:
test-partition: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
rust:
- 1.81.0 # MSRV
- stable
test_config:
- --no-default-features
- --all-features
- "default"
steps:
- uses: actions/checkout@v4
- run: mkdir -p ~/.cargo/bin
- uses: taiki-e/install-action@nextest
- name: Download test archive
uses: actions/download-artifact@v4
with:
name: nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}
path: slh-dsa
- name: Run tests (${{ matrix.rust }}) (${{ matrix.test_config }})
run: |
PROFILE="${{ matrix.test_config }}"
if [ "$PROFILE" = "default" ]; then
PROFILE="--features default"
fi
~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive-${{ matrix.rust }}-${{ matrix.test_config }}.tar.zst \
--partition count:${{ matrix.test-partition }}/16

0 comments on commit 647de14

Please sign in to comment.