ci: run cargo & clippy tests only on code changes (#379) #165
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cargo & Clippy Test | |
on: | |
push: | |
branches: [master] | |
paths: | |
- src/** | |
- test_files/** | |
- .cargo/** | |
- Cargo.toml | |
- Cargo.lock | |
- rust-toolchain.toml | |
pull_request: | |
paths: | |
- src/** | |
- test_files/** | |
- .cargo/** | |
- Cargo.toml | |
- Cargo.lock | |
- rust-toolchain.toml | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build_and_test: | |
name: Rust and clippy tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies installed with cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
./target/deps | |
~/.cargo | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: Build binary | |
# the binary will be used by the next cargo test step | |
run: cargo build | |
- name: Run cargo tests | |
run: cargo test --all-targets --all-features | |
- name: Run clippy check | |
run: cargo clippy --all-targets --all-features -- -D warnings |