Skip to content

Commit d4d85eb

Browse files
committed
Add Codecov CI upload and project configuration
Upload cover.out from unit tests on pull requests and main pushes.
1 parent b7521b0 commit d4d85eb

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

.codecov.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
codecov:
3+
notify:
4+
after_n_builds: 1
5+
require_ci_to_pass: false
6+
7+
coverage:
8+
precision: 2
9+
round: down
10+
range: 50..75
11+
12+
status:
13+
project:
14+
default:
15+
enabled: true
16+
# Report coverage; do not fail PRs on small drops until we set a target.
17+
threshold: null
18+
if_not_found: success
19+
if_no_uploads: success
20+
if_ci_failed: error
21+
patch:
22+
default:
23+
enabled: true
24+
threshold: null
25+
if_not_found: success
26+
if_no_uploads: success
27+
if_ci_failed: error
28+
changes: false
29+
30+
comment:
31+
layout: "header, diff"
32+
behavior: default
33+
require_changes: false
34+
35+
ignore:
36+
- "**/zz_generated.*.go"
37+
- "**/applyconfiguration/**"

.github/workflows/codecov.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Codecov
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
codecov:
16+
name: Upload coverage
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Clone the code
20+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Run unit tests with coverage
28+
run: |
29+
go mod tidy
30+
make test
31+
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
34+
env:
35+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36+
with:
37+
files: ./cover.out
38+
fail_ci_if_error: true

site-src/contributing/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ From the repository root:
2121
- **Lint / vet:** `make lint`
2222
- **Tests:** `make test` (writes `cover.out` for coverage)
2323
- **Test coverage:** `make test` writes `cover.out`. Run `make test-cover` to refresh tests and emit `out/coverage.html` and `out/coverage.txt` (`go tool cover`). With `cover.out` present, `make cover-func` prints a per-function summary and `make cover-html` opens the interactive HTML report in a browser (local). Remove generated artifacts with `make cover-clean`.
24+
- **CI coverage:** Pull requests and pushes to `main` upload `cover.out` to [Codecov](https://codecov.io/gh/kubernetes-sigs/mcp-lifecycle-operator).
2425
- **Generate manifests:** `make manifests generate`
2526

2627
After making changes, open a pull request on GitHub. Ensure CI passes and address any review feedback.

0 commit comments

Comments
 (0)