Skip to content

Commit 3726cf9

Browse files
committed
clippy: Add script to format json output as github inline annotation
Signed-off-by: Jerens Lensun <[email protected]>
1 parent 299305f commit 3726cf9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ jobs:
3434
- name: rustfmt
3535
run: cargo fmt --check
3636

37+
- name: Make Clippy JSON formatting script executable
38+
run: |
39+
chmod +x etc/ci/clippy-annotation.sh
40+
3741
- name: clippy
38-
run: cargo clippy --features "${{ matrix.features }}" --target ${{ matrix.platform.target }}
42+
run: cargo clippy --features "${{ matrix.features }}" --target ${{ matrix.platform.target }} --message-format=json | etc/ci/clippy-annotation.sh
3943

4044
- name: Cargo test
4145
run: cargo test --features "${{ matrix.features }} enable-slow-tests" --target ${{ matrix.platform.target }}

etc/ci/clippy-annotation.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
jq -r '
8+
select(.reason == "compiler-message")
9+
| .message as $msg
10+
| select($msg.level == "error" or $msg.level == "warning")
11+
| $msg.spans[]
12+
| select(.is_primary)
13+
| "::\($msg.level) file=\(.file_name),line=\(.line_start),col=\(.column_start)\(if .column_end != .column_start then ",endColumn=\(.column_end)" else "" end)::\($msg.message)"'

0 commit comments

Comments
 (0)