Add code coverage #48
Workflow file for this run
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
name: build | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
test: | |
name: ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run tests | |
run: make test | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: code-coverage | |
path: coverage.txt | |
- name: Run build | |
run: make build | |
code_coverage: | |
name: "Code coverage report" | |
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: read | |
actions: read # to download code coverage results from "test" job | |
pull-requests: write # write permission needed to comment on PR | |
steps: | |
- uses: fgrosse/[email protected] # Consider using a Git revision for maximum security | |
with: | |
coverage-artifact-name: "code-coverage" # can be omitted if you used this default value | |
coverage-file-name: "coverage.txt" # can be omitted if you used this default value |