Skip to content

Commit 9b22601

Browse files
gustavoliraclaude
andauthored
feat(coverage): add Codecov integration with per-workspace flags (RHIDP-11862) (#2955)
* feat(coverage): add Codecov integration with per-workspace flags (RHIDP-11862) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(coverage): tighten Codecov upload condition in CI workflow Add id to test step and check its outcome before uploading coverage, preventing wasted uploads when earlier steps (lint, tsc, build) fail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore(coverage): bump codecov-action from v5.5.4 to v6.0.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(coverage): scope upload directory, fix ignore patterns, drop empty components - Add `directory` to Codecov upload to scope search to the workspace - Change scripts/**/docs/** ignores to **/scripts/**/docs/** to cover workspace-level directories (dcm, orchestrator, cost-management, etc.) - Remove `components` from comment layout since component_management is not configured Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(coverage): ignore setupTests files in Codecov coverage These 79 files across workspaces are test infrastructure (polyfills, testing-library imports) — not application code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(coverage): scope coverage to plugin source directories only Apply reviewer suggestion to align with RHIDP-11862 scope: - Use explicit `files` + `disable_search` instead of `directory` to only upload lcov.info from plugins, excluding example apps - Add `paths` to project and patch status to restrict Codecov metrics to workspaces/*/plugins/*/src/** Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 865e771 commit 9b22601

3 files changed

Lines changed: 171 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,19 @@ jobs:
124124
run: yarn backstage-cli repo fix --check --publish
125125

126126
- name: test changed packages
127+
id: tests
127128
run: yarn test:all --maxWorkers=3
128129

130+
- name: Upload coverage to Codecov
131+
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
132+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
133+
with:
134+
flags: ${{ matrix.workspace }}
135+
files: workspaces/${{ matrix.workspace }}/plugins/**/coverage/lcov.info
136+
disable_search: true
137+
token: ${{ secrets.CODECOV_TOKEN }}
138+
fail_ci_if_error: false
139+
129140
- name: install playwright
130141
if: ${{ hashFiles(format('workspaces/{0}/playwright.config.ts', matrix.workspace)) != '' }}
131142
run: yarn playwright install --with-deps chromium chrome
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Codecov baseline coverage for redhat-developer/rhdh-plugins
2+
#
3+
# Feature umbrella: RHDHPLAN-851
4+
# Epic: RHIDP-11862 — Unit Test Coverage for RHDH Plugins Repository
5+
#
6+
# Runs the test suite for every workspace on push to main and uploads
7+
# coverage to Codecov. This establishes the per-workspace baselines that
8+
# Codecov uses to calculate coverage deltas in PRs (via carryforward).
9+
#
10+
# PR-level coverage is handled by the upload step in ci.yml; this
11+
# workflow only covers push events so the two never duplicate work.
12+
13+
name: Coverage Baseline
14+
15+
on:
16+
push:
17+
branches:
18+
- main
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
list-workspaces:
29+
name: Discover workspaces
30+
runs-on: ubuntu-latest
31+
outputs:
32+
workspaces: ${{ steps.list.outputs.workspaces }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
36+
with:
37+
fetch-depth: 1
38+
persist-credentials: false
39+
40+
- name: List all workspaces
41+
id: list
42+
run: |
43+
WORKSPACES=$(ls -d workspaces/*/ 2>/dev/null | sed 's|workspaces/||;s|/$||' | grep -v '^\.' | jq -R -s -c 'split("\n") | map(select(length > 0))')
44+
echo "workspaces=$WORKSPACES" >> "$GITHUB_OUTPUT"
45+
46+
coverage:
47+
name: Coverage — ${{ matrix.workspace }}
48+
runs-on: ubuntu-latest
49+
needs: list-workspaces
50+
strategy:
51+
matrix:
52+
workspace: ${{ fromJSON(needs.list-workspaces.outputs.workspaces) }}
53+
fail-fast: false
54+
defaults:
55+
run:
56+
working-directory: ./workspaces/${{ matrix.workspace }}
57+
58+
env:
59+
CI: true
60+
NODE_OPTIONS: --max-old-space-size=8192
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
65+
with:
66+
fetch-depth: 1
67+
persist-credentials: false
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
71+
with:
72+
node-version: 24
73+
registry-url: https://registry.npmjs.org/
74+
75+
- name: Install dependencies
76+
run: yarn install --immutable
77+
78+
- name: Run tests with coverage
79+
id: tests
80+
run: yarn test:all --maxWorkers=3
81+
82+
- name: Upload coverage to Codecov
83+
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
84+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
85+
with:
86+
flags: ${{ matrix.workspace }}
87+
files: workspaces/${{ matrix.workspace }}/plugins/**/coverage/lcov.info
88+
disable_search: true
89+
token: ${{ secrets.CODECOV_TOKEN }}
90+
fail_ci_if_error: false

codecov.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Codecov configuration for redhat-developer/rhdh-plugins
2+
# Reference: https://docs.codecov.com/docs/codecov-yaml
3+
#
4+
# Feature umbrella: RHDHPLAN-851
5+
# Epic: RHIDP-11862 — Unit Test Coverage for RHDH Plugins Repository
6+
#
7+
# Each workspace uploads coverage with its own flag (e.g., lightspeed,
8+
# orchestrator). Flags are created dynamically by the upload step in CI;
9+
# default_rules apply to all of them automatically.
10+
11+
codecov:
12+
require_ci_to_pass: false
13+
notify:
14+
wait_for_ci: true
15+
16+
coverage:
17+
precision: 2
18+
round: down
19+
range: "40...80"
20+
21+
status:
22+
project:
23+
default:
24+
target: auto
25+
threshold: 100%
26+
informational: true
27+
only_pulls: false
28+
paths:
29+
- "workspaces/*/plugins/*/src/**"
30+
patch:
31+
default:
32+
target: auto
33+
threshold: 100%
34+
informational: true
35+
paths:
36+
- "workspaces/*/plugins/*/src/**"
37+
38+
comment:
39+
layout: "header, diff, flags, footer"
40+
behavior: default
41+
require_changes: false
42+
show_carryforward_flags: true
43+
44+
ignore:
45+
- "**/*.test.ts"
46+
- "**/*.test.tsx"
47+
- "**/*.spec.ts"
48+
- "**/*.spec.tsx"
49+
- "**/index.ts"
50+
- "**/__fixtures__/**"
51+
- "**/__tests__/**"
52+
- "**/__mocks__/**"
53+
- "**/dist/**"
54+
- "**/build/**"
55+
- "**/node_modules/**"
56+
- "**/setupTests.*"
57+
- "**/playwright.config.ts"
58+
- "**/scripts/**"
59+
- "**/docs/**"
60+
61+
flag_management:
62+
default_rules:
63+
carryforward: true
64+
statuses:
65+
- type: project
66+
target: auto
67+
threshold: 100%
68+
- type: patch
69+
target: auto
70+
threshold: 100%

0 commit comments

Comments
 (0)