Skip to content

Commit

Permalink
Add test coverage check to CI.yaml (#13)
Browse files Browse the repository at this point in the history
* Add test coverage workflow

Signed-off-by: thepetk <[email protected]>

* Update ci.yaml

Signed-off-by: thepetk <[email protected]>

* Add separate check for code coverage

Signed-off-by: thepetk <[email protected]>

* Move code report in ci file

Signed-off-by: thepetk <[email protected]>

* Add .codecov.yaml

Signed-off-by: thepetk <[email protected]>

* Update workflow

Signed-off-by: thepetk <[email protected]>

* Bump up setup-go

Signed-off-by:thepetk <[email protected]>

---------

Signed-off-by: thepetk <[email protected]>
  • Loading branch information
thepetk committed Jul 27, 2023
1 parent 25a4fb9 commit f2b97bf
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See http://docs.codecov.io/docs/coverage-configuration
coverage:
precision: 2 # 2 = xx.xx%, 0 = xx%
round: down
# For example: 20...60 would result in any coverage less than 20%
# would have a red background. The color would gradually change to
# green approaching 60%. Any coverage over 60% would result in a
# solid green color.
range: "60...80"

status:
# project will give us the diff in the total code coverage between a commit
# and its parent
project: yes
# Patch gives just the coverage of the patch
patch: yes
# changes tells us if there are unexpected code coverage changes in other files
# which were not changed by the diff
changes: yes

# See http://docs.codecov.io/docs/ignoring-paths
ignore:
- "docs/*"
- ".github/*"
- "resources/*"
- "test/*"
- "Makefile"

# See http://docs.codecov.io/docs/pull-request-comments-1
comment:
layout: "diff, files"
behavior: ""
# default = posts once then update, posts new if delete
# once = post once then updates
# new = delete old, post new
# spammy = post new
18 changes: 17 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,20 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
# Path to SARIF file relative to the root of the repository
sarif_file: gosec.sarif
sarif_file: gosec.sarif

code-coverage-report:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
with:
persist-credentials: false
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run tests
run: make test
- name: Codecov
uses: codecov/[email protected]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ buildWin:

.PHONY: test
test:
go test ./...
go test -coverprofile cover.out -v ./...

0 comments on commit f2b97bf

Please sign in to comment.