chore: introduce fgrosse/go-coverage-report #17
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: Test | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
- name: Format | |
run: gofmt -s -w . && git diff --exit-code | |
- name: Tidy | |
run: go mod tidy && git diff --exit-code | |
- name: Install gotestfmt | |
uses: gotesttools/gotestfmt-action@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Test | |
run: | | |
set -euo pipefail | |
mkdir -p "${{ runner.temp }}/covdata" | |
go test -v -cover ./... -json -test.gocoverdir="${{ runner.temp }}/covdata" 2>&1 | tee "${{ runner.temp }}/test.log" | gotestfmt | |
go tool covdata textfmt -o "${{ runner.temp }}/coverage.out" -i="${{ runner.temp }}/covdata" | |
go tool covdata percent -i="${{ runner.temp }}/covdata" | |
- name: Coverage report | |
uses: ncruces/go-coverage-report@v0 | |
with: | |
coverage-file: "${{ runner.temp }}/coverage.out" | |
report: true | |
chart: true | |
if: | | |
github.event_name == 'push' | |
continue-on-error: true | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-logs | |
path: | | |
${{ runner.temp }}/test.log | |
${{ runner.temp }}/coverage.out | |
code_coverage: | |
name: Coverage review robot | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: fgrosse/[email protected] | |
with: | |
coverage-artifact-name: test-logs | |
coverage-file-name: coverage.out |