|
| 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 | +[](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. |
0 commit comments