Skip to content

feat: Unit test coverage on PRs (#13) #40

feat: Unit test coverage on PRs (#13)

feat: Unit test coverage on PRs (#13) #40

Workflow file for this run

name: "Test"
on:
push:
branches:
- main
paths-ignore:
- '.run/**'
- 'docs/**'
- '*.md'
pull_request:
branches:
- main
types: [ opened, synchronize ]
paths-ignore:
- '.run/**'
- 'docs/**'
- '*.md'
jobs:
test:
name: "Run unit tests"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "^1.21.1"
- name: Install dependencies and run tests
run: |
go mod download
go test -v ./... -coverpkg=./... -short -coverprofile=unit_coverage.out
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-${{github.sha}}
path: unit_coverage.out
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]
with:
coverage-artifact-name: code-coverage-${{github.sha}}
coverage-file-name: unit_coverage.out