Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ A lane whose run has no key, such as a fork's, files nothing and still passes.
- Playwright runs with `retries: 1` when `CI` is set (`web/playwright.config.ts`, `desktop/playwright.config.ts`), and the Rust workspace runs under `cargo nextest` with the `ci` profile's `retries = 1` (`.config/nextest.toml`, `scripts/verify-cargo.sh nextest`).
Neither retries locally: a flaky test fails where it is written.
- A test that fails and passes its retry is flaky: the lane passes, the log marks it, and `scripts/ci-flaky-report.py` reads the tool's own report (Playwright's JSON, nextest's JUnit) and files it as an issue labelled `quarantine`, or comments on the open issue that already tracks it.
An issue CI filed names its test whole in its `- Test:` line and tracks only that file and exact name, so a renamed test or a sibling that starts the same way opens an issue of its own; only a hand-written issue, which quotes a title cut short, matches by the file and the first 20 characters of the name.
Issue and comment lookup read every page, using the nightly report's existing bound of ten pages of 100 entries; an incomplete listing or a GitHub error stops filing and leaves the warning and unfiled-test summary below, rather than creating an issue or comment from a partial search.
The issue names the first run, the change and the system, and carries a deadline seven days out.
The report step also sets its `flaky` output, and a lane that keeps its e2e logs for a failure keeps them for a flaky run too, because the first attempt's daemon, holder and input logs are the evidence its issue needs.
Expand Down
20 changes: 18 additions & 2 deletions scripts/ci-flaky-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
r"(?:\x1b\[|\x9b)[0-?]*[ -/]*[@-~]|\x1b(?:[\]PX^_][^\x07\x1b\n]*(?:\x07|\x1b\\)?|[ -/]*[0-~])?"
r"|[\x00-\x08\x0b-\x1f\x7f-\x9f]"
)
# Hand-written issues quote a title cut short ("Agent tabs shrink in stages...").
# Hand-written issues quote a title cut short ("Agent tabs shrink in stages...");
# only they match by this much of the name (`tracks`).
MATCH_PREFIX = 20
# A home folder in a quoted path names the account that ran it; an excerpt
# goes to a public page. (The literals are split so the workstation-identity
Expand Down Expand Up @@ -255,9 +256,24 @@ def annotate(failed, write=print, title=FAILED_TITLE):
write(f"::error title={escape_property(UNANNOTATED_TITLE)}::{len(failed) - ANNOTATED_TESTS}")


# The `- Test:` line `new_issue` writes (`label_of`'s two forms). An issue
# carrying it was filed by this script and names its test whole.
FILED_TEST = re.compile(r'^- Test: `([^`\n]+)`(?: "(.*)")?$', re.M)


def tracks(issue, test):
"""Whether an open issue is about this test: its file and the start of its name appear in the body."""
"""Whether an open issue is about this test.

An issue this script filed names its test whole, so only that exact file
and name match: a renamed test, or a sibling that starts the same way,
opens an issue of its own. A hand-written issue quotes a title cut short
("Agent tabs shrink in stages..."), so it matches by the file and the
start of the name.
"""
body = issue.get("body") or ""
filed = FILED_TEST.search(body)
if filed:
return filed.groups() == ((test["file"], test["name"]) if test["file"] else (test["name"], None))
if test["file"] and test["file"] not in body:
return False
name = test["name"] if not test["file"] else test["name"].split(" > ")[-1][:MATCH_PREFIX]
Expand Down
33 changes: 33 additions & 0 deletions scripts/tests/test_ci_flaky_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,39 @@ def test_a_rust_test_is_tracked_by_its_whole_name(self):
self.assertTrue(r.tracks({"body": "`hide-platform::ipc a_burst` flakes"}, test))
self.assertFalse(r.tracks({"body": "`hide-platform::ipc another`"}, test))

FILE = "web/e2e/session-work-ledger.spec.ts"
LEDGER = "@platform a native session keeps its tasks and missed work through search"

def filed(self, file, name):
return {"body": r.new_issue({"file": file, "name": name, "error": ""}, "Linux", {"marker": "m", "run": "u", "change": "c", "sha": "s"}, TODAY)["body"]}

def test_an_issue_the_script_filed_tracks_only_the_test_it_names_whole(self):
issue = self.filed(self.FILE, self.LEDGER)
self.assertTrue(r.tracks(issue, {"file": self.FILE, "name": self.LEDGER, "error": ""}))

def test_a_sibling_that_starts_the_same_way_is_not_tracked_by_a_filed_issue(self):
issue = self.filed(self.FILE, self.LEDGER)
for name in ("@platform a native session also keeps its drafts", self.LEDGER + " off"):
self.assertFalse(r.tracks(issue, {"file": self.FILE, "name": name, "error": ""}), name)

def test_a_renamed_test_is_not_tracked_by_the_issue_of_its_old_title(self):
issue = self.filed(self.FILE, self.LEDGER)
renamed = {"file": self.FILE, "name": "@platform a native session's record groups its requests", "error": ""}
self.assertFalse(r.tracks(issue, renamed))

def test_a_filed_issue_of_another_file_is_not_tracked(self):
issue = self.filed("web/e2e/other.spec.ts", self.LEDGER)
self.assertFalse(r.tracks(issue, {"file": self.FILE, "name": self.LEDGER, "error": ""}))

def test_a_filed_rust_issue_does_not_track_a_test_whose_name_it_contains(self):
issue = self.filed(None, "hide-platform::ipc a_burst_more")
self.assertTrue(r.tracks(issue, {"file": None, "name": "hide-platform::ipc a_burst_more", "error": ""}))
self.assertFalse(r.tracks(issue, {"file": None, "name": "hide-platform::ipc a_burst", "error": ""}))

def test_a_hand_written_issue_still_tracks_a_test_by_file_and_start_of_name(self):
body = f"- Test: `{self.FILE}:62` › {self.LEDGER[:30]}... flakes"
self.assertTrue(r.tracks({"body": body}, {"file": self.FILE, "name": self.LEDGER, "error": ""}))


class Filing(unittest.TestCase):
def setUp(self):
Expand Down
Loading