Skip to content

Commit 28aedf0

Browse files
committed
ci(.github/workflows): enable Codecov coverage reporting
Add .codecov.yaml with coverage thresholds and an ignore list for non-source directories, following the same change made in tekton pruner. Upload coverage to Codecov via OIDC alongside the existing artifact upload and PR-comment step. Signed-off-by: Emil Natan <ena@redhat.com> Assisted-by: Claude Sonnet 5 (via Claude Code)
1 parent 08154dc commit 28aedf0

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

.codecov.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
coverage:
2+
# Commit status https://docs.codecov.io/docs/commit-status are used
3+
# to block PR based on coverage threshold.
4+
status:
5+
project:
6+
default:
7+
target: auto
8+
threshold: 5%
9+
patch:
10+
# Disable the coverage threshold of the patch, so that PRs are
11+
# only failing because of overall project coverage threshold.
12+
# See https://docs.codecov.io/docs/commit-status#disabling-a-status.
13+
default: false
14+
15+
ignore:
16+
# Auto-generated client code.
17+
- "pkg/client/clientset/**"
18+
- "pkg/client/informers/**"
19+
- "pkg/client/listers/**"
20+
- "pkg/client/injection/**"
21+
# Auto-generated deepcopy/openapi code.
22+
- "pkg/apis/config/zz_generated.deepcopy.go"
23+
- "pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go"
24+
- "pkg/apis/triggers/v1beta1/zz_generated.deepcopy.go"
25+
- "pkg/apis/triggers/v1beta1/openapi_generated.go"
26+
- "hack/**"
27+
- "test/**"
28+
- "config/**"
29+
- "tekton/**"
30+
- "docs/**"
31+
- "vendor/**"

.github/workflows/go-coverage.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
runs-on: ubuntu-24.04
2828
permissions:
2929
pull-requests: write # Required by go-coverage-report to comment on PRs
30+
id-token: write # Required to upload coverage to Codecov via OIDC
3031

3132
steps:
3233
- name: Harden runner
@@ -48,19 +49,28 @@ jobs:
4849
- name: Generate coverage
4950
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/triggers
5051
run: |
51-
go test -cover -coverprofile=coverage.txt ./... || true
52+
go test -coverprofile=coverage.out -covermode=atomic ./... || true
5253
echo "Generated coverage profile"
5354
5455
- name: Archive coverage results
5556
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
5657
with:
5758
name: code-coverage
58-
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers/coverage.txt
59+
path: ${{ github.workspace }}/src/github.com/tektoncd/triggers/coverage.out
5960

6061
- name: Comment on PR
6162
if: github.event_name == 'pull_request'
6263
uses: fgrosse/go-coverage-report@cbeb2ab2e32591d690337146ba02a911cc566f3f # v1.3.0
6364
continue-on-error: true # This may fail if artifact on main branch does not exist (first run or expired)
6465
with:
6566
coverage-artifact-name: "code-coverage"
66-
coverage-file-name: "coverage.txt"
67+
coverage-file-name: "coverage.out"
68+
69+
- name: Upload coverage to Codecov
70+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
71+
continue-on-error: true # job still "succeeds" even if this step fails
72+
with:
73+
files: ${{ github.workspace }}/src/github.com/tektoncd/triggers/coverage.out
74+
flags: unit-tests
75+
use_oidc: true
76+
fail_ci_if_error: false

0 commit comments

Comments
 (0)