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: "rcan@0.4.0"
IROH_FORCE_STAGING_RELAYS: "1"
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@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-nextest
uses: taiki-e/install-action@decb84fb327e5b809630c914eb4d1ca67cf59966 with:
tool: nextest@0.9.80
- name: Install sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba
- name: Select 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
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 }}
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"
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a 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' }}
run: |
if [ -n "${{ runner.debug }}" ]; then
export RUST_LOG=TRACE
else
export RUST_LOG=DEBUG
fi
cargo test --locked --workspace --all-features --doc
build_and_test_windows:
timeout-minutes: 30
name: "Tests"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
name: [windows-latest]
rust: ["${{ inputs.rust-version}}"]
features: [all, none, default]
target:
- x86_64-pc-windows-msvc
include:
- name: windows-latest
os: windows
runner: [self-hosted, windows, x64]
env:
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }}
env:
RUST_TOOLCHAIN: ${{ matrix.rust }}
RUST_TARGET: ${{ matrix.target }}
run: |
rustup toolchain install $env:RUST_TOOLCHAIN
rustup toolchain default $env:RUST_TOOLCHAIN
rustup target add $env:RUST_TARGET
rustup set default-host $env:RUST_TARGET
- name: Install cargo-nextest
shell: powershell
run: |
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows
$outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" }
$tmp | Expand-Archive -DestinationPath $outputDir -Force
$tmp | Remove-Item
- name: Select features
run: |
switch ("${{ matrix.features }}") {
"all" {
echo "FEATURES=--all-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
"none" {
echo "FEATURES=--no-default-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
"default" {
echo "FEATURES=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
default {
Exit 1
}
}
- name: Install sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884
- name: build tests
env:
RUST_TARGET: ${{ matrix.target }}
run: |
$feat = if ($env:FEATURES) { $env:FEATURES -split '\s+' } else { @() }
cargo nextest run --locked --workspace @feat --lib --bins --tests --target $env:RUST_TARGET --no-run
- name: list ignored tests
env:
RUST_TARGET: ${{ matrix.target }}
run: |
$feat = if ($env:FEATURES) { $env:FEATURES -split '\s+' } else { @() }
cargo nextest list --locked --workspace @feat --lib --bins --tests --target $env:RUST_TARGET --run-ignored ignored-only
- name: tests
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
RUST_TARGET: ${{ matrix.target }}
RUN_IGNORED: ${{ inputs.flaky && 'all' || 'default' }}
MSG_FORMAT: ${{ inputs.flaky && 'libtest-json' || 'human' }}
OUT_NAME: ${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}
run: |
mkdir -p output
$feat = if ($env:FEATURES) { $env:FEATURES -split '\s+' } else { @() }
cargo nextest run --locked --workspace @feat --lib --bins --tests --profile ci --target $env:RUST_TARGET --run-ignored $env:RUN_IGNORED --no-fail-fast --message-format $env:MSG_FORMAT > "output/$($env:OUT_NAME).json"
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
path: output
retention-days: 1
compression-level: 0