name: Rust CI
permissions:
contents: read
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- "**.rs"
- '**Cargo.toml'
- '**Cargo.lock'
- "rust-toolchain.toml"
- "rustfmt.toml"
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
RUST_LOG: info
RUST_BACKTRACE: 1
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: Install Rust
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 with:
components: rustfmt
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run format
run: |
cargo fmt --all --check
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: Install Rust
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 with:
components: clippy
cache-base: main
bins: cargo-hack
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run lint
run: |
cargo hack --each-feature --no-dev-deps clippy -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - name: Install Rust
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 with:
cache-base: main
bins: cargo-hack
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run test
run: |
cargo hack --each-feature test