Skip to content

Commit b959c8d

Browse files
authored
feat: 🎨 Adding coverage report to PR (#37)
Signed-off-by: Thor Anker Kvisgård Lange <tal@netic.dk>
1 parent e86ebfc commit b959c8d

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

.github/workflows/go-ci.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ on:
5353

5454
jobs:
5555
tests:
56+
name: Tests
5657
env:
5758
GOPRIVATE: "${{ inputs.go-private }}"
5859
GH_USERNAME: ${{ secrets.gh_username || 'gh-netic-robot' }}
@@ -87,7 +88,13 @@ jobs:
8788
install-mode: "goinstall"
8889

8990
- name: Go Compile and Test
90-
run: go test -cover -v ./...
91+
run: go test -cover -coverprofile=coverage.txt -v ./...
92+
93+
- name: Archive code coverage results
94+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
95+
with:
96+
name: code-coverage
97+
path: coverage.txt
9198

9299
- name: Run benchmarks
93100
if: inputs.run-benchmarks
@@ -163,3 +170,18 @@ jobs:
163170
- name: Clean up private repository access configuration
164171
if: always() && steps.setup_git_creds.outcome == 'success' && inputs.go-private != ''
165172
run: git config --global --unset url."https://${{ env.GH_USERNAME }}:${{ env.GH_TOKEN }}@github.com".insteadOf
173+
174+
code-coverage:
175+
name: Code Coverage
176+
runs-on: ubuntu-latest
177+
if: github.event_name == 'pull_request'
178+
needs: tests
179+
permissions:
180+
contents: read
181+
actions: read
182+
pull-requests: write
183+
steps:
184+
- uses: fgrosse/go-coverage-report@8c1d1a09864211d258937b1b1a5b849f7e4f2682 # v1
185+
with:
186+
coverage-artifact-name: code-coverage
187+
coverage-file-name: "coverage.txt"

0 commit comments

Comments
 (0)