name: CI
on:
push:
branches: [master, "wip/**"]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != 'master' }}
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
test:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: Test & lint (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest - ubuntu-24.04-arm - macos-latest - macos-15-intel - windows-latest - windows-11-arm steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- name: Format
if: matrix.os == 'ubuntu-latest' run: cargo fmt --all --check
- name: Clippy (all features, warnings denied)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Clippy (no_std, warnings denied)
run: cargo clippy --all-targets --no-default-features -- -D warnings
- name: Test (all features)
run: cargo test --all-features
env:
OSCALL_REQUIRE_IO_URING: ${{ runner.os == 'Linux' && '1' || '' }}
- name: Test (no_std)
run: cargo test --no-default-features
env:
OSCALL_REQUIRE_IO_URING: ${{ runner.os == 'Linux' && '1' || '' }}
cross:
if: ${{ !startsWith(github.ref_name, 'wip/') && !startsWith(github.head_ref, 'release-plz-') }}
name: Test (${{ matrix.name || matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl }
- { os: ubuntu-latest, target: i686-unknown-linux-musl }
- { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl }
- { os: ubuntu-latest, target: armv7-unknown-linux-musleabihf, qemu: arm }
- os: ubuntu-24.04-arm
target: armv7-unknown-linux-musleabihf
name: armv7-unknown-linux-musleabihf, on an aarch64 kernel
- { os: ubuntu-latest, target: riscv64gc-unknown-linux-musl, qemu: riscv64 }
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Set up qemu-user
if: matrix.qemu
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.qemu }}
- name: Link static musl binaries with rust-lld
if: runner.os == 'Linux'
run: |
target_env=$(tr 'a-z-' 'A-Z_' <<<"${{ matrix.target }}")
echo "CARGO_TARGET_${target_env}_LINKER=rust-lld" >> "$GITHUB_ENV"
# Not every musl target is static and self-contained by default.
echo "CARGO_TARGET_${target_env}_RUSTFLAGS=-C target-feature=+crt-static -C link-self-contained=yes" >> "$GITHUB_ENV"
- name: Test (all features)
run: cargo test --lib --tests --all-features --target ${{ matrix.target }}
env:
OSCALL_REQUIRE_IO_URING: ${{ !matrix.qemu && '1' || '' }}
- name: Test (no_std)
run: cargo test --lib --tests --no-default-features --target ${{ matrix.target }}
env:
OSCALL_REQUIRE_IO_URING: ${{ !matrix.qemu && '1' || '' }}
fullrust:
if: ${{ !startsWith(github.ref_name, 'wip/') && !startsWith(github.head_ref, 'release-plz-') }}
name: fullrust (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-fullrust
- aarch64-unknown-linux-fullrust
- i686-unknown-linux-fullrust
- armv7-unknown-linux-fullrusteabihf
steps:
- uses: actions/checkout@v7
- name: Test (all features)
uses: KarpelesLab/fullrust@master
with:
command: test
target: ${{ matrix.target }}
no-ecosystem: true
args: --lib --tests --all-features
- name: Test (no_std)
uses: KarpelesLab/fullrust@master
with:
command: test
target: ${{ matrix.target }}
no-ecosystem: true
args: --lib --tests --no-default-features
privileged:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: Privileged container (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
targets: x86_64-unknown-linux-musl, i686-unknown-linux-musl
- os: ubuntu-24.04-arm
targets: aarch64-unknown-linux-musl, armv7-unknown-linux-musleabihf
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.targets }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
key: privileged-${{ matrix.os }}
- name: Test in a privileged container
run: scripts/privileged.sh
vm:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: Virtual machine (${{ matrix.arch }})
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
- { arch: riscv64, toolchain: stable, target: riscv64gc-unknown-linux-musl }
- { arch: arm, toolchain: stable, target: armv7-unknown-linux-musleabihf }
- { arch: riscv32, toolchain: nightly, components: rust-src }
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
components: ${{ matrix.components }}
- name: Cache the kernel
uses: actions/cache@v6
with:
path: |
target/vm/kernel-${{ matrix.arch }}
target/vm/kernel-${{ matrix.arch }}.stamp
key: vm-kernel-${{ matrix.arch }}-${{ hashFiles('scripts/vm.sh') }}
- name: Test in a virtual machine
env:
OSCALL_NIGHTLY: ${{ matrix.toolchain == 'nightly' && 'nightly' || '' }}
run: scripts/vm.sh ${{ matrix.arch }}
windows-x86:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: Test (i686-pc-windows-msvc)
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: i686-pc-windows-msvc
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Test (all features)
run: cargo test --all-features --target i686-pc-windows-msvc
- name: Test (no_std)
run: cargo test --no-default-features --target i686-pc-windows-msvc
wasm:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: WebAssembly
runs-on: ubuntu-latest
env:
CARGO_TARGET_WASM32_WASIP1_RUNNER: wasmtime run --dir=. --env OSCALL_TEST_ENV=wasi
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: wasm32-wasip1, wasm32-wasip2, wasm32-unknown-unknown
- name: Install wasmtime
uses: bytecodealliance/actions/wasmtime/setup@v1
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Test on WASI (all features)
run: cargo test --all-features --target wasm32-wasip1
- name: Test on WASI (no_std)
run: cargo test --no-default-features --target wasm32-wasip1
- name: Clippy (wasm32-wasip2)
run: cargo clippy --all-targets --all-features --target wasm32-wasip2 -- -D warnings
- name: Clippy (wasm32-unknown-unknown, all features)
run: cargo clippy --lib --all-features --target wasm32-unknown-unknown -- -D warnings
- name: Clippy (wasm32-unknown-unknown, no_std)
run: cargo clippy --lib --no-default-features --target wasm32-unknown-unknown -- -D warnings
check:
if: ${{ !startsWith(github.ref_name, 'wip/') && !startsWith(github.head_ref, 'release-plz-') }}
name: Check (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- riscv64gc-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabihf
- i686-unknown-linux-gnu
- x86_64-pc-windows-gnu
- aarch64-pc-windows-gnullvm
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: ${{ matrix.target }}
- name: Clippy (all features, warnings denied)
run: cargo clippy --all-targets --all-features --target ${{ matrix.target }} -- -D warnings
riscv32:
if: ${{ !startsWith(github.head_ref, 'release-plz-') }}
name: riscv32 Linux (nightly, qemu)
runs-on: ubuntu-latest
continue-on-error: true
env:
FREESTANDING_FLAGS: -C linker=rust-lld -C linker-flavor=ld.lld -C relocation-model=static
steps:
- uses: actions/checkout@v7
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rust-src
- name: Install qemu-riscv32
run: |
docker run --rm -v "$RUNNER_TEMP":/out debian:trixie-slim sh -ec '
apt-get update -qq
apt-get install -y -qq --no-install-recommends qemu-user-static
cp /usr/bin/qemu-riscv32-static /out/qemu-riscv32'
sudo install "$RUNNER_TEMP/qemu-riscv32" /usr/local/bin/qemu-riscv32
qemu-riscv32 --version
- name: Clippy (all features, warnings denied)
run: cargo clippy -Zbuild-std --all-targets --all-features --target riscv32gc-unknown-linux-gnu -- -D warnings
- name: Clippy (no_std, warnings denied)
run: cargo clippy -Zbuild-std --all-targets --no-default-features --target riscv32gc-unknown-linux-gnu -- -D warnings
- name: Freestanding program (x86_64)
working-directory: tests/freestanding
env:
RUSTFLAGS: ${{ env.FREESTANDING_FLAGS }}
run: cargo run --target x86_64-unknown-linux-gnu -- "$RUNNER_TEMP"
- name: Freestanding program (riscv32)
working-directory: tests/freestanding
env:
RUSTFLAGS: ${{ env.FREESTANDING_FLAGS }}
CARGO_TARGET_RISCV32GC_UNKNOWN_LINUX_GNU_RUNNER: qemu-riscv32
run: cargo run -Zbuild-std=core --target riscv32gc-unknown-linux-gnu -- "$RUNNER_TEMP"
- name: Test (both feature sets)
env:
OSCALL_NIGHTLY: nightly
run: scripts/riscv32.sh
msrv:
if: ${{ !startsWith(github.ref_name, 'wip/') && !startsWith(github.head_ref, 'release-plz-') }}
name: MSRV (1.95)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust 1.95
uses: dtolnay/rust-toolchain@1.95
- name: Check
run: cargo check --all-targets --all-features