Skip to content

Commit

Permalink
Measure code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Sep 7, 2023
1 parent 6c78279 commit d1d2555
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ref: https://docs.codecov.com/docs/codecovyml-reference
coverage:
range: 80..100
round: down
precision: 1
status:
# ref: https://docs.codecov.com/docs/commit-status
project:
default:
# Avoid false negatives
threshold: 1%

ignore:
- "**/*_scale.go"
- "**/*mock*.go"
- "**/mocks/*.go"
31 changes: 25 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Go

env:
go-version: "1.19"

on:
pull_request:
push:
Expand All @@ -17,7 +14,8 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
check-latest: true
go-version-file: "go.mod"
- name: fmt, tidy
run: |
make install
Expand All @@ -35,7 +33,8 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
check-latest: true
go-version-file: "go.mod"
- name: setup env
run: make install
- name: lint
Expand All @@ -57,7 +56,8 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
check-latest: true
go-version-file: "go.mod"
- name: setup env
run: make install
- name: Clear test cache
Expand All @@ -74,3 +74,22 @@ jobs:
with:
report_paths: "**/unit-tests.xml"
annotate_only: true

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up go
uses: actions/setup-go@v4
with:
check-latest: true
go-version-file: "go.mod"
- name: setup env
run: make install
- name: test coverage
run: make cover
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ lint-github-action:
.PHONY: lint-github-action

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

staticcheck:
Expand Down

0 comments on commit d1d2555

Please sign in to comment.