name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: All features
run: cargo test --all-features
- name: Deferred without std (no_std + alloc)
run: cargo test --no-default-features --features alloc --tests
- name: StaticDeferred only (no heap)
run: cargo test --no-default-features --features static-deferred --tests
- name: std only, without a runtime
run: cargo test --no-default-features --features std --tests
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --check
- name: Clippy (all features)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Clippy (no_std + alloc)
run: cargo clippy --all-targets --no-default-features --features alloc -- -D warnings
- name: Clippy (no heap)
run: cargo clippy --all-targets --no-default-features --features static-deferred -- -D warnings
- name: Docs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings
docs-rs:
name: docs.rs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- name: Docs as on docs.rs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: --cfg docsrs -D warnings
no-std:
name: no_std (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: riscv32imac-unknown-none-elf cas: true
- target: thumbv7em-none-eabihf cas: true
- target: riscv32imc-unknown-none-elf cas: false
- target: thumbv6m-none-eabi cas: false
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Deferred (alloc)
if: matrix.cas
run: cargo build --no-default-features --features alloc --target ${{ matrix.target }}
- name: Deferred reports a clear error
if: ${{ !matrix.cas }}
run: |
if cargo check --no-default-features --features alloc --target ${{ matrix.target }} 2> build.log; then
echo "expected the build to fail without atomic compare-and-swap"
exit 1
fi
grep -q "needs atomic compare-and-swap" build.log
- name: StaticDeferred (no heap)
run: cargo build --no-default-features --features static-deferred --target ${{ matrix.target }}
msrv:
name: MSRV (1.68)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.68
- name: Lock dependencies for Rust 1.68
run: |
cargo +stable generate-lockfile
# Cargo 1.68 only reads lockfile version 3.
sed -i 's/^version = 4$/version = 3/' Cargo.lock
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
- name: All features
run: cargo +1.68 check --lib --all-features
- name: Deferred without std (no_std + alloc)
run: cargo +1.68 check --lib --no-default-features --features alloc
- name: StaticDeferred only (no heap)
run: cargo +1.68 check --lib --no-default-features --features static-deferred