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: Install fd (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y fd-find
sudo ln -sf $(which fdfind) /usr/local/bin/fd
- name: Install fd (macOS)
if: runner.os == 'macOS'
run: |
brew install fd
- name: Install fd (Windows)
if: runner.os == 'Windows'
run: |
choco install fd -y
- name: Verify fd
run: fd --version
- 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