|
| 1 | +# Surface Rust warnings on PRs that touch any Rust code |
| 2 | +name: Show Rust warnings on PR |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + - reopened |
| 9 | + paths: |
| 10 | + - '**.rs' |
| 11 | + - '!**.inc.rs' |
| 12 | + merge_group: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }} |
| 16 | + cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }} |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + make: |
| 23 | + strategy: |
| 24 | + env: |
| 25 | + GITPULLOPTIONS: --no-tags origin ${{ github.ref }} |
| 26 | + |
| 27 | + runs-on: ubuntu-24.04 |
| 28 | + |
| 29 | + if: >- |
| 30 | + ${{!(false |
| 31 | + || contains(github.event.head_commit.message, '[DOC]') |
| 32 | + || contains(github.event.head_commit.message, 'Document') |
| 33 | + || contains(github.event.pull_request.title, '[DOC]') |
| 34 | + || contains(github.event.pull_request.title, 'Document') |
| 35 | + || contains(github.event.pull_request.labels.*.name, 'Documentation') |
| 36 | + || (github.event_name == 'push' && github.event.pull_request.user.login == 'dependabot[bot]') |
| 37 | + )}} |
| 38 | +
|
| 39 | + steps: |
| 40 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 41 | + with: |
| 42 | + sparse-checkout-cone-mode: false |
| 43 | + sparse-checkout: /.github |
| 44 | + |
| 45 | + - name: Install Rust |
| 46 | + run: rustup default beta |
| 47 | + |
| 48 | + - name: Gather and translate warnings |
| 49 | + run: | |
| 50 | + cargo check --all-features --message-format=json | |
| 51 | + jq -r 'select(.reason == "compiler-message" and .message.level == "warning") | |
| 52 | + "::warning file=\(.message.spans[0].file_name),line=\(.message.spans[0].line_start),endLine=\(.message.spans[0].line_end)::\( |
| 53 | + .message.rendered | gsub("%"; "%25") | gsub("\n"; "%0A") | gsub("\r"; "%0D"))"' |
0 commit comments