name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
quick-check:
name: Quick - ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Format
cmd: fmt
toolchain: nightly
- name: Clippy
cmd: clippy
toolchain: stable
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Run ${{ matrix.name }}
run: |
case "${{ matrix.cmd }}" in
fmt)
cargo +${{ matrix.toolchain }} fmt --all -- --check
;;
clippy)
cargo +${{ matrix.toolchain }} clippy --workspace --all-targets -- -D warnings
;;
esac
build-test:
name: Build & Test - ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.runs-on }}
needs: quick-check
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
runs-on: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: Windows
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- name: macOS
runs-on: macos-latest
target: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- name: Install mold (Linux)
if: runner.os == 'Linux'
uses: rui314/setup-mold@v1
- name: Build (Release)
run: cargo build --release --target ${{ matrix.platform.target }} --verbose
- name: Run Tests
shell: bash
run: |
# Only run tests if we are on a compatible host
if [[ "${{ matrix.platform.runs-on }}" == "ubuntu-latest" && "${{ matrix.platform.target }}" == *"linux"* ]] || \
[[ "${{ matrix.platform.runs-on }}" == "windows-latest" && "${{ matrix.platform.target }}" == *"windows"* ]] || \
[[ "${{ matrix.platform.runs-on }}" == "macos-latest" && "${{ matrix.platform.target }}" == *"apple-darwin"* ]]; then
cargo test --target ${{ matrix.platform.target }} --verbose
else
echo "Skipping tests for ${{ matrix.platform.target }} on ${{ matrix.platform.runs-on }}"
fi