-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): enforce clippy and
cargo fmt
in CI (#2628)
- Loading branch information
1 parent
6db3bda
commit e54cf10
Showing
4 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Clippy | ||
|
||
on: | ||
pull_request: | ||
merge_group: | ||
push: | ||
branches: | ||
- master | ||
|
||
# This will cancel previous runs when a branch or PR is updated | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
clippy: | ||
name: cargo clippy | ||
runs-on: ${{ matrix.runner }} | ||
timeout-minutes: 30 | ||
env: | ||
CACHED_PATHS: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- runner: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore cargo cache | ||
uses: actions/cache/restore@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.CACHED_PATHS }} | ||
key: ${{ matrix.target }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} | ||
|
||
- name: Setup toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable # We do not use MSRV so we can benefit from newer lints | ||
targets: ${{ matrix.target }} | ||
components: clippy, rustfmt | ||
|
||
- name: Run `cargo clippy` | ||
run: cargo clippy --workspace --locked --release | ||
|
||
- name: Run `cargo fmt` | ||
run: cargo fmt --all --check | ||
|
||
- uses: actions/cache/save@v3 | ||
# Write a cache entry even if the tests fail but don't create any for the merge queue. | ||
if: ${{ always() && steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }} | ||
with: | ||
path: ${{ env.CACHED_PATHS }} | ||
key: ${{ steps.cache.outputs.cache-primary-key }} |
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
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
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