Skip to content

Commit 474904e

Browse files
committed
feat(coverage-matrix): add SDK coverage matrix dashboard
Add a coverage matrix tool that automatically discovers all @forgerock/* package exports and measures test coverage across unit tests, type tests, and e2e tests — with zero manual path maintenance. Pipeline (all via Nx): pnpm nx run @forgerock/coverage-matrix:coverage-report - Discovers packages from workspace package.json exports fields - Extracts public exports via TypeScript AST - Collects V8 unit coverage from Vitest - Collects V8 e2e coverage from Playwright's built-in CDP API - Merges into a per-export coverage matrix - Builds a Svelte dashboard deployable to GitHub Pages E2E coverage uses Playwright's page.coverage.startJSCoverage() — no instrumented builds, no Vite plugins, no Nx cache concerns. The @forgerock/e2e-shared package provides a coverage fixture that all 26 e2e test files import for automatic collection. CI integration: - Non-blocking coverage-report step in PR workflow - Coverage summary posted as PR comment - Dashboard deployed to GitHub Pages on merge to main
1 parent e239060 commit 474904e

90 files changed

Lines changed: 3623 additions & 96 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,57 @@ jobs:
134134
135135
---
136136
<sub>🔄 Updated automatically on each push to this PR</sub>
137+
138+
# Coverage Matrix (non-blocking)
139+
# Runs the full pipeline: analyze exports, collect V8 unit coverage,
140+
# merge into final matrix, and build the Svelte dashboard.
141+
# Zero manual path maintenance — discovers packages and exports automatically.
142+
- name: Generate coverage matrix and build dashboard
143+
continue-on-error: true
144+
run: pnpm nx run @forgerock/coverage-matrix:coverage-report
145+
146+
- name: Generate coverage matrix summary
147+
continue-on-error: true
148+
id: coverage-matrix-summary
149+
run: |
150+
node -e "
151+
const fs = require('fs');
152+
try {
153+
const data = JSON.parse(fs.readFileSync('tools/coverage-matrix/data/coverage-matrix.json', 'utf-8'));
154+
const rows = data.packages.map(p => {
155+
const s = p.summary;
156+
const uPct = s.totalExports > 0 ? Math.round(s.unitCovered / s.totalExports * 100) : 0;
157+
const ePct = s.totalExports > 0 ? Math.round(s.e2eCovered / s.totalExports * 100) : 0;
158+
const fPct = s.totalSourceFiles > 0 ? Math.round(s.unitTestedFiles / s.totalSourceFiles * 100) : 0;
159+
return '| ' + p.name + ' | ' + s.totalExports + ' | ' + fPct + '% (' + s.unitTestedFiles + '/' + s.totalSourceFiles + ') | ' + uPct + '% | ' + ePct + '% | ' + s.uncovered + ' |';
160+
});
161+
const table = '| Package | Exports | Unit Files | Unit Exports | E2E | Uncovered |\n|---------|---------|------------|--------------|-----|-----------|' + '\n' + rows.join('\n');
162+
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'table<<EOF\n' + table + '\nEOF\n');
163+
} catch (e) {
164+
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'table=Coverage matrix data not available.\n');
165+
}
166+
"
167+
168+
- name: Post coverage matrix PR comment
169+
continue-on-error: true
170+
if: github.event_name == 'pull_request'
171+
uses: peter-evans/create-or-update-comment@v4
172+
with:
173+
issue-number: ${{ github.event.pull_request.number }}
174+
body: |
175+
<!-- coverage-matrix -->
176+
## Coverage Matrix
177+
178+
${{ steps.coverage-matrix-summary.outputs.table }}
179+
180+
[Full dashboard](https://forgerock.github.io/ping-javascript-sdk/coverage-matrix/)
181+
182+
- name: Deploy dashboard to GitHub Pages
183+
continue-on-error: true
184+
if: github.ref == 'refs/heads/main'
185+
uses: peaceiris/actions-gh-pages@v4
186+
with:
187+
github_token: ${{ secrets.GITHUB_TOKEN }}
188+
publish_dir: ./tools/coverage-matrix/dist
189+
destination_dir: coverage-matrix
190+
keep_files: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ test-output
8585
# Gemini local knowledge base files
8686
GEMINI.md
8787
**/GEMINI.md
88+
.e2e-coverage/

e2e/davinci-suites/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
"main": "src/index.js",
1818
"nx": {
1919
"implicitDependencies": ["@forgerock/davinci-app", "@forgerock/mock-api-v2"]
20+
},
21+
"dependencies": {
22+
"@forgerock/e2e-shared": "workspace:*"
2023
}
2124
}

e2e/davinci-suites/src/basic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88
import { asyncEvents } from './utils/async-events.js';
99
import { password, username } from './utils/demo-user.js';
1010

e2e/davinci-suites/src/fido.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect, CDPSession } from '@playwright/test';
1+
import { test, expect, CDPSession } from '@forgerock/e2e-shared/coverage-fixture';
22
import { asyncEvents } from './utils/async-events.js';
33

44
const username = 'JSFidoUser@user.com';

e2e/davinci-suites/src/form-fields.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88

99
import { asyncEvents } from './utils/async-events.js';
1010

e2e/davinci-suites/src/logging.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88
import { asyncEvents } from './utils/async-events.js';
99
import { password, username } from './utils/demo-user.js';
1010

e2e/davinci-suites/src/mfa.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88
import { asyncEvents } from './utils/async-events.js';
99
import { password } from './utils/demo-user.js';
1010

e2e/davinci-suites/src/middleware.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88
import { asyncEvents } from './utils/async-events.js';
99
import { password, username } from './utils/demo-user.js';
1010

e2e/davinci-suites/src/phone-number-field.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This software may be modified and distributed under the terms
55
* of the MIT license. See the LICENSE file for details.
66
*/
7-
import { expect, test } from '@playwright/test';
7+
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
88
import { password } from './utils/demo-user.js';
99

1010
test.describe('Device registration tests', () => {

0 commit comments

Comments
 (0)