Skip to content
Open
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
20 changes: 19 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,31 @@ jobs:
run: bunx playwright install chromium

- name: Run app e2e tests
id: e2e
run: bun --cwd packages/app test:e2e:local
env:
CI: true
timeout-minutes: 30

- name: Detect Playwright flakes
id: playwright-status
if: always()
run: |
node <<'EOF'
const fs = require("fs")
const file = "packages/app/e2e/playwright-report/results.json"
if (!fs.existsSync(file)) {
fs.appendFileSync(process.env.GITHUB_OUTPUT, "flaky=false\nflaky_count=0\n")
process.exit(0)
}

const report = JSON.parse(fs.readFileSync(file, "utf8"))
const count = Number(report?.stats?.flaky ?? report?.suitesSummary?.flaky ?? 0)
fs.appendFileSync(process.env.GITHUB_OUTPUT, `flaky=${count > 0}\nflaky_count=${count}\n`)
Comment on lines +118 to +120
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flake-detection script will throw and fail the workflow if results.json exists but is malformed/partial (e.g., Playwright process interrupted, file truncated). Since this step runs if: always(), a parse error could incorrectly turn an otherwise-successful run into a failed job. Consider wrapping the JSON read/parse in try/catch and defaulting outputs to flaky=false (or emitting a separate flaky_parse_error output) instead of letting the step fail.

Suggested change
const report = JSON.parse(fs.readFileSync(file, "utf8"))
const count = Number(report?.stats?.flaky ?? report?.suitesSummary?.flaky ?? 0)
fs.appendFileSync(process.env.GITHUB_OUTPUT, `flaky=${count > 0}\nflaky_count=${count}\n`)
try {
const raw = fs.readFileSync(file, "utf8")
const report = JSON.parse(raw)
const count = Number(report?.stats?.flaky ?? report?.suitesSummary?.flaky ?? 0)
fs.appendFileSync(
process.env.GITHUB_OUTPUT,
`flaky=${count > 0}\nflaky_count=${count}\n`
)
} catch (error) {
console.error("Failed to read or parse Playwright results.json for flake detection:", error)
fs.appendFileSync(process.env.GITHUB_OUTPUT, "flaky=false\nflaky_count=0\n")
process.exit(0)
}

Copilot uses AI. Check for mistakes.
EOF

- name: Upload Playwright artifacts
if: failure()
if: failure() || steps.playwright-status.outputs.flaky == 'true'
uses: actions/upload-artifact@v4
with:
name: playwright-${{ matrix.settings.name }}-${{ github.run_attempt }}
Expand Down
6 changes: 5 additions & 1 deletion packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers,
reporter: [["html", { outputFolder: "e2e/playwright-report", open: "never" }], ["line"]],
reporter: [
["html", { outputFolder: "e2e/playwright-report", open: "never" }],
["json", { outputFile: "e2e/playwright-report/results.json" }],
["line"],
],
webServer: {
command,
url: baseURL,
Expand Down
Loading