Files
iroh/.github/workflows/tests.yaml
T
Workflow config file is invalid. Please check your config file: interpolate runs-on for job "build_and_test_nix": Invalid JSON: invalid character '$' looking for beginning of value
Grookieandn0-grookie f2d8d4694b chore(ci): select the toolchain the Windows test jobs request (#4514)
## Description

`build_and_test_windows` installs the requested toolchain but never
selects it. `rustup toolchain default` is not a rustup subcommand, and
pwsh steps don't check a command's exit status, so the line silently
does nothing and every cargo call uses the runner image's rustup
default. See #4513.

Fixes #4513

## API Changes

None, CI only.

## Notes & open questions

- `RUSTUP_TOOLCHAIN` on the job instead of `rustup default`: same effect
without rewriting the default of a shared self-hosted runner for other
jobs. Worth knowing that `dtolnay/rust-toolchain` does call `rustup
default`, with `continue-on-error: true`
([#127](https://github.com/dtolnay/rust-toolchain/issues/127)), so it
can fail to select and still pass. The nix jobs already use that action
and are untouched here.
- The step runs in bash so rustup failures fail the job, and asserts the
active toolchain matches `matrix.rust`.
- I could not run this: no Windows box locally, and first contribution
from this fork means the runs need a maintainer to approve them. Checked
against a real rustup (the guard's output forms), and `zizmor
--pedantic` reports the same findings as upstream, none new.

I'm an agent posting from my own account (`n0-grookie`), so the human
box is unticked. Philipp reviewed the diagnosis and asked for the PR.

## Change checklist

- [x] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [x] All API changes documented.
- [ ] This PR was created by a human that thought critically about the
      proposed change and wrote an as clear and concise description as
      they could.
- [x] This PR isn't slop, and is carefully crafted to do have the
      intented effect.

Co-authored-by: n0-grookie <322172879+n0-grookie@users.noreply.github.com>
2026-09-09 14:24:12 +00:00

374 lines
18 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: "iroh,iroh-bench,iroh-dns-server,iroh-relay"
IROH_FORCE_STAGING_RELAYS: "1"
NEXTEST_VERSION: "0.9.80"
# Default to read-only; jobs that need more grant it explicitly.
permissions:
contents: read
jobs:
pick-runner:
uses: "./.github/workflows/pick-runner.yml"
with:
min_free_runners: 3
secrets:
RUNNER_READ_TOKEN: ${{ secrets.RUNNER_READ_TOKEN }}
# Windows overflow routing onto Blacksmith, with its own idle count and an
# independent Blacksmith cap of 4 (see blacksmith_busy_match: windows).
pick-runner-windows:
uses: "./.github/workflows/pick-runner.yml"
with:
core_runner: '["self-hosted","windows","x64"]'
overflow_runner: '["blacksmith-4vcpu-windows-2025"]'
blacksmith_busy_match: windows
max_blacksmith_concurrent: 4
min_free_runners: 1
secrets:
RUNNER_READ_TOKEN: ${{ secrets.RUNNER_READ_TOKEN }}
build_and_test_nix:
timeout-minutes: 30
name: "Tests"
needs: pick-runner
runs-on: ${{ fromJSON(matrix.runs_on) }}
strategy:
fail-fast: false
matrix:
name: [ubuntu-latest, macOS-arm-latest]
rust: ["${{ inputs.rust-version }}"]
features: [all, none, default]
include:
# ubuntu cells route via pick-runner slots 1-3
- name: ubuntu-latest
features: all
os: ubuntu-latest
release-os: linux
release-arch: amd64
runs_on: ${{ needs.pick-runner.outputs.overflow_1 }}
- name: ubuntu-latest
features: none
os: ubuntu-latest
release-os: linux
release-arch: amd64
runs_on: ${{ needs.pick-runner.outputs.overflow_2 }}
- name: ubuntu-latest
features: default
os: ubuntu-latest
release-os: linux
release-arch: amd64
runs_on: ${{ needs.pick-runner.outputs.overflow_3 }}
# mac cells always stay on self-hosted mac (not in the routing pool)
- name: macOS-arm-latest
features: all
os: macOS-latest
release-os: darwin
release-arch: aarch64
runs_on: '["self-hosted","macOS","ARM64"]'
- name: macOS-arm-latest
features: none
os: macOS-latest
release-os: darwin
release-arch: aarch64
runs_on: '["self-hosted","macOS","ARM64"]'
- name: macOS-arm-latest
features: default
os: macOS-latest
release-os: darwin
release-arch: aarch64
runs_on: '["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: Configure sccache backend
shell: bash
run: |
if [[ "${RUNNER_NAME:-}" == blacksmith-* ]]; then
echo "Runner: $RUNNER_NAME → GHA-backed sccache"
echo "SCCACHE_GHA_ENABLED=on" >> "$GITHUB_ENV"
else
echo "Runner: $RUNNER_NAME → local-disk sccache"
# leave SCCACHE_GHA_ENABLED unset; sccache defaults to local disk
fi
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }} rust
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # v1
with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-nextest
uses: taiki-e/install-action@82cd3e7658a6f96c86c0234aeeda1748937cb0a1 # v2.85.13
with:
tool: nextest@${{ env.NEXTEST_VERSION }}
- name: Install sccache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
continue-on-error: true
- uses: ./.github/workflows/sccache-probe
- 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 --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" $VERBOSE --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' }}
VERBOSE: ${{ inputs.flaky && '--verbose' || '' }}
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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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
# We can not check the doctest features by only compiling them,
# so are forced to run them once more.
- 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 --locked -p $i --doc $FEATURES
cargo test --locked -p $i --doc $FEATURES
done
build_and_test_windows:
timeout-minutes: 30
name: "Tests"
needs: pick-runner-windows
runs-on: ${{ fromJSON(matrix.runs_on) }}
strategy:
fail-fast: false
matrix:
name: [windows-latest]
rust: ["${{ inputs.rust-version}}"]
features: [all, none, default]
target:
- x86_64-pc-windows-msvc
include:
# windows cells route via pick-runner-windows slots 1-3
- name: windows-latest
features: all
os: windows
runs_on: ${{ needs.pick-runner-windows.outputs.overflow_1 }}
- name: windows-latest
features: none
os: windows
runs_on: ${{ needs.pick-runner-windows.outputs.overflow_2 }}
- name: windows-latest
features: default
os: windows
runs_on: ${{ needs.pick-runner-windows.outputs.overflow_3 }}
env:
# sccache backend is selected at runtime in "Configure sccache backend":
# local disk on self-hosted, GHA-backed on Blacksmith (ephemeral).
RUSTC_WRAPPER: "sccache"
# Installing a toolchain does not select it, so without this every cargo
# invocation below uses whatever the runner image ships as rustup default.
# As an env var this applies to the job only; `rustup default` would
# rewrite the default of the shared self-hosted runner for other jobs.
RUSTUP_TOOLCHAIN: "${{ matrix.rust }}"
steps:
- name: Configure sccache backend
shell: bash
run: |
if [[ "${RUNNER_NAME:-}" == blacksmith-* ]]; then
echo "Runner: $RUNNER_NAME → GHA-backed sccache"
echo "SCCACHE_GHA_ENABLED=on" >> "$GITHUB_ENV"
else
echo "Runner: $RUNNER_NAME → local-disk sccache"
# leave SCCACHE_GHA_ENABLED unset; sccache defaults to local disk
fi
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ inputs.git-ref }}
- name: Install ${{ matrix.rust }}
env:
RUST_TOOLCHAIN: ${{ matrix.rust }}
RUST_TARGET: ${{ matrix.target }}
# bash: pwsh steps ignore a command's exit status, so a failed rustup
# call here goes unnoticed.
shell: bash
run: |
rustup toolchain install "$RUST_TOOLCHAIN" --target "$RUST_TARGET"
rustup set default-host "$RUST_TARGET"
# Fail here rather than building with the wrong compiler if the
# requested toolchain is not the active one.
rustup show active-toolchain | grep -q "^${RUST_TOOLCHAIN}-"
rustc --version
# Was a bare Invoke-WebRequest from get.nexte.st with no checksum,
# unpacked into ~/.cargo/bin on a long-lived host.
- name: Install cargo-nextest
uses: taiki-e/install-action@82cd3e7658a6f96c86c0234aeeda1748937cb0a1 # v2.85.13
with:
tool: nextest@${{ env.NEXTEST_VERSION }}
- 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 # v0.0.11
continue-on-error: true
with:
# Pinned: sccache >= 0.17.0 expands rustc @argfiles and breaks Windows'
# 32K command line limit: https://github.com/mozilla/sccache/issues/2397
version: "v0.16.0"
- uses: ./.github/workflows/sccache-probe
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0
with:
# Blacksmith's Windows image ships no pre-installed MSYS2 (C:\msys64),
# so install it there. Self-hosted keeps the pre-installed one (faster).
release: ${{ startsWith(runner.name, 'blacksmith-') }}
- name: Install aws-lc-sys build dependencies
shell: powershell
run: |
$chocoPath = "$Env:ProgramData\chocolatey\bin\choco.exe"
if (!(Test-Path $chocoPath)) {
$chocoPath = "$Env:SystemDrive\ProgramData\chocolatey\bin\choco.exe"
}
& $chocoPath install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
& $chocoPath install nasm -y
echo "C:\Program Files\CMake\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\NASM" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
- 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
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"
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 }}
- name: upload results
if: ${{ failure() && inputs.flaky }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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