-
Notifications
You must be signed in to change notification settings - Fork 9
105 lines (82 loc) · 3.75 KB
/
lint.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Lint
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
style:
name: Check Style
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set Rust Toolchain
id: toolchain
shell: bash
run: |
RUST_TOOLCHAIN="$(grep -oP '^channel.*"(\K.*?)(?=")' rust-toolchain.toml)"
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
- name: Set Rust Nightly Toolchain
id: nightly-toolchain
shell: bash
run: |
RUST_NIGHTLY_TOOLCHAIN="$(grep -oP '^nightly-channel.*"(\K.*?)(?=")' rust-toolchain.toml)"
echo "RUST_NIGHTLY_TOOLCHAIN=${RUST_NIGHTLY_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
- name: Install rust
uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c # stable
with:
toolchain: "${{ steps.toolchain.outputs.RUST_TOOLCHAIN }}"
components: clippy, rustfmt
- name: Install rust nightly
run: |
rustup toolchain install "${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}"
rustup component add rustfmt --toolchain "${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}"-x86_64-unknown-linux-gnu
- name: Cache cargo registry
uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- name: Cargo fmt
run: cargo +"${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}" fmt --check
- name: Install clippy-sarif and sarif-fmt
run: cargo install clippy-sarif sarif-fmt --locked --git https://github.com/psastras/sarif-rs.git --rev 11c33a53f6ffeaed736856b86fb6b7b09fabdfd8
- name: Cargo clippy-sarif
run: cargo clippy --all-features --tests --message-format=json |
clippy-sarif | tee clippy_result.sarif | sarif-fmt
env:
RUSTFLAGS: "-D warnings"
- name: Upload Clippy results to GitHub
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
sarif_file: clippy_result.sarif
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
# Run it again but this time without the sarif output so that the
# status code of the command is caught and reported as failed in GitHub.
# This should be cached from the previous step and should be fast.
- name: Cargo clippy
run: cargo clippy --all-features --tests
env:
RUSTFLAGS: "-D warnings"
- name: Install cargo-sort
run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev f5047967021cbb1f822faddc355b3b07674305a1
- name: Cargo sort
run: cargo sort --workspace --check
- name: Install cargo-udeps
run: cargo install cargo-udeps --version 0.1.53 --locked
- name: Cargo udeps
run: cargo +"${{ steps.nightly-toolchain.outputs.RUST_NIGHTLY_TOOLCHAIN }}" udeps --workspace --all-features
- name: Set up Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
cache: "npm"
cache-dependency-path: "package-lock.json"
node-version: "16"
- name: NPM setup
run: npm ci
- name: Node Lint
run: npm run lint
- name: Verify rust documentation links
run: cargo doc --no-deps --all-features --document-private-items
env:
RUSTDOCFLAGS: "-D warnings"