name: Rust Cross-Platform Check
on:
push:
branches: [ main, dev ]
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy, rustfmt
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Format check
run: cargo fmt --all -- --check
- name: Clippy check
run: cargo clippy --all-targets -- -D warnings
- name: Run tests
run: cargo test --all --release
env:
RUST_BACKTRACE: 1
- name: Build project
run: cargo build --release --target ${{ matrix.target }}