name: Rust
on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build-macos:
name: Build - macOS aarch64
runs-on: macos-latest
strategy:
matrix:
toolchain:
- stable
- 1.89.0 steps:
- uses: actions/checkout@v6
- name: Install rust version
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.toolchain}}
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
- name: Build (default)
run: cargo build
- name: Test (default)
run: cargo test
- name: Build (no_std)
run: cargo build --features no_std
- name: Test (no_std)
run: cargo test --features no_std
build-linux:
name: Build - Linux x86_64 (${{matrix.target-cpu}})
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
- 1.89.0 target-cpu:
- baseline
- x86-64-v2
- x86-64-v3
steps:
- uses: actions/checkout@v6
- name: Install rust version
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.toolchain}}
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
with:
key: ${{matrix.target-cpu}}
- name: Build (default)
run: cargo build
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
- name: Test (default)
run: cargo test
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
- name: Build (no_std)
run: cargo build --features no_std
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
- name: Test (no_std)
run: cargo test --features no_std
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
build-wasm:
runs-on: ${{matrix.os}}
strategy:
matrix:
os:
- ubuntu-latest
toolchain:
- stable
- 1.89.0 include:
- os: ubuntu-latest
target: wasm32-unknown-unknown
steps:
- uses: actions/checkout@v6
- name: Install rust version
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{matrix.toolchain}}
target: ${{matrix.target}}
- uses: actions/checkout@v6
- name: Build Default
run: cargo build --target wasm32-unknown-unknown --release
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
- name: Check code formatted
run: cargo fmt --all -- --check
clippy-macos:
name: Clippy - macOS aarch64
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2
- name: Check no lint warnings
run: cargo clippy --workspace -- -D warnings
- name: Check no lint warnings (all features)
run: cargo clippy --workspace --all-features -- -D warnings
- name: Check no lint warnings (no default features)
run: cargo clippy --workspace --no-default-features -- -D warnings
clippy-linux:
name: Clippy - Linux x86_64 (${{matrix.target-cpu}})
runs-on: ubuntu-latest
strategy:
matrix:
target-cpu:
- baseline
- x86-64-v2
- x86-64-v3
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy
- name: Cache build artifacts
uses: Swatinem/rust-cache@v2.8.1
with:
key: ${{matrix.target-cpu}}
- name: Check no lint warnings
run: cargo clippy --workspace -- -D warnings
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
- name: Check no lint warnings (all features)
run: cargo clippy --workspace --all-features -- -D warnings
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}
- name: Check no lint warnings (no default features)
run: cargo clippy --workspace --no-default-features -- -D warnings
env:
RUSTFLAGS: ${{matrix.target-cpu != 'baseline' && format('-C target-cpu={0}', matrix.target-cpu) || ''}}