name: CI
on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
ci:
name: CI
if: |
!github.event.pull_request.draft ||
(github.event.action == 'ready_for_review' &&
github.event.pull_request.user.login == 'github-actions[bot]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run unit tests
run: cargo test --verbose
- name: Build release
run: cargo build --release --verbose
- name: Run golden tests
run: |
cd tests
./run_golden_tests.sh
test-cross-platform:
name: Test on ${{ matrix.os }}
if: |
!github.event.pull_request.draft ||
(github.event.action == 'ready_for_review' &&
github.event.pull_request.user.login == 'github-actions[bot]')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Build release
run: cargo build --release --verbose
- name: Run golden tests (Unix)
if: runner.os != 'Windows'
run: |
cd tests
./run_golden_tests.sh
- name: Run golden tests (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
cd tests
./run_golden_tests.sh