Skip to content

Commit eef0937

Browse files
committed
BUILD/MINOR: ci: use better reports for ci jobs
1 parent 9af6b2f commit eef0937

File tree

6 files changed

+91
-6
lines changed

6 files changed

+91
-6
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ variables:
1111
DOCKER_DRIVER: overlay2
1212
GO_VERSION: "1.25"
1313
DOCKER_VERSION: "28.1"
14+
JUNIT_FILE: "junit-report.xml"
15+
GOTESTSUM_JUNITFILE: "junit-report.xml"
1416

1517
include:
1618
- local: .gitlab/bots.yml

.gitlab/bots.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
pipelines-check:
42
stage: bots
53
needs: []

.gitlab/diff.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,26 @@ diff:
1515
- task generate
1616
- "sed -i 's/internal: false/internal: true/g' taskfile/generate.yml"
1717
script:
18+
- test -z "$(git diff 2> /dev/null)" || git diff
19+
- test -z "$(git diff 2> /dev/null)" || junit-report add --status=failed --file=git-diff --message="git diff is not clean" --description="$(git diff)"
1820
- test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`cd documentation/gen && go run .\` and commit the result"
21+
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || git ls-files --others --exclude-standard
22+
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || junit-report add --status=failed --file=git-ls-files --message="Documentation created untracked files" --description="$(git ls-files --others --exclude-standard 2> /dev/null)"
1923
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed"
24+
- junit-report add --status=ok --file=diff --message="Diff is clean" --description="Check for uncommitted changes in the repository"
25+
artifacts:
26+
when: always
27+
paths:
28+
- junit-report.xml
29+
reports:
30+
junit: junit-report.xml
2031
check-large-files:
2132
stage: diff
2233
rules:
2334
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
35+
image:
36+
name: $CI_REGISTRY_GO/golang:$GO_VERSION
37+
entrypoint: [ "" ]
2438
tags:
2539
- go
2640
script:
@@ -38,7 +52,15 @@ check-large-files:
3852
if [ -s large_files.txt ]; then
3953
echo "❌ The following files exceed 1MB:"
4054
cat large_files.txt
55+
junit-report add --status=failed --file=large-files --message="large files found" --description="$(cat large_files.txt)"
4156
exit 1
4257
else
4358
echo "✅ No large files found in the latest commit."
59+
junit-report add --status=ok --file=large-files --message="commit clean" --description="No large files found in the latest commit."
4460
fi
61+
artifacts:
62+
when: always
63+
paths:
64+
- junit-report.xml
65+
reports:
66+
junit: junit-report.xml

.gitlab/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ tidy:
1212
script:
1313
- go mod tidy
1414
- test -z "$(git diff 2> /dev/null)" || exit 'Go modules not tidied, issue \`go mod tidy\` and commit the result'
15+
after_script:
16+
- |
17+
if [ "$CI_JOB_STATUS" == "success" ]; then
18+
junit-report add --status=ok --message="tidy check passed successfully"
19+
else
20+
junit-report add --status=failed --message="go mod tidy not executed" --description="$(git diff)"
21+
fi
22+
artifacts:
23+
when: always
24+
paths:
25+
- junit-report.xml
26+
reports:
27+
junit: junit-report.xml
1528
format:
1629
stage: lint
1730
needs: []
@@ -28,6 +41,19 @@ format:
2841
- task format
2942
- "sed -i 's/internal: false/internal: true/g' taskfile.yml"
3043
- test -z "$(git diff 2> /dev/null)" || exit 'Go code not formatted, issue \`task ci\` and commit the result'
44+
after_script:
45+
- |
46+
if [ "$CI_JOB_STATUS" == "success" ]; then
47+
junit-report add --status=ok --message="format check passed successfully"
48+
else
49+
junit-report add --status=failed --message="go code not formatted" --description="$(git diff)"
50+
fi
51+
artifacts:
52+
when: always
53+
paths:
54+
- junit-report.xml
55+
reports:
56+
junit: junit-report.xml
3157
lint:
3258
stage: lint
3359
needs: []
@@ -41,6 +67,19 @@ lint:
4167
- go
4268
script:
4369
- task lint
70+
after_script:
71+
- |
72+
if [ "$CI_JOB_STATUS" == "success" ]; then
73+
junit-report add --status=ok --message="linting passed successfully"
74+
else
75+
junit-report add --status=failed --message="git diff is not clean" --description="$(git diff)"
76+
fi
77+
artifacts:
78+
when: always
79+
paths:
80+
- junit-report.xml
81+
reports:
82+
junit: junit-report.xml
4483
commit-policy:
4584
stage: lint
4685
needs: []

.gitlab/security.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ license:
1313
- "sed -i 's/internal: true/internal: false/g' taskfile.yml"
1414
script:
1515
- task licenses
16+
after_script:
17+
- |
18+
if [ "$CI_JOB_STATUS" == "success" ]; then
19+
junit-report add --status=ok --message="license check passed successfully"
20+
else
21+
junit-report add --status=failed --message="licenses errors" --description="$(task licenses 2>&1)"
22+
fi
23+
artifacts:
24+
when: always
25+
paths:
26+
- junit-report.xml
27+
reports:
28+
junit: junit-report.xml
1629
govulncheck:
1730
stage: security
1831
needs: []
@@ -28,3 +41,16 @@ govulncheck:
2841
- "sed -i 's/internal: true/internal: false/g' taskfile.yml"
2942
script:
3043
- task govulncheck
44+
after_script:
45+
- |
46+
if [ "$CI_JOB_STATUS" == "success" ]; then
47+
junit-report add --status=ok --message="vulnerability check passed successfully"
48+
else
49+
junit-report add --status=failed --message="vulnerabilities detected" --description="$(task govulncheck 2>&1)"
50+
fi
51+
artifacts:
52+
when: always
53+
paths:
54+
- junit-report.xml
55+
reports:
56+
junit: junit-report.xml

.gitlab/unit-tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
unit-tests:
22
needs: ["diff", "tidy"]
3-
variables:
4-
GOTESTSUM_JUNITFILE: "unit-tests-report.xml"
53
rules:
64
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
75
- if: "$CI_PROJECT_NAMESPACE != 'haproxy-controller/community' && $CI_PIPELINE_SOURCE == 'push'"
@@ -18,6 +16,6 @@ unit-tests:
1816
artifacts:
1917
when: always
2018
paths:
21-
- unit-tests-report.xml
19+
- junit-report.xml
2220
reports:
23-
junit: unit-tests-report.xml
21+
junit: junit-report.xml

0 commit comments

Comments
 (0)