Pulse/scripts/tests/test_e2e_workflow_contract.py
courtmanr@gmail.com 46fd0b713e Shard internal/api race tests and drop probation E2E from PRs
Across the last 25 bot PRs the median open to merge time was about 33
minutes for one PR and about 45 when three opened together. The critical
path was the required Backend tests (api) check, where one go test -race
./internal/api step took about 27 of its 31 minutes. Every other required
check finishes within about 12 minutes.

internal/api now runs as four Backend tests (api-N) shards. Each shard
lists the package's tests with go test -race -list from the commit under
test and runs one contiguous quarter of that list in go test's own order,
so every test, including ones added later, runs in exactly one shard, and
a shard that resolves no tests fails. The split is contiguous rather than
interleaved by name because some internal/api tests depend on package
state left by the tests just before them. A round-robin split by sorted
name failed dozens of tests locally (admin bypass and session store
globals), while the four contiguous slices and the full run all pass. A
Backend tests (api) verdict job keeps the required check name and fails
unless every shard succeeded. Backend tests (rest-0) and (rest-1) keep
their names and package split. Local non-race timings put the heaviest
slice at about 42 percent of the package, so the api check should drop
from about 31 minutes to roughly 14.

Core E2E no longer runs the non-gating probation tier on pull requests.
It could not gate a PR and the promotion rule counts only main runs, so
on a PR it only held each of the eight shard runners about eight minutes
longer, which fed the runner queueing seen with concurrent PRs. Push and
manual runs still execute it.

Go test steps still run for frontend-only changes. Go tests read
frontend sources directly (internal/api contract tests,
internal/unifiedresources walking frontend-modern/src, and the
internal/telemetry repository-wide wording scan), so skipping them by
path would drop real coverage.
2026-09-29 11:43:57 +01:00

37 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Guard the stable/probation Core E2E verdict boundary."""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
WORKFLOW = ROOT / ".github" / "workflows" / "test-e2e.yml"
class E2EWorkflowContractTest(unittest.TestCase):
def test_probation_failures_are_bounded_and_non_gating(self) -> None:
workflow = WORKFLOW.read_text()
probation_start = workflow.index(
"- name: Run probation-tier E2E suite (non-gating)"
)
report_start = workflow.index(
"- name: Report probation-tier outcome", probation_start
)
probation_step = workflow[probation_start:report_start]
self.assertIn("continue-on-error: true", probation_step)
# Non-gating and promotion counts only main runs, so PRs skip it.
self.assertIn("github.event_name != 'pull_request'", probation_step)
self.assertIn("timeout-minutes: 12", probation_step)
self.assertIn("--max-failures=5", probation_step)
self.assertIn("--global-timeout=600000", probation_step)
verdict_start = workflow.index("- name: Check E2E results")
verdict = workflow[verdict_start:]
self.assertNotIn("needs.probation", verdict)
self.assertNotIn("steps.probation", verdict)
if __name__ == "__main__":
unittest.main()