From 1e5a8bcbcba86b6c9fcdc4528fd64ad4ee5f18b9 Mon Sep 17 00:00:00 2001 From: Matthias <5011972+fasmat@users.noreply.github.com> Date: Thu, 7 Sep 2023 08:48:13 +0000 Subject: [PATCH] Measure code coverage --- .github/codecov.yml | 16 ++++++++++++++++ .github/workflows/go.yml | 19 +++++++++++++++++++ Makefile | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..6ebdf4c --- /dev/null +++ b/.github/codecov.yml @@ -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" diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 443c2be..d66250e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 }} diff --git a/Makefile b/Makefile index bc11ebf..0ad7cb2 100644 --- a/Makefile +++ b/Makefile @@ -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: