name: Build and Test Crate
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build on ${{ matrix.os }} (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-13 target: x86_64-apple-darwin
- os: macos-latest target: aarch64-apple-darwin
steps:
- name: ๐ฅ Checkout repository
uses: actions/checkout@v4
- name: ๐ ๏ธ Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
- name: ๐๏ธ Build library and tests in release mode
run: cargo test --release --no-run --verbose --target ${{ matrix.target }}
- name: โฌ๏ธ Upload target directory
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.target }}
path: target
test:
name: Test on ${{ matrix.os }} (${{ matrix.target }})
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-13
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
steps:
- name: ๐ฅ Checkout repository
uses: actions/checkout@v4
- name: ๐ ๏ธ Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
- name: ๐ฅ Download target directory
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.target }}
path: target
- name: ๐งช Run tests (without rebuilding)
run: cargo test --release --verbose --target ${{ matrix.target }}
benchmark:
name: Benchmark on ${{ matrix.os }} (${{ matrix.target }})
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-13
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
steps:
- name: ๐ฅ Checkout repository
uses: actions/checkout@v4
- name: ๐ ๏ธ Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
- name: ๐ Run benchmarks
run: cargo bench --verbose --target ${{ matrix.target }} --bench=workflow_dep