From 5d3ccb69c37a0902c8d338dbf5e0b00b1c809b90 Mon Sep 17 00:00:00 2001 From: garrytan Date: Thu, 29 Oct 2026 16:15:24 +0000 Subject: [PATCH] feat(flaky): gstack-flaky run reruns a failed JUnit test once and ledgers the flake (GSTA-158) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- bin/gstack-flaky | 110 ++++++++++ docs/TESTING_INTERNALS.md | 5 + docs/flaky.md | 91 ++++++++ lib/flaky-run.ts | 226 ++++++++++++++++++++ lib/junit.ts | 204 ++++++++++++++++++ test/fixtures/junit/bun.xml | 17 ++ test/fixtures/junit/playwright-r0.xml | 138 ++++++++++++ test/fixtures/junit/playwright-r2-inc.xml | 244 +++++++++++++++++++++ test/fixtures/junit/playwright-r2.xml | 178 ++++++++++++++++ test/flaky-run.test.ts | 245 ++++++++++++++++++++++ 10 files changed, 1458 insertions(+) create mode 100755 bin/gstack-flaky create mode 100644 docs/flaky.md create mode 100644 lib/flaky-run.ts create mode 100644 lib/junit.ts create mode 100644 test/fixtures/junit/bun.xml create mode 100644 test/fixtures/junit/playwright-r0.xml create mode 100644 test/fixtures/junit/playwright-r2-inc.xml create mode 100644 test/fixtures/junit/playwright-r2.xml create mode 100644 test/flaky-run.test.ts diff --git a/bin/gstack-flaky b/bin/gstack-flaky new file mode 100755 index 000000000..7bec3b7ba --- /dev/null +++ b/bin/gstack-flaky @@ -0,0 +1,110 @@ +#!/usr/bin/env -S bun --no-env-file --config=/dev/null +/** + * gstack-flaky (GSTA-158): rerun a failed test once and record the flake, for + * any runner that writes JUnit (Playwright, bun, jest, pytest, vitest). CREW + * rule 16 for every repository: "you can just run the failed test again and + * note that it is flaky". The rules live in lib/flaky-run.ts; docs/flaky.md is + * the how-to and the error-code table. + */ +import * as fs from 'fs'; +import { DEFAULT_MAX_RERUNS, appendLedger, ledgerPath, renderResult, runFlaky, stepSummary } from '../lib/flaky-run'; +import { JunitError, readJunit, type JunitRunner } from '../lib/junit'; + +const USAGE = `Usage: + gstack-flaky run --junit [--runner playwright|bun|generic] [--max-reruns ] + [--rerun-arg