summaryrefslogtreecommitdiff
path: root/.github/workflows/rust-warnings.yml
blob: a2e3208e5294f4ae7bd578635cad6d91f1e9b2e3 (plain)
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
# Surface Rust warnings on PRs that touch any Rust code.
# Not a required check so we never block people over new warnings
# that might come from a new Rust version being released.
name: Rust warnings
on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
    paths:
      - '**.rs'
      - '!**.inc.rs'
  merge_group:

concurrency:
  group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
  cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}

permissions:
  contents: read

jobs:
  rust-warnings:
    env:
      GITPULLOPTIONS: --no-tags origin ${{ github.ref }}

    runs-on: ubuntu-24.04

    if: >-
      ${{!(false
      || contains(github.event.head_commit.message, '[DOC]')
      || contains(github.event.pull_request.title, '[DOC]')
      || contains(github.event.pull_request.labels.*.name, 'Documentation')
      || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]')
      )}}

    steps:
      - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

      - name: Install Rust
        run: rustup default beta

      - name: Rust warnings
        shell: bash
        run: |
          set -eu
          cargo check --quiet --all-features --message-format=json \
            | jq -r 'select(.message.level | IN("warning", "error")) | .message.rendered' \
            | tee messages.txt
          (exit "${PIPESTATUS[0]}") && ! grep --quiet '[^[:space:]]' messages.txt

      - name: "📜 `rustdoc` warnings"
        shell: bash
        run: |
          set -eu
          cargo doc --document-private-items --all --no-deps --message-format=json \
            | jq -r 'select(.message.level | IN("warning", "error")) | .message.rendered' \
            | tee messages.txt
          (exit "${PIPESTATUS[0]}") && ! grep --quiet '[^[:space:]]' messages.txt