Skip to content

Commit 77b9d4f

Browse files
committed
BUILD/MINOR: ci: add extra job to indicate if someone used revive override
1 parent 7e9a3c9 commit 77b9d4f

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ variables:
1919
include:
2020
- local: .gitlab/bots.yml
2121
- local: .gitlab/diff.yml
22+
- local: .gitlab/diff-warnings.yml
2223
- local: .gitlab/lint.yml
2324
- local: .gitlab/unit-tests.yml
2425
- local: .gitlab/build.yml

.gitlab/diff-warnings.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
check-revive-flags:
2+
stage: diff
3+
allow_failure: true
4+
rules:
5+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
6+
image:
7+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
8+
entrypoint: [ "" ]
9+
tags:
10+
- go
11+
script:
12+
- git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
13+
# Parse the diff to find 'revive:disable' and track file/line info
14+
- |
15+
git diff -U0 origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}...HEAD | perl -ne '
16+
if (/^\+\+\+ b\/(.*)/) { $file = $1; }
17+
if (/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) { $line = $1; }
18+
if (/^\+(.*revive:disable.*)/) {
19+
print "$file:$line:$1\n";
20+
$line++;
21+
} elsif (/^\+/) {
22+
$line++;
23+
}
24+
' > found_disables.txt || true
25+
26+
- |
27+
if [ -s found_disables.txt ]; then
28+
echo "⚠️ Found 'revive:disable' in the following locations:"
29+
cat found_disables.txt
30+
31+
DESCRIPTION=$(cat found_disables.txt)
32+
junit-report add --status=failed --file=revive-check --message="revive:disable found" --description="$DESCRIPTION"
33+
exit 1
34+
else
35+
echo "✅ No 'revive:disable' tags found in the diff."
36+
junit-report add --status=ok --file=revive-check --message="clean" --description="No linter disables found."
37+
fi
38+
artifacts:
39+
when: always
40+
paths:
41+
- junit-report.xml
42+
reports:
43+
junit: junit-report.xml

0 commit comments

Comments
 (0)