name: Rust
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache target directory
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Build examples
run: cargo build --examples --verbose
- name: Build examples with mimalloc
run: cargo build --examples --verbose --features mimalloc
- name: Build examples with metrics
run: cargo build --examples --verbose --features metrics
- name: Build examples with all features
run: cargo build --examples --verbose --features mimalloc,metrics
test-features:
name: Test Features
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- ""
- "mimalloc"
- "metrics"
- "mimalloc,metrics"
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Build with features
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo build --verbose
else
cargo build --verbose --features "${{ matrix.features }}"
fi
- name: Test with features
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo test --verbose
else
cargo test --verbose --features "${{ matrix.features }}"
fi
- name: Build examples with features
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo build --examples --verbose
else
cargo build --examples --verbose --features "${{ matrix.features }}"
fi