|
| 1 | +name: Lint |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + merge_group: |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +permissions: {} |
| 13 | + |
| 14 | +jobs: |
| 15 | + clippy: |
| 16 | + name: Run clippy on crates |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 60 |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - name: Install Rust toolchain |
| 28 | + uses: dtolnay/rust-toolchain@22a6a5b0f9f487c5f5587025ae9d4a1caf2a8a78 # clippy |
| 29 | + |
| 30 | + - name: Rust cache |
| 31 | + uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2 |
| 32 | + with: |
| 33 | + cache-on-failure: true |
| 34 | + |
| 35 | + - name: Run clippy |
| 36 | + run: cargo clippy --workspace --examples --tests --benches --all-features --all-targets --locked |
| 37 | + env: |
| 38 | + RUSTFLAGS: -D warnings |
| 39 | + |
| 40 | + fmt: |
| 41 | + name: Check code formatting |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 30 |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + steps: |
| 47 | + - name: Checkout repository |
| 48 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 49 | + with: |
| 50 | + persist-credentials: false |
| 51 | + |
| 52 | + - name: Install Rust toolchain |
| 53 | + uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable |
| 54 | + with: |
| 55 | + components: rustfmt |
| 56 | + |
| 57 | + - name: Check Rust formatting |
| 58 | + run: cargo fmt --all --check |
| 59 | + |
| 60 | + taplo: |
| 61 | + name: Lint and check formatting of TOML files |
| 62 | + runs-on: ubuntu-latest |
| 63 | + timeout-minutes: 10 |
| 64 | + permissions: |
| 65 | + contents: read |
| 66 | + steps: |
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 69 | + with: |
| 70 | + persist-credentials: false |
| 71 | + |
| 72 | + - name: Install latest taplo |
| 73 | + run: | |
| 74 | + curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz \ |
| 75 | + | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo |
| 76 | +
|
| 77 | + - name: Run taplo lint |
| 78 | + run: | |
| 79 | + taplo lint |
| 80 | +
|
| 81 | + - name: Run taplo format check |
| 82 | + run: | |
| 83 | + taplo fmt --check |
| 84 | +
|
| 85 | + lint-success: |
| 86 | + name: Check that lints passed |
| 87 | + runs-on: ubuntu-latest |
| 88 | + if: always() |
| 89 | + needs: |
| 90 | + - clippy |
| 91 | + - fmt |
| 92 | + - taplo |
| 93 | + timeout-minutes: 30 |
| 94 | + steps: |
| 95 | + - name: Decide whether the needed jobs succeeded or failed |
| 96 | + uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # release/v1 |
| 97 | + with: |
| 98 | + jobs: ${{ toJSON(needs) }} |
0 commit comments