-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (34 loc) · 1.09 KB
/
lint-cargo-fmt.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Make sure Rust source code is consistently formatted with rustfmt.
name: "lint-cargo-fmt.yml"
on:
pull_request: {}
merge_group:
types: ["checks_requested"]
concurrency:
group: "${{ github.workflow }}:${{ github.event.pull_request.number }}"
cancel-in-progress: true
jobs:
format-check:
name: "Check formatting for Rust code"
runs-on: "ubuntu-latest"
# Skip this job in merge group checks; but we need the workflow to run,
# given that the status check is required for merging.
if: "${{ github.event.pull_request }}"
steps:
- name: "Install Rust toolchain"
uses: "dtolnay/rust-toolchain@stable"
with:
toolchain: "nightly"
components: "rustfmt"
- name: "Checkout"
uses: "actions/checkout@v4"
with:
fetch-depth: "1"
persist-credentials: "false"
- name: "Check formatting"
run: |
cargo fmt --check
- name: "How to fix"
if: ${{ failure() }}
run: |
echo "::notice::Try fixing the issue with 'cargo fmt --all', then commit the changes."