Add codecov configuration file and simplify coverage profile generation

A codecov.yml configuration file has been added to specify the coverage target and other codecov settings. The CI pipeline has also been streamlined to directly generate the coverage profile without using grep for filtering ignored code paths. This makes it easier to understand and maintain the testing and coverage reporting process.
This commit is contained in:
Winni Neessen 2024-03-14 10:35:43 +01:00
parent aae55baa1d
commit 83c67b33be
Signed by: wneessen
GPG key ID: 385AC9889632126E
2 changed files with 28 additions and 5 deletions

View file

@ -36,12 +36,9 @@ jobs:
go-version: ${{ matrix.go }}
- name: Run Tests
run: |
go test -v -race --coverprofile=coverage.coverprofile.tmp --covermode=atomic ./...
- name: Remove ignored code from coverage profile
run: |
grep -v -E '(apg-go/cmd/apg/apg.go|apg-go/example-code)' coverage.coverprofile.tmp > coverage.coverprofile
go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
- name: Upload coverage to Codecov
if: success() && matrix.go == '1.22' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos

26
codecov.yml Normal file
View file

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
#
# SPDX-License-Identifier: CC0-1.0
coverage:
status:
project:
default:
target: 85%
threshold: 5%
base: auto
if_ci_failed: error
only_pulls: false
patch:
default:
target: 80%
base: auto
if_ci_failed: error
threshold: 5%
comment:
require_changes: true
ignore:
- "cmd/apg"
- "example-code"