-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Code Coverage Tracker
- Loading branch information
Showing
1 changed file
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Lint | Test | ||
name: Lint | Test | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: | ||
- "main" | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
env: | ||
GO_VER: '1.22.4' | ||
|
||
permissions: | ||
# Required: allow read access to the content for analysis. | ||
contents: read | ||
# Optional: allow write access to checks to allow the action to annotate code in the PR. | ||
checks: write | ||
|
||
contents: read # allow read access to the content for analysis. | ||
checks: write # allow write access to checks to allow the action to annotate code in the PR. | ||
actions: read # to download code coverage results from "test" job | ||
pull-requests: write # write permission needed to comment on PR | ||
|
||
jobs: | ||
lint: | ||
|
@@ -54,3 +59,27 @@ jobs: | |
name: Run test suite | ||
run: | | ||
go test $(go list ./...) | ||
- | ||
name: Run Cover Profile | ||
if: runner.os == 'Linux' | ||
run: | | ||
go test -cover -coverprofile=coverage.txt $(go list ./...) | ||
- | ||
name: Archive code coverage results | ||
if: runner.os == 'Linux' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: code-coverage | ||
path: coverage.txt | ||
|
||
code_coverage: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
if: github.event_name == 'pull_request' | ||
steps: | ||
- | ||
name: Go Code Coverage | ||
uses: fgrosse/[email protected] | ||
with: | ||
coverage-artifact-name: "code-coverage" | ||
coverage-file-name: "coverage.txt" |