Skip to content

chore: use more context, with_context and bail macros #7085

chore: use more context, with_context and bail macros

chore: use more context, with_context and bail macros #7085

Workflow file for this run

name: CI
on:
push:
branches: ['main']
pull_request:
branches: ['**']
workflow_dispatch:
permissions:
packages: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: '-D warnings'
jobs:
test-nightly:
name: Test Linux (${{ matrix.container }})
strategy:
matrix:
include:
- runs-on: ubuntu-24.04
container: ci-ubuntu-cross-amd64
cross: all
- runs-on: ubuntu-24.04
container: ci-arch-cross-amd64
cross: aarch64,riscv64
- runs-on: ubuntu-24.04-arm
container: ci-ubuntu-arm64
- runs-on: ubuntu-24.04
container: ci-alpine-amd64
- runs-on: ubuntu-24.04
container: ci-opensuse-amd64
- runs-on: ubuntu-24.04-arm
container: ci-opensuse-arm64
fail-fast: false
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 10
container:
# Note: when updating this image hash, update the other occurrences in this file too.
image: ghcr.io/wild-linker/wild/${{ matrix.container }}:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b
steps:
# https://github.com/actions/runner/issues/3210
- run: echo "$PATH" >> "$GITHUB_PATH"
if: ${{ contains(matrix.container, 'opensuse') }}
- run: echo "WILD_TEST_CONFIG=test-config-ci.toml" >> $GITHUB_ENV
- run: echo "WILD_TEST_CROSS=${{ matrix.cross }}" >> $GITHUB_ENV
if: ${{ contains(matrix.container, '-cross') }}
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: wild-linker/action@latest
- uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-${{ matrix.container }}-${{ matrix.runs-on }}
- run: cargo build --profile ci --workspace --no-default-features
- run: WILD_TEST_CROSS=$WILD_TEST_CROSS cargo test --profile ci --workspace
external-tests:
name: Test Linux (external tests)
runs-on: ubuntu-24.04
timeout-minutes: 10
container:
image: "ghcr.io/wild-linker/wild/ci-ubuntu-cross-amd64:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b"
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
submodules: recursive
- uses: Swatinem/rust-cache@v2
- run: echo "WILD_TEST_CONFIG=test-config-ci.toml" >> $GITHUB_ENV
- name: Check regressions
run: WILD_TEST_CROSS=all cargo test --features external_tests external_test_suites -- --skip expect_failure
- name: Check tests that should fail still fail
run: WILD_TEST_CROSS=all cargo test --features external_tests expect_failure
linux-cross-build:
name: Build Linux (${{ matrix.arch }})
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- arch: RISC-V
target: riscv64gc-unknown-linux-gnu
config: .cargo/config.toml.cross-riscv
- arch: LoongArch64
target: loongarch64-unknown-linux-gnu
config: .cargo/config.toml.cross-loongarch64
- arch: PPC64LE
target: powerpc64le-unknown-linux-gnu
config: .cargo/config.toml.cross-ppc64le
container:
image: ghcr.io/wild-linker/wild/ci-ubuntu-cross-amd64:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cp -f ${{ matrix.config }} .cargo/config.toml
- run: cargo build --target ${{ matrix.target }}
wasip1-build:
name: Build wasip1
runs-on: ubuntu-24.04
timeout-minutes: 10
container:
image: ghcr.io/wild-linker/wild/ci-ubuntu-wasm-amd64:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b
steps:
- name: Setup Wasmtime
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: '48.0.0'
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
targets: wasm32-wasip1
- uses: Swatinem/rust-cache@v2
- run: cargo build --target wasm32-wasip1
- run: cp -f .cargo/config.toml.cross-wasm32p1 .cargo/config.toml
# -p libwild prevents integration tests from running. they depend on
# spawning processes, which isn't supported on wasi.
- run: cargo test --profile ci -p libwild --target wasm32-wasip1
wasm-test:
name: Test Wasm
runs-on: ubuntu-24.04
timeout-minutes: 10
container:
image: ghcr.io/wild-linker/wild/ci-ubuntu-wasm-amd64:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
targets: wasm32-wasip1
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2.87.13
with:
tool: wasm-tools
- name: Setup Wasmtime
uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: '48.0.0'
- run: cargo test --features wasm -- wasm
macho-build:
name: Test Mach-O (AArch64)
runs-on: macos-latest
timeout-minutes: 10
env:
WILD_TEST_IGNORE_FORMAT: "1" # Checked by other jobs
steps:
- run: brew install lld llvm
- run: echo "PATH=/opt/homebrew/opt/llvm/bin:$PATH" >> $GITHUB_ENV
- run: clang --version
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- uses: Swatinem/rust-cache@v2
with:
env-vars: ImageVersion
- run: echo "WILD_TEST_CONFIG=test-config-ci.toml" >> $GITHUB_ENV
- run: cargo build --profile ci --workspace --no-default-features
- run: cargo test --profile ci --workspace --features macho
windows-build:
name: Build Windows (x86_64)
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- uses: Swatinem/rust-cache@v2
- run: cargo build --profile ci --workspace --no-default-features
minimal-versions:
runs-on: ubuntu-24.04
timeout-minutes: 10
container:
image: ghcr.io/wild-linker/wild/ci-ubuntu-amd64:sha-fc8fa6975269300dacfc3c8fff06b3ba2f96721b
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
- uses: taiki-e/install-action@v2.87.13
with:
tool: cargo-hack,cargo-minimal-versions,taplo
- uses: Swatinem/rust-cache@v2
- run: cargo minimal-versions --direct test --profile ci
clippy:
name: Clippy
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
# This is where we check that we're not using features from a more recent rust version. When
# updating this, please also update workspace.package.rust-version in `Cargo.toml`.
- uses: dtolnay/rust-toolchain@1.97.1
id: rust-toolchain
with:
components: clippy
- uses: wild-linker/action@latest
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --workspace --target x86_64-unknown-linux-gnu
- run: cargo clippy --all-targets --workspace --target x86_64-unknown-linux-gnu --no-default-features
cargo-deny:
name: Cargo deny
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
dependency_cooldown:
name: Dependency cooldown
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
- run: cp -f .cargo/config.toml.publish-age .cargo/config.toml
- name: Check for eligible dependency updates
run: cargo +nightly update
rustfmt:
name: Check formatting
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all -- --check
yamlfmt:
name: yamlfmt
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v7
with:
go-version: '1.26.0'
cache: false
- run: go install github.com/google/yamlfmt/cmd/yamlfmt@v0.21.0
- run: echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- run: yamlfmt -lint .
spelling:
name: Spell Check with Typos
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Spell Check Repo
uses: crate-ci/typos@v1.50.2
calc-matrix:
name: Find Nix checks
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
matrix: ${{ steps.calc-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 0
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v35
with:
nix_on_tmpfs: true
- name: Calculate check
id: calc-matrix
run: |
set -euo pipefail
matrix=$(nix flake show --json | jq -c '.checks."x86_64-linux"|keys_unsorted')
echo "Matrix: $matrix"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix-checks:
needs:
- calc-matrix
strategy:
fail-fast: false
matrix:
check: ${{ fromJson(needs.calc-matrix.outputs.matrix) }}
runs-on: ubuntu-24.04
timeout-minutes: 10
name: Nix/${{ matrix.check }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 0
- name: Install Nix
uses: nixbuild/nix-quick-install-action@v35
- name: Restore Nix store
uses: nix-community/cache-nix-action/restore@v7
id: cache
with:
primary-key: ${{ runner.os }}-${{ hashFiles( 'flake.lock', 'Cargo.lock') }}
- name: Run ${{ matrix.check }}
run: nix build .#checks.x86_64-linux.${MATRIX_CHECK} -L --show-trace
env:
MATRIX_CHECK: ${{ matrix.check }}
reuse-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 0
submodules: recursive
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v6