Skip to content

Commit 843c3ad

Browse files
Add Codecov to Report Test Coverage (#1101)
* fix permissions * codecov * Implement PR Size Labeler (#1098) * added PR size labeler * fix permissions * fix permissions * Apply suggestions from code review --------- Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * Use Mergify for PR Size Comments (#1099) * fix comment and line breaks * comment test * test changes * this should not trigger another one * fix multiple msg * fix multiple msg * remove test file * Update .github/workflows/codeql.yml Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * add test file * delete test file --------- Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * fix: coverage run * clean up codecov * fix path * add comment * add comment * fix path debug * fix path part 2 * test config cov * test config cov * test config cov * test config cov * test codecov config * update ci * Update codecov.yml Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * remove coverage file * unify tests * fix action codecov issue * Update codecov.yml Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]> * Update .github/workflows/test.yml * Update test.yml * Update test.yml * Update codecov.yml --------- Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
1 parent 9586061 commit 843c3ad

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ jobs:
157157
timeout-minutes: 10
158158
env:
159159
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160-
run: make testacc
160+
run: make testacc-cover
161+
162+
- name: Upload coverage report to Codecov
163+
if: matrix.flavor.target == 'linux'
164+
uses: codecov/codecov-action@v5
165+
with:
166+
token: ${{ secrets.CODECOV_TOKEN }}
167+
slug: ${{ github.repository }}
168+
files: coverage.out
169+
fail_ci_if_error: true
170+
flags: unittests
171+
verbose: true
161172

162173
docker:
163174
name: "[lint] Dockerfile"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@
4141
# Ignore components vendored during tests
4242
tests/fixtures/scenarios/vendor/components/**
4343
examples/demo-vendoring/components/**
44+
45+
# Coverage files
46+
coverage.out
47+
coverage.html

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ version-windows: build-windows
5555
deps:
5656
go mod download
5757

58-
# Run acceptance tests
5958
testacc: get
59+
@echo "Running acceptance tests"
6060
go test $(TEST) -v $(TESTARGS) -timeout 10m
6161

62-
.PHONY: lint get build version build-linux build-windows build-macos deps version-linux version-windows version-macos testacc
62+
testacc-cover: get
63+
@echo "Running tests with coverage"
64+
go test $(TEST) -v $(TESTARGS) -timeout 10m -coverprofile=coverage.out
65+
66+
# Run acceptance tests with coverage report
67+
testacc-coverage: testacc-cover
68+
go tool cover -html=coverage.out -o coverage.html
69+
70+
.PHONY: lint get build version build-linux build-windows build-macos deps version-linux version-windows version-macos testacc testacc-cover testacc-coverage

codecov.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
codecov:
2+
require_ci_to_pass: true
3+
4+
coverage:
5+
status:
6+
patch:
7+
default:
8+
target: 80% # Require at least 80% test coverage on new/changed lines
9+
threshold: 2% # Allow a small drop in coverage
10+
base: auto
11+
12+
comment:
13+
layout: "reach,diff,flags,tree" # Display different coverage views
14+
behavior: default # Default PR comment behavior
15+
require_changes: true # Only post if coverage changes
16+
require_base: yes # Compare against base branch coverage
17+
18+
github_checks:
19+
annotations: true # Enable GitHub Checks Annotations
20+
informational: false # Fail the PR check if coverage is too low

0 commit comments

Comments
 (0)