diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7a9478e8b..6cefbbbe6 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -499,6 +499,13 @@ jobs: # cold `cmd/bd` test compile in "Exercise generated Git hook timeout # process boundary" (250-300s); see S2 below (the restore-non-race-cache # step) for the fix that actually targets it. Reverted to one leg per OS. + # + # Windows leg budget with the caches warm (merge group 37710264475 and PR + # runs, 2026-10-07/08): 45-115s setup (setup-go, then the two cache + # restores, mostly tar extraction), 33-71s for TestPRPreflight (Git Bash + # process creation, now parallel subtests), 27-58s to compile and link + # ./cmd/bd's test binary, and about 25s for the rest. A second Windows leg + # would pay the setup again to save about 20s, so it stays one leg. pr-preflight-platforms: name: PR preflight process (${{ matrix.os }}) runs-on: ${{ matrix.runner }} @@ -565,24 +572,21 @@ jobs: GOCACHE: ${{ runner.temp }}/go-cache/non-race run: go test '-tags=gms_pure_go' -count=1 -run '^TestTestScriptPrebuiltBinaryContract$' ./scripts - - name: Exercise generated Git hook timeout process boundary - shell: bash - env: - GOCACHE: ${{ runner.temp }}/go-cache/non-race - run: go test '-tags=gms_pure_go' -count=1 -run '^TestGeneratedHookTimeoutProcessBoundary$' ./cmd/bd - - # Plain go test's own bd build fallback (BEADS_TEST_BD_BINARY unset), + # One go test of ./cmd/bd runs the generated hook timeout boundary and + # plain go test's own bd build fallback (BEADS_TEST_BD_BINARY unset), # which Bazel never takes, on every OS developers run go test on: the # tests tools/bazel/equivalence_allowlist.txt lists as skipped under - # Bazel. Same build as the step above, so no second compile. - - name: Exercise go test's bd build fallback + # Bazel. They were two steps; each go test of ./cmd/bd re-hashes its + # ~1500 packages and relinks the test binary, which cost 5-9s on + # Windows for a fallback run of under one second. + - name: Exercise generated Git hook timeout process boundary and go test's bd build fallback shell: bash env: GOCACHE: ${{ runner.temp }}/go-cache/non-race - run: go test '-tags=gms_pure_go' -count=1 -run '^(TestGOMODCACHENotUnderTestHome|TestGoBuildBDCommandIsCWDIndependent)$' ./cmd/bd + run: go test '-tags=gms_pure_go' -count=1 -run '^(TestGeneratedHookTimeoutProcessBoundary|TestGOMODCACHENotUnderTestHome|TestGoBuildBDCommandIsCWDIndependent)$' ./cmd/bd # This step recompiles ./cmd/bd's test binary. It must share the restored - # GOCACHE with the hook-timeout step above (same tags, same platform + # GOCACHE with the hook-timeout/bd-build-fallback step above (same tags, same platform # default CGO_ENABLED, see the script's header) so it is a relink rather # than a second cold compile: without GOCACHE here it fell back to the # runner's empty default cache and cold-compiled all of ./cmd/bd on every diff --git a/engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md b/engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md index 6d4f8f454..8bc7ebb4e 100644 --- a/engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md +++ b/engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md @@ -927,8 +927,9 @@ Required` requires them to have run remotely and passed. `tools/bazel/equivalence_allowlist.txt` holds only the two `cmd/bd` tests of plain `go test`'s own bd build fallback, which Bazel never - takes; `pr-preflight-platforms` runs them on every OS ("Exercise go - test's bd build fallback"). `TestBazelOnlySkipsAreAllowlisted` (under + takes; `pr-preflight-platforms` runs them on macOS and Windows + ("Exercise generated Git hook timeout process boundary and go test's bd + build fallback"). `TestBazelOnlySkipsAreAllowlisted` (under Bazel too) requires every top-level test with a `TEST_SRCDIR`- or `bazeltest.IsBazel()`-guarded `t.Skip` to have an allowlist `skip` entry, and no test anywhere to run part of its checks under `go test` diff --git a/scripts/ci/warm-non-race-cache.sh b/scripts/ci/warm-non-race-cache.sh index 51b5de8ff..9facc7fa1 100755 --- a/scripts/ci/warm-non-race-cache.sh +++ b/scripts/ci/warm-non-race-cache.sh @@ -28,3 +28,12 @@ go test -tags gms_pure_go -c -o /dev/null ./cmd/bd go test -tags gms_pure_go -c -o /dev/null ./scripts go test '-tags=integration,gms_pure_go' -c -o /dev/null ./scripts go test '-tags=integration,gms_pure_go' -c -o /dev/null ./scripts/gitattributespolicy + +# pr-preflight-platforms' Windows-only "Exercise credential command fixtures on +# Windows" step tests these with CGO_ENABLED=0, which the Windows runner's +# default (CGO_ENABLED=1, gcc on PATH) does not build. +if [[ "$(go env GOOS)" == windows ]]; then + for pkg in ./internal/testutil/credentialcmd ./internal/creds ./internal/storage/dolt; do + CGO_ENABLED=0 go test -tags gms_pure_go -c -o /dev/null "$pkg" + done +fi diff --git a/scripts/ci_workflow_test.go b/scripts/ci_workflow_test.go index 4878ba465..d3cdeab5b 100644 --- a/scripts/ci_workflow_test.go +++ b/scripts/ci_workflow_test.go @@ -616,8 +616,8 @@ func TestPRCIGateRequiresWindowsGlobalPrimeOverride(t *testing.T) { func TestPRCIGateRequiresGeneratedHookTimeoutProcessBoundary(t *testing.T) { const ( jobName = "pr-preflight-platforms" - stepName = "Exercise generated Git hook timeout process boundary" - stepCommand = "go test '-tags=gms_pure_go' -count=1 -run '^TestGeneratedHookTimeoutProcessBoundary$' ./cmd/bd" + stepName = "Exercise generated Git hook timeout process boundary and go test's bd build fallback" + stepCommand = "go test '-tags=gms_pure_go' -count=1 -run '^(TestGeneratedHookTimeoutProcessBoundary|TestGOMODCACHENotUnderTestHome|TestGoBuildBDCommandIsCWDIndependent)$' ./cmd/bd" gateKey = "PR_PREFLIGHT_PLATFORMS" ) diff --git a/scripts/pr_lanes_bazel_coverage_test.go b/scripts/pr_lanes_bazel_coverage_test.go index ecbd22c38..3983462d0 100644 --- a/scripts/pr_lanes_bazel_coverage_test.go +++ b/scripts/pr_lanes_bazel_coverage_test.go @@ -481,7 +481,7 @@ func TestPRRunsGoTestsBazelSkips(t *testing.T) { } // The allowlist's remaining skip entries run in pr-preflight-platforms // (every OS), each named in its go test selector. - fallback := pr.job(t, "pr-preflight-platforms").step(t, "Exercise go test's bd build fallback").Run + fallback := pr.job(t, "pr-preflight-platforms").step(t, "Exercise generated Git hook timeout process boundary and go test's bd build fallback").Run for _, line := range strings.Split(readPolicyFile(t, root, "tools/bazel/equivalence_allowlist.txt"), "\n") { body, _, _ := strings.Cut(line, "#") f := strings.Fields(body) diff --git a/scripts/pr_preflight_test.go b/scripts/pr_preflight_test.go index 1d5a9354b..f98882c46 100644 --- a/scripts/pr_preflight_test.go +++ b/scripts/pr_preflight_test.go @@ -95,6 +95,7 @@ type preflightRun struct { func TestPRPreflightSupportsGitHubCLIWithoutClosingIssuesReferences(t *testing.T) { t.Run("numeric lookup uses exact canonical GraphQL coordinates", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{}) if run.err != nil { t.Fatalf("pr-preflight failed with old gh field set: %v\n%s", run.err, run.output) @@ -137,6 +138,7 @@ func TestPRPreflightSupportsGitHubCLIWithoutClosingIssuesReferences(t *testing.T }) t.Run("canonical PR URL and zero count preserve warning behavior", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{ prArg: "https://github.com/octo/repo/pull/7", graphQLResponse: closingIssuesZero, @@ -226,6 +228,7 @@ func TestPRPreflightSupportsGitHubCLIWithoutClosingIssuesReferences(t *testing.T } for _, test := range tests { t.Run(test.name, func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, test.fixture) if exitCode(run.err) != 2 { t.Fatalf("exit = %d, want 2; error=%v\n%s", exitCode(run.err), run.err, run.output) @@ -318,6 +321,7 @@ func TestPRPreflightChecksUseLatestRunPerName(t *testing.T) { `]` t.Run("stale failures and cancellations are superseded by newer green runs", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{rollup: staleGreenRollup}) if !strings.Contains(run.output, "No failed or pending status checks reported.") { t.Fatalf("expected stale rollup entries to be superseded:\n%s", run.output) @@ -328,6 +332,7 @@ func TestPRPreflightChecksUseLatestRunPerName(t *testing.T) { }) t.Run("a genuinely failing latest run still blocks", func(t *testing.T) { + t.Parallel() freshRedRollup := `[` + `{"name":"CI Gate / Required","status":"COMPLETED","conclusion":"SUCCESS","completedAt":"2026-07-27T10:00:00Z"},` + `{"name":"CI Gate / Required","status":"COMPLETED","conclusion":"FAILURE","completedAt":"2026-07-28T10:00:00Z"}` + @@ -339,6 +344,7 @@ func TestPRPreflightChecksUseLatestRunPerName(t *testing.T) { }) t.Run("a commit status cannot supersede a same-named check run", func(t *testing.T) { + t.Parallel() // GitHub treats a check run and a commit status sharing a name as // independent required gates; both must pass. mixedRollup := `[` + @@ -352,6 +358,7 @@ func TestPRPreflightChecksUseLatestRunPerName(t *testing.T) { }) t.Run("identically named jobs in different workflows stay independent", func(t *testing.T) { + t.Parallel() crossWorkflowRollup := `[` + `{"__typename":"CheckRun","workflowName":"Main","name":"Test","status":"COMPLETED","conclusion":"FAILURE","completedAt":"2026-07-28T10:00:00Z"},` + `{"__typename":"CheckRun","workflowName":"Nightly","name":"Test","status":"COMPLETED","conclusion":"SUCCESS","completedAt":"2026-07-28T11:00:00Z"}` + @@ -363,6 +370,7 @@ func TestPRPreflightChecksUseLatestRunPerName(t *testing.T) { }) t.Run("an in-progress rerun with a zero completion time supersedes an old failure as pending", func(t *testing.T) { + t.Parallel() // gh exports absent CheckRun times as the Go zero time, not null. rerunRollup := `[` + `{"__typename":"CheckRun","workflowName":"Main","name":"CI","status":"COMPLETED","conclusion":"FAILURE","startedAt":"2026-07-27T09:00:00Z","completedAt":"2026-07-27T10:00:00Z"},` + @@ -396,6 +404,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { `]` t.Run("all failed across 3+ heads with 5+ decisive runs warns and names the workflow", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{baseRunList: greenBase, prGateRunList: sixRunsThreeHeadsAllFailed}) if run.err != nil { t.Fatalf("expected warn-only exit, got error: %v\n%s", run.err, run.output) @@ -407,6 +416,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("stays warn-only even under PR_PREFLIGHT_BLOCK_RED_BASE=1", func(t *testing.T) { + t.Parallel() // The warn-only property is the load-bearing one: mybd's pr-babysit // classifies any unrecognized [block] line as a genuine merge blocker // and parks merge lanes on it, and it withholds the base-fix @@ -426,6 +436,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("one success in the workflow's sample stays silent", func(t *testing.T) { + t.Parallel() mostlyFailedOneSuccess := strings.Replace(sixRunsThreeHeadsAllFailed, `"conclusion":"failure","headBranch":"branch-c","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T05:00:00Z"`, `"conclusion":"success","headBranch":"branch-c","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T05:00:00Z"`, 1) run := runPRPreflightWithFakeGH(t, preflightFixture{baseRunList: greenBase, prGateRunList: mostlyFailedOneSuccess}) if run.err != nil { @@ -437,6 +448,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("all failed but only 2 distinct heads stays silent", func(t *testing.T) { + t.Parallel() twoHeadsAllFailed := `[` + `{"conclusion":"failure","headBranch":"branch-a","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T10:00:00Z","url":"https://github.com/o/r/actions/runs/1"},` + `{"conclusion":"failure","headBranch":"branch-a","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T09:00:00Z","url":"https://github.com/o/r/actions/runs/2"},` + @@ -455,6 +467,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("empty sample stays silent", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{baseRunList: greenBase, prGateRunList: "[]"}) if run.err != nil { t.Fatalf("expected exit 0, got error: %v\n%s", run.err, run.output) @@ -465,6 +478,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("mixed workflows: only the all-red workflow fires, and it is named", func(t *testing.T) { + t.Parallel() mixedWorkflows := `[` + `{"conclusion":"success","headBranch":"branch-a","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T12:00:00Z","url":"https://github.com/o/r/actions/runs/201"},` + `{"conclusion":"success","headBranch":"branch-b","workflowName":"PR CI","workflowDatabaseId":101,"createdAt":"2026-07-28T11:30:00Z","url":"https://github.com/o/r/actions/runs/202"},` + @@ -488,6 +502,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("undetermined base health skips the sample", func(t *testing.T) { + t.Parallel() // With no decisive base runs at all, preflight has just warned that it // could not determine base health; diagnosing "red for every PR while // the base branch shows green" would contradict that line. @@ -501,6 +516,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("red base skips the sample even when a workflow would otherwise fire", func(t *testing.T) { + t.Parallel() redBaseRunList := `[{"conclusion":"failure","workflowName":"CI","createdAt":"2026-07-28T09:00:00Z","url":"https://github.com/o/r/actions/base-1"}]` run := runPRPreflightWithFakeGH(t, preflightFixture{ baseRunList: redBaseRunList, @@ -518,6 +534,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("unreadable/non-JSON sample stays silent", func(t *testing.T) { + t.Parallel() run := runPRPreflightWithFakeGH(t, preflightFixture{baseRunList: greenBase, prGateRunList: "gh: rate limit exceeded"}) if run.err != nil { t.Fatalf("expected exit 0, got error: %v\n%s", run.err, run.output) @@ -528,6 +545,7 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) t.Run("BASE_RUN_LIST positively drives the base-branch dispatch, not the PR-gate one", func(t *testing.T) { + t.Parallel() greenBaseRunList := `[{"conclusion":"success","workflowName":"CI","createdAt":"2026-07-28T12:00:00Z","url":"https://github.com/o/r/actions/base-2"}]` run := runPRPreflightWithFakeGH(t, preflightFixture{baseRunList: greenBaseRunList}) if run.err != nil { @@ -542,6 +560,13 @@ func TestPRPreflightPRGateHealthSample(t *testing.T) { }) } +// runPRPreflightWithFakeGH runs scripts/pr-preflight.sh once in its own temp +// dir, call log and environment, so callers that do not t.Setenv may run it +// from parallel subtests. They do: on Windows, Git Bash process creation makes +// each run cost about 1.5s, and the ~29 runs in this file used to take 42s of +// pr-preflight-platforms' Windows leg one after another (gastownhall/beads +// merge group 37710264475). TestPRPreflightFixtureIgnoresHostShellAndGitHubState +// stays serial because it rewrites the process environment. func runPRPreflightWithFakeGH(t *testing.T, fixture preflightFixture) preflightRun { t.Helper() diff --git a/tools/bazel/equivalence_allowlist.txt b/tools/bazel/equivalence_allowlist.txt index 374308a3b..e67a80a63 100644 --- a/tools/bazel/equivalence_allowlist.txt +++ b/tools/bazel/equivalence_allowlist.txt @@ -14,7 +14,7 @@ # Plain go test's own bd build fallback (BEADS_TEST_BD_BINARY unset), which # Bazel never takes (bd comes in through BEADS_TEST_BD_BINARY). pr.yml's -# pr-preflight-platforms runs both on Linux, macOS and Windows ("Exercise go -# test's bd build fallback"). +# pr-preflight-platforms runs both on macOS and Windows ("Exercise generated +# Git hook timeout process boundary and go test's bd build fallback"). cmd/bd TestGOMODCACHENotUnderTestHome skip # no in-test go build under Bazel; pr-preflight-platforms runs it cmd/bd TestGoBuildBDCommandIsCWDIndependent skip # no in-test go build under Bazel; pr-preflight-platforms runs it