Skip to content

Commit 383ce95

Browse files
authored
Use CodeCov to check code coverage (#1326)
1 parent fda1c08 commit 383ce95

File tree

4 files changed

+59
-60
lines changed

4 files changed

+59
-60
lines changed

.codecov.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Codecov configuration file
2+
# This file configures code coverage reporting and requirements for the project
3+
coverage:
4+
5+
# Coverage status configuration
6+
status:
7+
8+
# Project-level coverage settings
9+
project:
10+
11+
# Default status check configuration
12+
default:
13+
14+
# The minimum required coverage value for the project
15+
target: 80%
16+
17+
# The allowed coverage decrease before failing the status check
18+
threshold: 0%
19+
20+
# Whether to run coverage checks only on pull requests
21+
only_pulls: false
22+
23+
# Patch-level coverage settings
24+
patch:
25+
26+
default:
27+
28+
target: 80%
29+
threshold: 0%
30+
only_pulls: false
31+
32+
comment:
33+
layout: "header,diff,files,footer"
34+
behavior: default
35+
require_changes: false
36+
require_base: false
37+
require_head: true
38+
39+
40+
# Ignore files or packages matching their paths
41+
ignore:
42+
- '\.pb\.go$' # Excludes all protobuf generated files
43+
- '\.gen\.go' # Excludes generated files
44+
- '^fake_.*\.go' # Excludes fakes
45+
- '^test/.*$'
46+
- 'app.go' # app.go and main.go should be tested by integration tests.
47+
- 'main.go'
48+
# ignore metadata generated files
49+
- 'metadata/generated_.*\.go'
50+
# ignore wrappers around gopsutil
51+
- 'internal/datasource/host'
52+
- 'internal/watcher/process'
53+
- 'pkg/nginxprocess'
54+

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,11 @@ jobs:
6868
cache: false
6969
- name: Run Unit Tests
7070
run: make unit-test
71-
- name: Check Coverage
72-
uses: vladopajic/go-test-coverage@dd4b1f21c4e48db0425e1187d2845404b1206919
71+
- name: Uplaod Test Coverage
72+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
7373
with:
74-
config: ./.testcoverage.yaml
75-
## when token is not specified (value '') this feature is turned off
76-
git-token: ${{ github.ref_name == 'main' && secrets.GITHUB_TOKEN || '' }}
77-
## name of orphaned branch where badges are stored
78-
git-branch: badges
74+
files: ./build/test/coverage.out
75+
token: ${{ secrets.CODECOV_TOKEN }}
7976

8077
race-condition-test:
8178
name: Unit tests with race condition detection

.testcoverage.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ $(TEST_BUILD_DIR)/coverage.out:
153153
.PHONY: coverage
154154
coverage: $(TEST_BUILD_DIR)/coverage.out
155155
@echo "Checking code coverage"
156-
@$(GORUN) $(GOTESTCOVERAGE) --config=./.testcoverage.yaml
156+
@printf "Total code coverage: " && $(GOTOOL) cover -func=$(TEST_BUILD_DIR)/coverage.out | grep 'total:' | awk '{print $$3}'
157157

158158
build-mock-management-plane-grpc:
159159
mkdir -p $(BUILD_DIR)/mock-management-plane-grpc

0 commit comments

Comments
 (0)