name: Rust CI
on:
push:
branches:
- "main"
- "feature/**"
pull_request:
branches:
- "main"
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
toolchain:
- stable
- beta
- nightly
exclude:
- toolchain: beta
- toolchain: nightly
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Rust toolchain
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Lint with clippy
if: matrix.os == 'ubuntu-latest' && matrix.toolchain == 'stable'
run: |
rustup component add clippy
cargo clippy -- -D warnings
- name: Check formatting with rustfmt
if: matrix.os == 'ubuntu-latest' && matrix.toolchain == 'stable'
run: |
rustup component add rustfmt
cargo fmt -- --check