Merge pull request 'fix: unset NODE_ENV in e2e job so devDependencies install' (#19) from fix/e2e-devdeps-and-summarize into main
SonarQube Analysis / sonarqube (push) Failing after 5s
Tests / backend-unit (push) Successful in 1m11s
Tests / backend-integration (push) Successful in 1m32s
Tests / frontend-e2e (push) Failing after 4m42s

Reviewed-on: #19
This commit was merged in pull request #19.
This commit is contained in:
2026-08-15 08:56:25 -05:00
3 changed files with 64 additions and 19 deletions
+24 -5
View File
@@ -107,7 +107,10 @@ jobs:
PORT: 3000
DEMO_MODE: 'true'
UPLOADS_DIR: /tmp/redefined-uploads
NODE_ENV: production
# NODE_ENV is deliberately unset: `npm install` omits devDependencies when
# NODE_ENV=production, which strips tsc/vite/@playwright/test and breaks the
# build. It would also flip the session cookie to Secure, which the e2e run
# serves over plain http.
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -125,12 +128,24 @@ jobs:
run: node migrate.js up
working-directory: backend
- name: Build and start backend
- name: Build backend
run: npm run build
working-directory: backend
- name: Start backend
run: |
mkdir -p /tmp/redefined-uploads
npm run build
node dist/server.js &
sleep 3
node dist/server.js > /tmp/backend.log 2>&1 &
for i in $(seq 1 30); do
if node -e "require('http').get('http://localhost:3000/api/config', r => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"; then
echo "Backend ready after ${i}s"
exit 0
fi
sleep 1
done
echo "Backend did not become ready within 30s:"
cat /tmp/backend.log
exit 1
working-directory: backend
- name: Install frontend deps
@@ -149,6 +164,10 @@ jobs:
run: npx playwright test --reporter=json
working-directory: frontend
- name: Backend log
if: steps.e2e.outcome == 'failure'
run: cat /tmp/backend.log
- name: Summarize
if: always()
run: node scripts/summarize-playwright.js frontend/playwright-results.json
+19 -6
View File
@@ -2,6 +2,15 @@
const fs = require('fs');
const [, , resultsPath, label] = process.argv;
// This runs with `if: always()`, so it also fires when an earlier step failed and
// no results file was ever written. Report that plainly and exit 0 — the job still
// fails on the real step, and a stack trace here would only bury it.
if (!fs.existsSync(resultsPath)) {
report([`## ${label || 'Test'} Results`, '', `No results file at \`${resultsPath}\` — the test step failed before writing one.`, '']);
process.exit(0);
}
const raw = fs.readFileSync(resultsPath, 'utf-8');
const data = JSON.parse(raw);
@@ -33,11 +42,15 @@ if (data.numFailedTests > 0) {
lines.push('');
}
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
if (summaryPath) {
fs.appendFileSync(summaryPath, lines.join('\n') + '\n');
} else {
console.log(lines.join('\n'));
}
report(lines);
process.exit(data.numFailedTests > 0 ? 1 : 0);
function report(out) {
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
if (summaryPath) {
fs.appendFileSync(summaryPath, out.join('\n') + '\n');
} else {
console.log(out.join('\n'));
}
}
+19 -6
View File
@@ -2,6 +2,15 @@
const fs = require('fs');
const [, , resultsPath] = process.argv;
// This runs with `if: always()`, so it also fires when an earlier step failed and
// no results file was ever written. Report that plainly and exit 0 — the job still
// fails on the real step, and a stack trace here would only bury it.
if (!fs.existsSync(resultsPath)) {
report([`## Playwright E2E Results`, '', `No results file at \`${resultsPath}\` — the test step failed before writing one.`, '']);
process.exit(0);
}
const raw = fs.readFileSync(resultsPath, 'utf-8');
const data = JSON.parse(raw);
const stats = data.stats || {};
@@ -44,11 +53,15 @@ if (failures.length) {
lines.push('');
}
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
if (summaryPath) {
fs.appendFileSync(summaryPath, lines.join('\n') + '\n');
} else {
console.log(lines.join('\n'));
}
report(lines);
process.exit((stats.unexpected || 0) > 0 ? 1 : 0);
function report(out) {
const summaryPath = process.env.GITEA_STEP_SUMMARY || process.env.GITHUB_STEP_SUMMARY;
if (summaryPath) {
fs.appendFileSync(summaryPath, out.join('\n') + '\n');
} else {
console.log(out.join('\n'));
}
}