Skip to content

Commit c7ff423

Browse files
gustavoliraclaude
andauthored
feat(coverage): add Codecov Test Analytics with JUnit XML upload (#2968)
* feat(coverage): add Codecov Test Analytics with JUnit XML upload (RHIDP-11862) Install jest-junit reporter at test time and upload JUnit XML results to Codecov via codecov/test-results-action. Uses NODE_PATH to make the reporter available without modifying workspace lockfiles. Test output goes to runner.temp to avoid polluting the working directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(coverage): use absolute path for jest-junit and pin version Use absolute path to the reporter module instead of NODE_PATH for robust resolution across different test runners. Pin jest-junit@17.0.0 for reproducibility and enable JEST_JUNIT_UNIQUE_OUTPUT_NAME to prevent file overwrites in multi-package runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c346ec1 commit c7ff423

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ jobs:
123123
- name: publish check
124124
run: yarn backstage-cli repo fix --check --publish
125125

126-
- name: test changed packages
126+
- name: Install jest-junit reporter
127+
run: npm install jest-junit@17.0.0 --prefix ${{ runner.temp }}/jest-junit
128+
129+
- name: Test changed packages
127130
id: tests
128-
run: yarn test:all --maxWorkers=3
131+
env:
132+
JEST_JUNIT_OUTPUT_DIR: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
133+
JEST_JUNIT_CLASSNAME: '{filepath}'
134+
JEST_JUNIT_UNIQUE_OUTPUT_NAME: 'true'
135+
run: yarn test:all --maxWorkers=3 --reporters=default --reporters=${{ runner.temp }}/jest-junit/node_modules/jest-junit
129136

130137
- name: Upload coverage to Codecov
131138
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
@@ -135,6 +142,15 @@ jobs:
135142
token: ${{ secrets.CODECOV_TOKEN }}
136143
fail_ci_if_error: false
137144

145+
- name: Upload test results to Codecov
146+
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
147+
uses: codecov/test-results-action@6ba3fdeec616fb91fd6a389b788a2366835a0fa2 # v1.2.1
148+
with:
149+
flags: ${{ matrix.workspace }}
150+
token: ${{ secrets.CODECOV_TOKEN }}
151+
directory: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
152+
fail_ci_if_error: false
153+
138154
- name: install playwright
139155
if: ${{ hashFiles(format('workspaces/{0}/playwright.config.ts', matrix.workspace)) != '' }}
140156
run: yarn playwright install --with-deps chromium chrome

.github/workflows/coverage-baseline.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ jobs:
7575
- name: Install dependencies
7676
run: yarn install --immutable
7777

78+
- name: Install jest-junit reporter
79+
run: npm install jest-junit@17.0.0 --prefix ${{ runner.temp }}/jest-junit
80+
7881
- name: Run tests with coverage
7982
id: tests
80-
run: yarn test:all --maxWorkers=3
83+
env:
84+
JEST_JUNIT_OUTPUT_DIR: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
85+
JEST_JUNIT_CLASSNAME: '{filepath}'
86+
JEST_JUNIT_UNIQUE_OUTPUT_NAME: 'true'
87+
run: yarn test:all --maxWorkers=3 --reporters=default --reporters=${{ runner.temp }}/jest-junit/node_modules/jest-junit
8188

8289
- name: Upload coverage to Codecov
8390
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
@@ -86,3 +93,12 @@ jobs:
8693
flags: ${{ matrix.workspace }}
8794
token: ${{ secrets.CODECOV_TOKEN }}
8895
fail_ci_if_error: false
96+
97+
- name: Upload test results to Codecov
98+
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
99+
uses: codecov/test-results-action@6ba3fdeec616fb91fd6a389b788a2366835a0fa2 # v1.2.1
100+
with:
101+
flags: ${{ matrix.workspace }}
102+
token: ${{ secrets.CODECOV_TOKEN }}
103+
directory: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
104+
fail_ci_if_error: false

0 commit comments

Comments
 (0)