Skip to content

Commit 57a31a6

Browse files
committed
feat: switch from third-party coverage tool to GitHub API
1 parent a482170 commit 57a31a6

3 files changed

Lines changed: 10 additions & 24 deletions

File tree

.github/dependency-review-config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ allow-licenses:
2424
- 'LicenseRef-scancode-google-patent-license-golang'
2525

2626
allow-dependencies-licenses:
27-
# this action is GPL-3 but it is only used in CI
28-
# https://github.com/actions/dependency-review-action/issues/530#issuecomment-1638291806
29-
- pkg:githubactions/vladopajic/go-test-coverage@bcd064e5ceef1ccec5441519eb054263b6a44787
3027
# this package is MPL-2.0 and has a CNCF exception
3128
# https://github.com/cncf/foundation/blob/9b8c9173c2101c1b4aedad3caf2c0128715133f6/license-exceptions/cncf-exceptions-2022-04-12.json#L43C17-L43C47
3229
- pkg:golang/github.com/go-sql-driver/mysql

.github/workflows/coverage.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ jobs:
1717
- name: Calculate coverage
1818
run: |
1919
go test -count=1 -v -covermode=atomic -coverprofile=cover.out -coverpkg=./... ./...
20-
- name: Generage coverage badge
21-
uses: vladopajic/go-test-coverage@a93b868a4cbcbf18dc3781650fad241f0020e609 # v2.18.8
20+
- name: Convert Go coverage profile to cobertuba format
21+
run: |
22+
go get github.com/boumenot/gocover-cobertura@v1.5.0
23+
gocover-cobertura < cover.out > cover.xml
24+
- name: Upload coverage to GitHub API
25+
uses: actions/upload-code-coverage@abb5995db9e0199b0e2bb9dbd136fce4cb1ec4d3 # v1.3.0
2226
with:
23-
profile: cover.out
24-
local-prefix: github.com/${{ github.repository }}
25-
git-token: ${{ secrets.GITHUB_TOKEN }}
26-
# orphan branch for storing badges
27-
git-branch: badges
27+
file: cover.xml
28+
language: Go
29+
label: code-coverage/${{ github.repository }}

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Go Reference](https://pkg.go.dev/badge/github.com/smlx/go-cli-github.svg)](https://pkg.go.dev/github.com/smlx/go-cli-github)
44
[![Release](https://github.com/smlx/go-cli-github/actions/workflows/release.yaml/badge.svg)](https://github.com/smlx/go-cli-github/actions/workflows/release.yaml)
5-
[![coverage](https://raw.githubusercontent.com/smlx/go-cli-github/badges/.badges/main/coverage.svg)](https://github.com/smlx/go-cli-github/actions/workflows/coverage.yaml)
65
[![Go Report Card](https://goreportcard.com/badge/github.com/smlx/go-cli-github)](https://goreportcard.com/report/github.com/smlx/go-cli-github)
76
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/smlx/go-cli-github/badge)](https://securityscorecards.dev/viewer/?uri=github.com/smlx/go-cli-github)
87
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8168/badge)](https://www.bestpractices.dev/projects/8168)
@@ -23,7 +22,7 @@ It also automatically builds and tests your code using [GitHub Actions](https://
2322
* Test Pull Requests using `go test`.
2423
* Build container images from Pull Requests and push them to the GitHub container registry for manual testing and review.
2524
* Static code analysis using [CodeQL](https://codeql.github.com/) and [Go Report Card](https://goreportcard.com/).
26-
* Coverage analysis using the [go-test-coverage action](https://github.com/vladopajic/go-test-coverage).
25+
* Coverage analysis using the [GitHub coverage API](https://docs.github.com/en/code-security/how-tos/maintain-quality-code/set-up-code-coverage).
2726
* Security analysis using [OpenSSF](https://securityscorecards.dev).
2827
* Signed binary and container release artifacts using [artifact attestations](https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
2928
* SBOM generation for both release artifacts and container images, with image SBOMs pushed to the container registry.
@@ -54,18 +53,6 @@ Then push some code to main:
5453
git push -u origin main
5554
```
5655

57-
1. Create the `badges` branch for storing the README coverage badge.
58-
59-
```bash
60-
git checkout --orphan badges
61-
git rm -rf .
62-
rm -f .gitignore
63-
echo 'This branch exists only to store the coverage badge in the README on `main`.' > README.md
64-
git add README.md
65-
git commit -m 'chore: initialize the badges branch'
66-
git push origin badges
67-
```
68-
6956
Then customize the code for your repository:
7057

7158
1. Check out a new branch to set up the repo `git checkout -b setup main`

0 commit comments

Comments
 (0)