name: Rust CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
if: github.repository_owner == github.actor || github.event.sender.type == 'User'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build
run: cargo build --release --locked
- name: Test
shell: bash
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
cargo test --all --release --locked --verbose
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
cargo test --all --locked --verbose
else
echo "Skipping test on ${{ matrix.os }} for non-main branch."
fi