name: Tests
on:
workflow_call:
inputs:
rust-version:
description: "The version of the rust compiler to run"
type: string
default: "stable"
flaky:
description: "Whether to also run flaky tests"
type: boolean
default: false
git-ref:
description: "Which git ref to checkout"
type: string
default: ${{ github.ref }}
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -Dwarnings
RUSTDOCFLAGS: -Dwarnings
SCCACHE_CACHE_SIZE: "50G"
CRATES_LIST: "n0-error"
permissions:
contents: read
jobs:
build_and_test_nix:
timeout-minutes: 30
name: "Tests"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, macOS-arm-latest]
rust: ["${{ inputs.rust-version }}"]
features: [all, none, default]
include:
- name: ubuntu-latest
os: ubuntu-latest
release-os: linux
release-arch: amd64
runner: [self-hosted, linux, X64]
- name: macOS-arm-latest
os: macOS-latest
release-os: darwin
release-arch: aarch64
runner: [self-hosted, macOS, ARM64]
env:
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }} rust
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-nextest
uses: taiki-e/install-action@682ce6c3c696a4cd5168a05f98e51aa02b877941 with:
tool: nextest@0.9.80
- name: Install sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba
- name: Select features
env:
MATRIX_FEATURES: ${{ matrix.features }}
run: |
case "$MATRIX_FEATURES" in
all)
echo "FEATURES=--all-features" >> "$GITHUB_ENV"
;;
none)
echo "FEATURES=--no-default-features" >> "$GITHUB_ENV"
;;
default)
echo "FEATURES=" >> "$GITHUB_ENV"
;;
*)
exit 1
esac
- name: check features
if: ${{ ! inputs.flaky }}
run: |
for i in ${CRATES_LIST//,/ }
do
echo "Checking $i $FEATURES"
if [ $i = "iroh-cli" ]; then
targets="--bins"
else
targets="--lib --bins"
fi
echo cargo check --locked -p $i $FEATURES $targets
cargo check --locked -p $i $FEATURES $targets
done
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
- name: build tests
run: |
cargo nextest run --locked --workspace $FEATURES --lib --bins --tests --no-run
- name: list ignored tests
run: |
cargo nextest list --locked --workspace $FEATURES --lib --bins --tests --run-ignored ignored-only
- name: run tests
run: |
mkdir -p output
cargo nextest run --locked --workspace $FEATURES --lib --bins --tests --profile ci --run-ignored "$RUN_IGNORED" --no-fail-fast --message-format "$MSG_FORMAT" > "output/$OUT_NAME.json"
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
RUN_IGNORED: ${{ inputs.flaky && 'all' || 'default' }}
MSG_FORMAT: ${{ inputs.flaky && 'libtest-json' || 'human' }}
OUT_NAME: ${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 with:
name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
path: output
retention-days: 45
compression-level: 0
- name: doctests
if: ${{ (! inputs.flaky) && matrix.features == 'all' }}
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
run: |
cargo test --locked --workspace --all-features --doc