mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-12 06:20:48 +00:00
caf81fd2e2
* chore(ci): adjust runner usage and storage policies * fix android * fix android again
457 lines
15 KiB
YAML
457 lines
15 KiB
YAML
# Run all tests, with or without flaky tests.
|
|
|
|
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: "10G"
|
|
CRATES_LIST: "noq,noq-proto,noq-udp"
|
|
NEXTEST_VERSION: "0.9.80"
|
|
|
|
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:
|
|
# Using self-hosted runners so use local cache for sccache and
|
|
# not SCCACHE_GHA_ENABLED.
|
|
RUSTC_WRAPPER: "sccache"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.git-ref }}
|
|
|
|
- name: Install ${{ matrix.rust }} rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
- name: Install cargo-nextest
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: nextest@${{ env.NEXTEST_VERSION }}
|
|
|
|
- name: Install sccache
|
|
uses: mozilla-actions/sccache-action@v0.0.9
|
|
|
|
# Go is required for FIPS builds (aws-lc-rs-fips feature)
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "stable"
|
|
|
|
- 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"
|
|
targets="--lib --bins"
|
|
echo cargo check -p $i $FEATURES $targets
|
|
cargo check -p $i $FEATURES $targets
|
|
done
|
|
env:
|
|
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
|
|
|
|
- name: build tests
|
|
run: |
|
|
cargo nextest run --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --no-run
|
|
|
|
- name: list ignored tests
|
|
run: |
|
|
cargo nextest list --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --run-ignored ignored-only
|
|
|
|
- name: run tests
|
|
run: |
|
|
mkdir -p output
|
|
cargo nextest run --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --profile ci --run-ignored ${{ inputs.flaky && 'all' || 'default' }} ${{ inputs.flaky && '--verbose' || '' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
|
|
env:
|
|
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
|
|
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
|
|
|
|
- name: upload results
|
|
if: ${{ failure() && inputs.flaky }}
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
|
|
path: output
|
|
retention-days: 7
|
|
compression-level: 0
|
|
|
|
- name: doctests
|
|
if: ${{ (! inputs.flaky) && matrix.features == 'all' }}
|
|
env:
|
|
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
|
|
run: |
|
|
cargo test --workspace --all-features --doc
|
|
|
|
- name: Check doctest features
|
|
if: ${{ ! inputs.flaky }}
|
|
env:
|
|
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
|
|
run: |
|
|
for i in ${CRATES_LIST//,/ }
|
|
do
|
|
echo "Checking $i doctest $FEATURES"
|
|
echo cargo test -p $i --doc $FEATURES
|
|
cargo test -p $i --doc $FEATURES
|
|
done
|
|
|
|
- uses: taiki-e/install-action@cargo-make
|
|
|
|
- name: run proptests (1 minute minimum)
|
|
if: ${{ ! inputs.flaky }}
|
|
run: cargo make proptests-light
|
|
|
|
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:
|
|
# Using self-hosted runners so use local cache for sccache and
|
|
# not SCCACHE_GHA_ENABLED.
|
|
RUSTC_WRAPPER: "sccache"
|
|
# Force clang/bindgen to use MSVC target to avoid mingw headers from msys2
|
|
BINDGEN_EXTRA_CLANG_ARGS: "--target=x86_64-pc-windows-msvc"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.git-ref }}
|
|
|
|
- name: Install ${{ matrix.rust }}
|
|
run: |
|
|
rustup toolchain install ${{ matrix.rust }}
|
|
rustup toolchain default ${{ matrix.rust }}
|
|
rustup target add ${{ matrix.target }}
|
|
rustup set default-host ${{ matrix.target }}
|
|
|
|
- name: Cache cargo-nextest
|
|
id: cache-nextest
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/bin/cargo-nextest.exe
|
|
key: nextest-windows-${{ env.NEXTEST_VERSION }}
|
|
|
|
- name: Install cargo-nextest
|
|
if: steps.cache-nextest.outputs.cache-hit != 'true'
|
|
shell: powershell
|
|
run: |
|
|
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru
|
|
Invoke-WebRequest -OutFile $tmp https://get.nexte.st/${{ env.NEXTEST_VERSION }}/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@v0.0.9
|
|
|
|
- uses: msys2/setup-msys2@v2
|
|
with:
|
|
release: false
|
|
|
|
# FIPS dependencies for Windows
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "stable"
|
|
|
|
- name: Install NASM
|
|
uses: ilammy/setup-nasm@v1
|
|
|
|
- name: Cache Strawberry Perl
|
|
id: cache-perl
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Strawberry
|
|
key: strawberry-perl-5.38.2.2
|
|
|
|
- name: Install Strawberry Perl
|
|
if: steps.cache-perl.outputs.cache-hit != 'true'
|
|
run: |
|
|
Invoke-WebRequest -Uri "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.zip" -OutFile perl.zip
|
|
Expand-Archive perl.zip -DestinationPath C:\Strawberry -Force
|
|
|
|
- name: Add Perl to PATH
|
|
run: |
|
|
echo "C:\Strawberry\perl\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "C:\Strawberry\c\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
- name: Install cmake
|
|
uses: lukka/get-cmake@latest
|
|
|
|
# Install LLVM for libclang (required by bindgen for aws-lc-fips-sys)
|
|
- name: Cache LLVM
|
|
id: cache-llvm
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Program Files\LLVM
|
|
key: llvm-17.0.6-windows
|
|
|
|
- name: Install LLVM
|
|
if: steps.cache-llvm.outputs.cache-hit != 'true'
|
|
run: |
|
|
$llvmUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/LLVM-17.0.6-win64.exe"
|
|
Invoke-WebRequest -Uri $llvmUrl -OutFile llvm-installer.exe
|
|
Start-Process -FilePath .\llvm-installer.exe -ArgumentList "/S" -Wait
|
|
|
|
- name: Add LLVM to PATH
|
|
run: |
|
|
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
- name: Setup MSVC dev environment
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: build tests
|
|
run: |
|
|
cargo nextest run --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --no-run
|
|
|
|
- name: list ignored tests
|
|
run: |
|
|
cargo nextest list --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --run-ignored ignored-only
|
|
|
|
- name: tests
|
|
run: |
|
|
mkdir -p output
|
|
cargo nextest run --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --profile ci --target ${{ matrix.target }} --run-ignored ${{ inputs.flaky && 'all' || 'default' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json
|
|
env:
|
|
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
|
|
NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1
|
|
|
|
- name: upload results
|
|
if: ${{ failure() && inputs.flaky }}
|
|
uses: actions/upload-artifact@v5
|
|
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
|
|
|
|
- name: Cache cargo-make
|
|
id: cache-cargo-make
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cargo/bin/cargo-make.exe
|
|
key: cargo-make-windows-0.37.24
|
|
|
|
- name: Install cargo-make
|
|
if: steps.cache-cargo-make.outputs.cache-hit != 'true'
|
|
run: cargo install cargo-make --version 0.37.24 --locked
|
|
|
|
- name: run proptests (1 minute minimum)
|
|
if: ${{ ! inputs.flaky }}
|
|
run: cargo make proptests-light
|
|
|
|
minimal-crates:
|
|
timeout-minutes: 45
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
name: [ubuntu-latest, macOS-arm-latest]
|
|
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]
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: dtolnay/rust-toolchain@nightly
|
|
- name: Install Go (required for aws-lc-rs FIPS)
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "stable"
|
|
cache: false
|
|
- name: cargo check
|
|
run: |
|
|
rm -f Cargo.lock
|
|
cargo +nightly check -Z minimal-versions --workspace --exclude fuzz --all-features --lib --bins
|
|
|
|
minimal-crates-windows:
|
|
timeout-minutes: 30
|
|
name: "Minimal Crates (Windows)"
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
name: [windows-latest]
|
|
rust: ["${{ inputs.rust-version}}"]
|
|
target:
|
|
- x86_64-pc-windows-msvc
|
|
include:
|
|
- name: windows-latest
|
|
os: windows
|
|
runner: [self-hosted, windows, x64]
|
|
env:
|
|
# Using self-hosted runners so use local cache for sccache and
|
|
# not SCCACHE_GHA_ENABLED.
|
|
RUSTC_WRAPPER: "sccache"
|
|
# Force clang/bindgen to use MSVC target to avoid mingw headers from msys2
|
|
BINDGEN_EXTRA_CLANG_ARGS: "--target=x86_64-pc-windows-msvc"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.git-ref }}
|
|
|
|
- name: Install Rust nightly
|
|
run: |
|
|
rustup toolchain install nightly
|
|
rustup target add ${{ matrix.target }}
|
|
rustup set default-host ${{ matrix.target }}
|
|
|
|
- name: Install sccache
|
|
uses: mozilla-actions/sccache-action@v0.0.9
|
|
|
|
- uses: msys2/setup-msys2@v2
|
|
with:
|
|
release: false
|
|
|
|
- name: Install cmake
|
|
uses: lukka/get-cmake@latest
|
|
|
|
- name: Install NASM
|
|
uses: ilammy/setup-nasm@v1
|
|
|
|
- name: Cache Strawberry Perl
|
|
id: cache-perl
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Strawberry
|
|
key: strawberry-perl-5.38.2.2
|
|
|
|
- name: Install Strawberry Perl
|
|
if: steps.cache-perl.outputs.cache-hit != 'true'
|
|
run: |
|
|
Invoke-WebRequest -Uri "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.zip" -OutFile perl.zip
|
|
Expand-Archive perl.zip -DestinationPath C:\Strawberry -Force
|
|
|
|
- name: Add Perl to PATH
|
|
run: |
|
|
echo "C:\Strawberry\perl\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "C:\Strawberry\c\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
- name: Install Go (required for aws-lc-rs FIPS)
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "stable"
|
|
cache: false
|
|
|
|
# Install LLVM for libclang (required by bindgen for aws-lc-fips-sys)
|
|
- name: Cache LLVM
|
|
id: cache-llvm
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: C:\Program Files\LLVM
|
|
key: llvm-17.0.6-windows
|
|
|
|
- name: Install LLVM
|
|
if: steps.cache-llvm.outputs.cache-hit != 'true'
|
|
run: |
|
|
$llvmUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/LLVM-17.0.6-win64.exe"
|
|
Invoke-WebRequest -Uri $llvmUrl -OutFile llvm-installer.exe
|
|
Start-Process -FilePath .\llvm-installer.exe -ArgumentList "/S" -Wait
|
|
|
|
- name: Add LLVM to PATH
|
|
run: |
|
|
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
# Set up MSVC environment to ensure clang/bindgen uses MSVC headers instead of mingw
|
|
- name: Setup MSVC dev environment
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
- name: cargo check
|
|
run: |
|
|
rm -Force Cargo.lock
|
|
cargo +nightly check -Z minimal-versions --workspace --exclude fuzz --all-features --lib --bins
|