Add coverage report #95
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: action | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Build | |
run: go build -v ./... | |
- name: Lint | |
uses: golangci/golangci-lint-action@v3 | |
- name: Test | |
run: go test -cpu 2 -timeout 2m -race -v ./... | |
- name: Test coverage | |
run: go test -v -covermode=count -coverprofile=coverage.out ./... | |
- name: Tool cover | |
run: go tool cover -func=coverage.out -o=coverage.out | |
- name: Obtain coverage | |
run: echo "COVERAGE=$(grep -e 'total' coverage.out | awk '{print $3;}')" >> $GITHUB_ENV | |
- name: Create coverage badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: c77b22000b3e249510dfb4542847c708 | |
filename: test_coverage.json | |
label: "test coverage" | |
message: ${{ env.COVERAGE }} | |
valColorRange: ${{ env.COVERAGE }} | |
maxColorRange: 100 | |
minColorRange: 0 |