Skip to content

Commit 5f4f279

Browse files
authored
Measure code coverage (#69)
1 parent 5dda31b commit 5f4f279

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/codecov.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ref: https://docs.codecov.com/docs/codecovyml-reference
2+
coverage:
3+
range: 80..100
4+
round: down
5+
precision: 1
6+
status:
7+
# ref: https://docs.codecov.com/docs/commit-status
8+
project:
9+
default:
10+
# Avoid false negatives
11+
threshold: 1%
12+
13+
ignore:
14+
- "**/*_scale.go"
15+
- "**/*mock*.go"
16+
- "**/mocks/*.go"

.github/workflows/go.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,22 @@ jobs:
7474
with:
7575
report_paths: "**/unit-tests.xml"
7676
annotate_only: true
77+
78+
coverage:
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
- name: set up go
83+
uses: actions/setup-go@v4
84+
with:
85+
check-latest: true
86+
go-version-file: "go.mod"
87+
- name: setup env
88+
run: make install
89+
- name: test coverage
90+
run: make cover
91+
- name: Upload to codecov.io
92+
uses: codecov/codecov-action@v3
93+
with:
94+
fail_ci_if_error: true
95+
token: ${{ secrets.CODECOV_TOKEN }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ lint-github-action:
5555
.PHONY: lint-github-action
5656

5757
cover:
58-
go test -coverprofile=cover.out -timeout 0 -p 1 $(UNIT_TESTS)
58+
go test -coverprofile=cover.out -timeout 0 -p 1 -coverpkg=./... $(UNIT_TESTS)
5959
.PHONY: cover
6060

6161
staticcheck:

0 commit comments

Comments
 (0)