Skip to content

Commit 8ed3dbd

Browse files
authored
Merge pull request #2 from NdoleStudio/copilot/add-codecov
Add Codecov coverage reporting
2 parents 1301c72 + 9f2b1ff commit 8ed3dbd

4 files changed

Lines changed: 261 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ jobs:
3737
- name: Run tests
3838
run: go test -race -cover ./...
3939

40+
coverage:
41+
name: Coverage
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
id-token: write
46+
steps:
47+
- name: Check out repository
48+
uses: actions/checkout@v7
49+
- name: Set up Go
50+
uses: actions/setup-go@v7
51+
with:
52+
go-version: 1.26.x
53+
cache: true
54+
- name: Generate coverage
55+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
56+
- name: Upload coverage to Codecov
57+
uses: codecov/codecov-action@v5
58+
with:
59+
use_oidc: true
60+
files: ./coverage.out
61+
disable_search: true
62+
fail_ci_if_error: true
63+
4064
lint:
4165
name: Lint
4266
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Stacktrace
22

33
[![CI](https://github.com/NdoleStudio/stacktrace/actions/workflows/ci.yml/badge.svg)](https://github.com/NdoleStudio/stacktrace/actions/workflows/ci.yml)
4+
[![codecov](https://codecov.io/gh/NdoleStudio/stacktrace/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/stacktrace)
45
[![Go Reference](https://pkg.go.dev/badge/github.com/NdoleStudio/stacktrace.svg)](https://pkg.go.dev/github.com/NdoleStudio/stacktrace)
56
[![License](https://img.shields.io/github/license/NdoleStudio/stacktrace)](LICENSE)
67

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Codecov Integration Implementation Plan
2+
3+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4+
5+
**Goal:** Upload one authoritative Go coverage report to Codecov and display its status in the README.
6+
7+
**Architecture:** Add a dedicated Ubuntu/Go 1.26 coverage job without changing the compatibility matrix or lint job. Generate one atomic race-enabled profile, upload it through OIDC, and link the repository's Codecov badge from the README.
8+
9+
**Tech Stack:** Go 1.18+, GitHub Actions, `codecov/codecov-action@v5`, GitHub OIDC
10+
11+
## Global Constraints
12+
13+
- Keep the existing test matrix and lint job unchanged.
14+
- Run the coverage job on `ubuntu-latest` with Go `1.26.x`.
15+
- Grant `contents: read` and `id-token: write` only to the coverage job.
16+
- Generate `coverage.out` with `go test -race -coverprofile=coverage.out -covermode=atomic ./...`.
17+
- Upload only `./coverage.out` through OIDC and fail CI when the upload fails.
18+
- Add no repository secret or Go dependency.
19+
- Keep README badge links scoped to `NdoleStudio/stacktrace`.
20+
21+
---
22+
23+
### Task 1: Add Codecov coverage reporting
24+
25+
**Files:**
26+
- Modify: `.github/workflows/ci.yml`
27+
- Modify: `README.md`
28+
29+
**Interfaces:**
30+
- Consumes: GitHub OIDC identity and Go's `coverage.out` profile.
31+
- Produces: One Codecov coverage upload per workflow run and a repository coverage badge.
32+
33+
- [ ] **Step 1: Verify Codecov is not configured**
34+
35+
Run:
36+
37+
```bash
38+
rg -n "codecov|coverage.out|coverprofile" .github/workflows/ci.yml README.md
39+
```
40+
41+
Expected: no output.
42+
43+
- [ ] **Step 2: Add the dedicated coverage job**
44+
45+
Insert this job between `test` and `lint`:
46+
47+
```yaml
48+
coverage:
49+
name: Coverage
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
id-token: write
54+
steps:
55+
- name: Check out repository
56+
uses: actions/checkout@v7
57+
- name: Set up Go
58+
uses: actions/setup-go@v7
59+
with:
60+
go-version: 1.26.x
61+
cache: true
62+
- name: Generate coverage
63+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
64+
- name: Upload coverage to Codecov
65+
uses: codecov/codecov-action@v5
66+
with:
67+
use_oidc: true
68+
files: ./coverage.out
69+
disable_search: true
70+
fail_ci_if_error: true
71+
```
72+
73+
- [ ] **Step 3: Add the README badge**
74+
75+
Immediately after the CI badge, add:
76+
77+
```markdown
78+
[![codecov](https://codecov.io/gh/NdoleStudio/stacktrace/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/stacktrace)
79+
```
80+
81+
- [ ] **Step 4: Verify the focused changes**
82+
83+
Run:
84+
85+
```bash
86+
rg -n "codecov|coverage.out|coverprofile|id-token" .github/workflows/ci.yml README.md
87+
git diff --check
88+
git diff -- .github/workflows/ci.yml README.md
89+
```
90+
91+
Expected: one coverage job, one upload step, one badge, no whitespace errors,
92+
and no changes to the existing test matrix or lint job.
93+
94+
- [ ] **Step 5: Commit the integration**
95+
96+
```bash
97+
git add .github/workflows/ci.yml README.md
98+
git commit -m "ci: upload coverage to Codecov"
99+
```
100+
101+
---
102+
103+
### Task 2: Validate the branch
104+
105+
**Files:**
106+
- Review: `.github/workflows/ci.yml`
107+
- Review: `README.md`
108+
109+
**Interfaces:**
110+
- Consumes: The complete Codecov integration diff.
111+
- Produces: A clean branch ready to push.
112+
113+
- [ ] **Step 1: Generate the coverage profile locally**
114+
115+
Run:
116+
117+
```bash
118+
go test -coverprofile=coverage.out -covermode=atomic ./...
119+
```
120+
121+
Expected: both packages pass and `coverage.out` is created. The local
122+
Windows/ARM64 host omits `-race` because that platform does not support it;
123+
the Ubuntu CI coverage job runs the exact race-enabled command.
124+
125+
- [ ] **Step 2: Remove the generated profile**
126+
127+
Run:
128+
129+
```bash
130+
Remove-Item -LiteralPath coverage.out
131+
git status --short
132+
```
133+
134+
Expected: `coverage.out` is removed and no untracked coverage artifact remains.
135+
136+
- [ ] **Step 3: Run repository checks**
137+
138+
Run:
139+
140+
```bash
141+
go test ./...
142+
go vet ./...
143+
golangci-lint fmt --diff
144+
golangci-lint run
145+
pre-commit run --all-files
146+
```
147+
148+
Expected: every command passes.
149+
150+
- [ ] **Step 4: Review the branch diff**
151+
152+
Run:
153+
154+
```bash
155+
git diff --check origin/main...HEAD
156+
git status --short
157+
git diff --stat origin/main...HEAD
158+
```
159+
160+
Expected: no whitespace errors, a clean worktree, and only the design, plan,
161+
workflow, and README files in the branch.
162+
163+
- [ ] **Step 5: Push the branch**
164+
165+
Run:
166+
167+
```bash
168+
git push -u origin copilot/add-codecov
169+
```
170+
171+
Expected: the branch is published successfully.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Codecov Integration Design
2+
3+
## Goal
4+
5+
Publish repository coverage to Codecov from GitHub Actions and display the
6+
current coverage status in `README.md`.
7+
8+
## CI Design
9+
10+
Add one dedicated `coverage` job to `.github/workflows/ci.yml`. The job runs on
11+
Ubuntu with Go 1.26.x, independently of the existing nine-combination
12+
compatibility matrix. This avoids duplicate uploads while keeping the existing
13+
test job unchanged.
14+
15+
Grant only this job:
16+
17+
```yaml
18+
permissions:
19+
contents: read
20+
id-token: write
21+
```
22+
23+
Generate an atomic race-enabled Go coverage profile:
24+
25+
```bash
26+
go test -race -coverprofile=coverage.out -covermode=atomic ./...
27+
```
28+
29+
Upload only `coverage.out` with `codecov/codecov-action@v5`. Use GitHub OIDC
30+
authentication instead of a repository secret, disable automatic report
31+
search, and fail the job if the upload fails:
32+
33+
```yaml
34+
with:
35+
use_oidc: true
36+
files: ./coverage.out
37+
disable_search: true
38+
fail_ci_if_error: true
39+
```
40+
41+
The repository must be enabled in Codecov for OIDC uploads and badge data.
42+
43+
## README Design
44+
45+
Add the Codecov badge immediately after the CI badge:
46+
47+
```markdown
48+
[![codecov](https://codecov.io/gh/NdoleStudio/stacktrace/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/stacktrace)
49+
```
50+
51+
## File Impact
52+
53+
Modify:
54+
55+
- `.github/workflows/ci.yml`
56+
- `README.md`
57+
58+
## Acceptance Checks
59+
60+
1. The existing compatibility test matrix and lint job remain unchanged.
61+
2. The coverage job has the minimum permissions needed for checkout and OIDC.
62+
3. The coverage profile is explicit, atomic, race-enabled, and uploaded once.
63+
4. Codecov upload failures fail CI.
64+
5. The README badge targets `NdoleStudio/stacktrace`.
65+
6. Existing Go tests, vet, lint, formatting, and pre-commit checks pass.

0 commit comments

Comments
 (0)