Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/scripts/merge-ctrf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node
/**
* Merges UI and Integration CTRF JSON reports into a single playwright-ctrf.json
* for GitHub test reporting. Run after both Playwright test steps in CI.
*/
const fs = require('fs');
const path = require('path');

const dir = path.join(__dirname, '../../playwright-ctrf');
const uiPath = path.join(dir, 'playwright-ctrf-ui.json');
const integrationPath = path.join(dir, 'playwright-ctrf-integration.json');
const outPath = path.join(dir, 'playwright-ctrf.json');

function loadJson(filePath) {
const raw = fs.readFileSync(filePath, 'utf8');
return JSON.parse(raw);
}

function mergeSummary(a, b) {
const sum = (x, y) => (x ?? 0) + (y ?? 0);
return {
tests: sum(a.tests, b.tests),
passed: sum(a.passed, b.passed),
failed: sum(a.failed, b.failed),
pending: sum(a.pending, b.pending),
skipped: sum(a.skipped, b.skipped),
other: sum(a.other, b.other),
start: Math.min(a.start ?? Infinity, b.start ?? Infinity),
stop: Math.max(a.stop ?? 0, b.stop ?? 0),
};
}

const ui = loadJson(uiPath);
const integration = loadJson(integrationPath);

const r1 = ui.results;
const r2 = integration.results;

const merged = {
results: {
tool: r1.tool ?? r2.tool,
summary: mergeSummary(r1.summary ?? {}, r2.summary ?? {}),
tests: [...(r1.tests ?? []), ...(r2.tests ?? [])],
environment: r1.environment ?? r2.environment ?? {},
},
};

fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(outPath, JSON.stringify(merged, null, 0), 'utf8');
console.log(
`Merged CTRF: ${(r1.tests ?? []).length} UI + ${(r2.tests ?? []).length} Integration tests -> ${outPath}`,
);
18 changes: 16 additions & 2 deletions .github/workflows/playwright-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,22 @@ jobs:
working-directory: content-sources-backend
run: while [[ "$(curl http://localhost:8000/api/content-sources/v1.0/repositories/ -H "$( ./scripts/header.sh 9999 1111)" | jq '.data | all(.status == "Valid")')" == "false" ]]; do sleep 5; done;

- name: Run front-end Playwright tests
run: CURRENTS_PROJECT_ID=mMVOFH CURRENTS_RECORD_KEY=$CURRENTS_RECORD_KEY CURRENTS_CI_BUILD_ID="${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" yarn playwright test
- name: Run front-end Playwright tests (UI)
run: yarn playwright test
env:
CURRENTS_PROJECT_ID: ${{ secrets.CURRENTS_PROJECT_ID }}
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}

- name: Run front-end Playwright tests (Integration)
run: INTEGRATION=true yarn playwright test
env:
CURRENTS_PROJECT_ID: ${{ secrets.CURRENTS_PROJECT_ID }}
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}

- name: Merge CTRF reports
run: node .github/scripts/merge-ctrf.js

- name: Publish front-end Test Report
uses: ctrf-io/github-test-reporter@v1
Expand Down
7 changes: 6 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export default defineConfig({
['html', { outputFolder: 'playwright-report' }],
[
'playwright-ctrf-json-reporter',
{ outputDir: 'playwright-ctrf', outputFile: 'playwright-ctrf.json' },
{
outputDir: 'playwright-ctrf',
outputFile: process.env.INTEGRATION
? 'playwright-ctrf-integration.json'
: 'playwright-ctrf-ui.json',
},
],
['@currents/playwright'],
]
Expand Down
Loading