Skip to content

Commit e15af16

Browse files
committed
Use GitHub step summaries to report coverage
1 parent 79f1ea2 commit e15af16

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

.github/workflows/lint.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
--max-issues-per-linter 0 \
4848
--max-same-issues 0 \
4949
--out-format json |
50-
jq --color-output --sort-keys \
51-
'reduce .Issues[] as $i ({}; .[$i.FromLinter] += 1)' ||
52-
true
50+
jq --sort-keys 'reduce .Issues[] as $i ({}; .[$i.FromLinter] += 1)' |
51+
awk >> "${GITHUB_STEP_SUMMARY}" '
52+
NR == 1 { print "```json" } { print } END { if (NR > 0) print "```" }
53+
' || true

.github/workflows/test.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
retention-days: 1
109109

110110
coverage-report:
111+
if: ${{ success() || contains(needs.*.result, 'success') }}
111112
runs-on: ubuntu-latest
112113
needs:
113114
- kubernetes-api
@@ -120,17 +121,23 @@ jobs:
120121
with: { path: download }
121122

122123
# Combine the coverage profiles by taking the mode line from any one file
123-
# and the data from all files. Print a list of functions with less than
124-
# 100% coverage, and upload a complete HTML report.
124+
# and the data from all files. Write a list of functions with less than
125+
# 100% coverage to the job summary, and upload a complete HTML report.
125126
- name: Generate report
126127
run: |
127128
gunzip --keep download/*/*.gz
128129
( sed -e '1q' download/*/*.coverage
129130
tail -qn +2 download/*/*.coverage ) > total.coverage
130131
go tool cover --func total.coverage -o total-coverage.txt
131132
go tool cover --html total.coverage -o total-coverage.html
132-
sed -e '/100.0%/d' -e "s,$(go list -m)/,," total-coverage.txt
133-
awk 'END { print "::notice title=Total Coverage::" $3 " " $2 }' total-coverage.txt
133+
134+
awk < total-coverage.txt '
135+
END { print "<details><summary>Total Coverage: <code>" $3 " " $2 "</code></summary>" }
136+
' >> "${GITHUB_STEP_SUMMARY}"
137+
138+
sed < total-coverage.txt -e '/100.0%/d' -e "s,$(go list -m)/,," | column -t | awk '
139+
NR == 1 { print "\n\n```" } { print } END { if (NR > 0) print "```\n\n"; print "</details>" }
140+
' >> "${GITHUB_STEP_SUMMARY}"
134141
135142
# Upload coverage to GitHub
136143
- run: gzip total-coverage.html

0 commit comments

Comments
 (0)