-
Notifications
You must be signed in to change notification settings - Fork 12
ci: Move realm server tests into shards #4269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
797772e
f1139a3
3cc9065
ebd54d2
7c01d8d
2e79398
5527bb7
3def21c
633390c
08b469d
d1d5c38
63a1472
b466d12
a9d868c
0e6e753
191a8cd
6af24f2
5ad24c3
8520c5d
48365ea
521e7e6
49e2c98
eace2d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,6 +116,8 @@ | |||||
| `pnpm test` | ||||||
| - Run a single module: | ||||||
| `TEST_MODULE=card-endpoints-test.ts pnpm test-module` | ||||||
| - Run a list of modules: | ||||||
| `TEST_MODULES=card-endpoints-test.ts|another-module-test.ts pnpm test` | ||||||
|
||||||
| `TEST_MODULES=card-endpoints-test.ts|another-module-test.ts pnpm test` | |
| `TEST_MODULES="card-endpoints-test.ts|another-module-test.ts" pnpm test` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| #!/usr/bin/env node | ||
| /* eslint-env node */ | ||
| 'use strict'; | ||
|
|
||
| // QUnit JUnit XML reporter for CI. | ||
| // | ||
| // Usage: qunit --reporter junit-reporter.js ... | ||
| // Or: qunit --require ./scripts/junit-reporter.js --reporter console ... | ||
| // | ||
| // Set JUNIT_OUTPUT_FILE to control the output path (default: junit/realm-server.xml). | ||
| // When used as a --require module, this attaches alongside the default console | ||
| // reporter so you get both terminal output and a JUnit file. | ||
|
|
||
| const fs = require('node:fs'); // eslint-disable-line @typescript-eslint/no-var-requires | ||
| const path = require('node:path'); // eslint-disable-line @typescript-eslint/no-var-requires | ||
| const QUnit = require('qunit'); // eslint-disable-line @typescript-eslint/no-var-requires | ||
|
|
||
| const outputFile = | ||
| process.env.JUNIT_OUTPUT_FILE || | ||
| path.join(process.cwd(), '..', '..', 'junit', 'realm-server.xml'); | ||
|
|
||
| const suites = new Map(); // moduleName -> { tests, failures, errors, time, testCases } | ||
|
|
||
| function escapeXml(str) { | ||
| return String(str) | ||
| .replace(/&/g, '&') | ||
| .replace(/</g, '<') | ||
| .replace(/>/g, '>') | ||
| .replace(/"/g, '"') | ||
| .replace(/'/g, '''); | ||
| } | ||
|
|
||
| QUnit.on('testEnd', (data) => { | ||
| const moduleName = data.module || 'default'; | ||
| const testName = data.name || 'unknown'; | ||
| const runtime = (data.runtime || 0) / 1000; // ms → seconds | ||
| const status = data.status; // passed, failed, skipped, todo | ||
|
|
||
| if (!suites.has(moduleName)) { | ||
| suites.set(moduleName, { | ||
| tests: 0, | ||
| failures: 0, | ||
| errors: 0, | ||
| skipped: 0, | ||
| time: 0, | ||
| testCases: [], | ||
| }); | ||
| } | ||
|
|
||
| const suite = suites.get(moduleName); | ||
| suite.tests++; | ||
| suite.time += runtime; | ||
|
|
||
| let caseXml = ` <testcase classname="${escapeXml(moduleName)}" name="${escapeXml(testName)}" time="${runtime.toFixed(3)}"`; | ||
|
|
||
| if (status === 'failed') { | ||
| suite.failures++; | ||
| const messages = (data.errors || []) | ||
| .map((e) => { | ||
| let msg = e.message || ''; | ||
| if (e.actual !== undefined && e.expected !== undefined) { | ||
| msg += `\nExpected: ${JSON.stringify(e.expected)}\nActual: ${JSON.stringify(e.actual)}`; | ||
| } | ||
| if (e.stack) { | ||
| msg += `\n${e.stack}`; | ||
| } | ||
| return msg; | ||
| }) | ||
| .join('\n---\n'); | ||
| caseXml += `>\n <failure message="${escapeXml((data.errors?.[0]?.message || 'test failed').slice(0, 200))}">${escapeXml(messages)}</failure>\n </testcase>`; | ||
| } else if (status === 'skipped' || status === 'todo') { | ||
| suite.skipped++; | ||
| caseXml += `>\n <skipped />\n </testcase>`; | ||
| } else { | ||
| caseXml += ` />`; | ||
| } | ||
|
|
||
| suite.testCases.push(caseXml); | ||
| }); | ||
|
|
||
| QUnit.on('runEnd', () => { | ||
| const suitesXml = []; | ||
| let totalTests = 0; | ||
| let totalFailures = 0; | ||
| let totalErrors = 0; | ||
| let totalSkipped = 0; | ||
| let totalTime = 0; | ||
|
|
||
| for (const [name, suite] of suites) { | ||
| totalTests += suite.tests; | ||
| totalFailures += suite.failures; | ||
| totalErrors += suite.errors; | ||
| totalSkipped += suite.skipped; | ||
| totalTime += suite.time; | ||
|
|
||
| suitesXml.push( | ||
| ` <testsuite name="${escapeXml(name)}" tests="${suite.tests}" failures="${suite.failures}" errors="${suite.errors}" skipped="${suite.skipped}" time="${suite.time.toFixed(3)}">\n${suite.testCases.join('\n')}\n </testsuite>`, | ||
| ); | ||
| } | ||
|
|
||
| const xml = [ | ||
| `<?xml version="1.0" encoding="UTF-8"?>`, | ||
| `<testsuites name="Realm Server Tests" tests="${totalTests}" failures="${totalFailures}" errors="${totalErrors}" skipped="${totalSkipped}" time="${totalTime.toFixed(3)}">`, | ||
| ...suitesXml, | ||
| `</testsuites>`, | ||
| ].join('\n'); | ||
|
|
||
| const dir = path.dirname(outputFile); | ||
| fs.mkdirSync(dir, { recursive: true }); | ||
| fs.writeFileSync(outputFile, xml, 'utf8'); | ||
| }); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step hardcodes the total shard count as
6even though the matrix already definesshardTotal. To avoid drift if the shard count changes later, pass${{ matrix.shardTotal }}toshard-test-modules.jsinstead of a constant.