name: Rust
on:
push:
paths:
- "**.rs"
- "**/Cargo.toml"
- "rust-toolchain.toml"
- ".github/workflows/rust.yml"
pull_request:
workflow_call:
env:
CARGO_TERM_COLOR: always
jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5.3.2
with:
concurrent_skipping: 'same_content_newer'
test:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Update rust
run: rustup install && rustup update
- uses: actions/checkout@v7
- uses: Swatinem/rust-cache@v2.9.2
- name: Run tests
run: cargo test --all-features
lint:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Update rust
run: rustup install && rustup update
- uses: Swatinem/rust-cache@v2.9.2
- name: clippy
run: cargo clippy --all-features --all-targets -- --deny warnings
fmt:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Update rust
run: rustup install && rustup update
- name: fmt
run: cargo fmt --check