ci: merge-queue readiness for the required gates; cache test results (fresh nightly) (#7264)

* ci: make the required gates merge-queue ready

The default-branch ruleset requires "CI Gate / Required" and "PR Risk
Gate / Required". Prepare both for a GitHub merge queue (ALLGREEN,
squash), so enabling the ruleset's merge_queue rule is the only step left.

- pr.yml, pr-risk.yml: merge_group pinned to types [checks_requested].
- D2: bazel-coverage covers every merge_group run (same repository, CI
  secrets, actor github-merge-queue[bot], bazel.yml mode remote), so the
  retired legacy tiers stay retired in the queue and ci-gate requires
  their Bazel lanes to have run remotely and passed; a missing secret or
  the farm switch off is red, as on a same-repo PR.
- Diff bases on merge_group: the package gates diff
  merge_group.base_sha..head_sha (not HEAD^, which misses all but the
  last commit of a rebase-method entry), the .beads/issues.jsonl guard
  now runs on merge_group against base_sha (ci-gate no longer excuses
  its skip), and check-doc-flags passes BD_DOCS_DIFF_BASE so CLI-docs
  drift already on main cannot eject every queued PR.
- Test result reuse: on a merge_group run and on attempt 2+ of a PR run,
  the six always-execute Bazel lanes append --config=reuse-test-results
  (--cache_test_results=auto), so tests whose action key is unchanged
  reuse the farm's recorded PASS and only what the merge changed runs.
  Failures are never reused, eviction retries stay 0, and each PR's first
  attempt, push to main and nightly still execute every test.
- scripts/ci_merge_queue_test.go simulates merge_group through the shared
  evalGHExpr evaluator (now with true/false/null literals, hyphenated
  identifiers and case-insensitive ==) and the workflows' own scripts:
  triggers and gate names, concurrency groups, every pull_request field
  read, the coverage and rbe decisions, result reuse, the package-gate,
  .beads and doc-drift diff bases.
- engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md: new "Merge Queue" section (how
  to queue, settings, what runs, result reuse rationale, ejection and
  flakes, rollback).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci: cache Bazel test results except nightly; queue trust and sizing

Review follow-ups to the merge-queue readiness change.

- Test results (S1): --nocache_test_results also stops Bazel writing
  results, so a PR's first run never fed the cache and the merge-queue
  reuse config could only hit on later reuse runs. Drop it from
  test:embedded, test:doltserver-proxied, test:doltserver-integration and
  test:sole-run (which keeps --experimental_remote_cache_eviction_retries=0),
  and drop test:reuse-test-results and BAZEL_REUSE_RESULTS. Results are now
  cached (read and write) on PRs, merge groups and pushes to main.
  nightly.yml passes the new fresh-test-results input, so every `bazel
  test` appends --config=fresh (--nocache_test_results) and the suite
  re-executes nightly. The docker lane keeps --nocache_test_results.
  Measured locally with a disk cache: a default run writes and the next
  reads ("(cached) PASSED"); a fresh run neither reads nor writes.
- Security headers (S2): bazel.yml now states that a merge_group run
  executes the queued commit's workflows, so a queued fork or Dependabot
  PR's CI edits run with every CI secret, the pre-warm app key included
  (merging-level trust), and records the maintainer rule: review fork
  changes to .github/, .bazelrc, tools/bazel, MODULE.bazel, BUILD files
  and CI scripts before queueing. Same note in the topology doc.
- Queue sizing (S3): recommend max_entries_to_build 3 and
  check_response_timeout_minutes 60 (max_entries_to_merge 5, ALLGREEN,
  SQUASH unchanged).
- Nits: the .beads guard fails closed on a missing diff base, and its
  test runs under GitHub's default `bash -e`; evalGHExpr follows GitHub's
  loose equality (true == 'true' is false, false == '' is true, missing
  context keys are null) with a typed-context variant; the
  detect-package-gates comment notes the SQUASH/HEAD^ equivalence and
  path-filter scope; the doc covers re-run reuse, flake re-sampling via
  dispatch, stale queue runs and how to confirm reuse on the farm.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen 2026-10-05 13:54:15 -07:00 • committed by GitHub
commit e72cd8b315
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1231 additions and 213 deletions

View file

@ -99,11 +99,9 @@ test:embedded --test_arg=-test.parallel=4
test:embedded --test_env=GO_TEST_WRAP_TESTV=1
test:embedded --remote_download_regex=.*/test\.xml$
# Since D2 step 1 this lane is the tier's only pre-merge run on same-repo PRs
# (pr-risk.yml's legacy jobs stand down), and the legacy jobs ran every test
# every time (-test.count=1). A cached PASS would let a stale or poisoned
# farm action-cache entry, or an unreproduced -race finding, stand in for a
# run: always execute, at farm (not runner) cost.
test:embedded --nocache_test_results
# (pr-risk.yml's legacy jobs stand down). Its results are cached like every
# lane's: an unchanged test reuses its recorded PASS, and nightly re-executes
# everything (--config=fresh below).
# No whole-invocation retry on a remote cache eviction ("Lost inputs"):
# Bazel would re-run every test, and a test that failed in the first
# attempt but passes in the retry would report green, unlike the legacy
@ -159,9 +157,7 @@ test:doltserver-proxied --test_arg=-test.parallel=4
test:doltserver-proxied --local_test_jobs=4
test:doltserver-proxied --remote_download_regex=.*/test\.(log|xml)$
# Since D2 step 2 this lane is the tier's only pre-merge run on same-repo
# PRs: execute every time, like the jobs' -test.count=1, never replay a
# cached result.
test:doltserver-proxied --nocache_test_results
# PRs. Results are cached like every lane's (nightly: --config=fresh).
# No whole-invocation retry on a remote cache eviction ("Lost inputs"):
# Bazel would re-run every test, and a test that failed in the first
# attempt but passes in the retry would report green, unlike the legacy
@ -196,9 +192,7 @@ test:doltserver-integration --test_arg=-test.parallel=4
test:doltserver-integration --local_test_jobs=4
test:doltserver-integration --remote_download_regex=.*/test\.(log|xml)$
# Since D2 step 2 this lane is the tier's only pre-merge run on same-repo
# PRs: execute every time, like the jobs' -test.count=1, never replay a
# cached result.
test:doltserver-integration --nocache_test_results
# PRs. Results are cached like every lane's (nightly: --config=fresh).
# No whole-invocation retry on a remote cache eviction ("Lost inputs"):
# Bazel would re-run every test, and a test that failed in the first
# attempt but passes in the retry would report green, unlike the legacy
@ -301,19 +295,37 @@ build:js-wasm --use_target_platform_for_tests
build:js-wasm --remote_download_outputs=toplevel
# D2 step 3: bazel.yml's bazel-test, bazel-pure and bazel-doltserver lanes
# add this in mode remote only, where (on same-repo PRs) they are the only
# pre-merge run of pr.yml's legacy PR Core, pure-Go/js-wasm, domain+uow and
# contract corpus jobs, which ran every test every time (`go test
# -count=1`) and never retried. Like the retired PR Risk tiers' configs:
# always execute (a cached PASS would stand in for a run), and no
# whole-invocation retry after a remote cache eviction ("Lost inputs"),
# whose exit code outranks a test failure, so a test that failed in the
# first attempt and passed in the retry would report green. Local and
# cache runs (forks, Dependabot; their legacy jobs still run) keep cached
# results.
test:sole-run --nocache_test_results
# add this in the remote modes, where (on same-repo PRs and merge groups)
# they are the only pre-merge run of pr.yml's legacy PR Core,
# pure-Go/js-wasm, domain+uow and contract corpus jobs, which never retried.
# Like the retired PR Risk tiers' configs: no whole-invocation retry after
# a remote cache eviction ("Lost inputs"), whose exit code outranks a test
# failure, so a test that failed in the first attempt and passed in the
# retry would report green.
test:sole-run --experimental_remote_cache_eviction_retries=0
# Test result caching. Every lane but docker caches its test results (read
# and write; Bazel's default): a test whose action key (test binary,
# runfiles, test env, platform) is unchanged reuses the PASS the farm
# recorded for it, on a PR (any attempt), a merge group or a push to main,
# so only what a change touched runs. Why that is safe:
# - Identical key, identical test: these targets are hermetic (dolt and
# every input are runfiles). The docker lane depends on host state no
# key sees and keeps --nocache_test_results above.
# - A cached failure is never reused: Bazel treats a failed cached action
# as a miss, so whatever failed re-runs.
# - Only rbe-west's workers write the action cache (clients' writes are
# refused), so a cached PASS is a real remote execution, not a client
# upload.
# - What is given up is re-sampling a nondeterministic (-race, timing)
# test on unchanged inputs. nightly.yml passes fresh-test-results: true,
# so bazel.yml appends this config last to every `bazel test` and the
# whole suite re-executes once a night.
# - No retries: --experimental_remote_cache_eviction_retries=0 (the
# retired tiers' configs and sole-run) and no flaky attempts anywhere.
# Policy: scripts/ci_merge_queue_test.go.
test:fresh --nocache_test_results
# Read-only anonymous cache for fork PRs: rbe-west's rbe-cache endpoint serves
# action-cache and CAS reads only (writes and Execute are refused by the farm)
# and needs no credentials, so it is committed (scripts/bazel_policy_test.go

View file

@ -9,8 +9,8 @@
# except where their D2 flag retires them: while the committed
# BAZEL_RETIRES_LEGACY_EMBEDDED / BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS /
# BAZEL_RETIRES_LEGACY_PR_LANES flag is "true", on a same-repo,
# non-Dependabot pull_request (whatever the mode), the bazel-coverage job
# stands down pr-risk.yml's embedded-Dolt test jobs (bazel-embedded runs
# non-Dependabot pull_request or a merge_group run (whatever the mode), the
# bazel-coverage job stands down pr-risk.yml's embedded-Dolt test jobs (bazel-embedded runs
# the tier), its proxied-server and server-Dolt storage test jobs
# (bazel-proxied, bazel-server-storage), or pr.yml's PR Core,
# build-artifacts, pure-Go/js-wasm, domain+uow and contract corpus jobs
@ -18,6 +18,14 @@
# --config=sole-run); pr.yml's ci-gate then requires those lanes to have run
# remotely and passed, so modes skip, local and cache are red there
# (scripts/pr_risk_bazel_coverage_test.go, pr_lanes_bazel_coverage_test.go).
# Test results are cached (read and written) on every run but nightly's: a
# test whose action key is unchanged reuses the PASS the farm recorded for
# it, on a PR, a merge group (merge queue) or a push to main alike, and only
# what changed runs. nightly.yml passes fresh-test-results: true, so every
# `bazel test` here appends --config=fresh (BAZEL_FRESH below;
# --nocache_test_results) and re-executes every test once a night, which
# keeps sampling flaky and -race failures. A cached failure is never reused.
# Policy: scripts/ci_merge_queue_test.go.
# This file has no pull_request or merge_group trigger of its own, so a PR
# runs the lane once. Every lane reports its job.status as a workflow_call
# output (named after the job) from an always() last step. pr.yml's ci-gate
@ -111,9 +119,18 @@
# by every later step and by locally executed Bazel actions, and a .bazelrc
# edit can point the BEP or the executor anywhere. Anyone who can push a
# branch here can therefore use or copy the certificate and write to the
# farm's cache. Fork PRs never get it, except those bazel-farm.yml
# authorizes (allowlisted author and sender, accepted as same-repo-level
# trust; that workflow's header lists what it adds): pull_request from a
# farm's cache. Fork PRs never get it on their own runs, except those
# bazel-farm.yml authorizes (allowlisted author and sender, accepted as
# same-repo-level trust; that workflow's header lists what it adds), and
# except once queued: a merge_group run loads every workflow file and
# script from the queue entry's commit, so a fork (or Dependabot) PR that a
# maintainer queues runs its own edits to .github/, .bazelrc, tools/bazel,
# MODULE.bazel, BUILD files and CI scripts with all CI secrets, the
# pre-warm app key included, even if the entry is later ejected. That is
# the trust of merging it (push to main would run the same code), so the
# maintainer rule is: review a fork PR's changes to those paths before
# queueing it, as before merging (engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md,
# "Merge Queue"). Otherwise: pull_request from a
# fork receives no secrets, bazel-farm.yml is the only pull_request_target
# caller (policy-tested), and forks cannot write the runner cache. Nor do
# Dependabot PRs, which run as same-repo but get no Actions secrets. Fork
@ -141,7 +158,11 @@
# runs - the only contexts that ever receive RBE_POOL_APP_PRIVATE_KEY - each
# reach that shared key for the duration of the mint step alone (nothing
# executes from the checked-out repository tree while it, or the token it
# produces, is in scope: see the rbe-prewarm job below). Unlike the RBE
# produces, is in scope: see the rbe-prewarm job below). That holds only for
# this file as committed: a merge_group run uses the queued commit's copy,
# so a queued fork PR that edits this job (or pr.yml) reaches the key with
# whatever it wrote. Queueing a fork PR is therefore merging-level trust;
# review its .github/ changes first (see the header above). Unlike the RBE
# client certificate above, this key cannot be rotated or revoked for beads
# alone without also breaking gascity's scaler; the kill switch
# (RBE_POOL_APP_PRIVATE_KEY unset, or RBE_PREWARM_WORKERS=0) disables
@ -159,7 +180,8 @@
# remote cache, and local runs would need about 7 GB more.
#
# Workflow-file changes suppress pull_request runs under the org approval
# policy; validate edits to this file with workflow_dispatch on the branch.
# policy (merge_group runs are not suppressed: they run the queued copy);
# validate edits to this file with workflow_dispatch on the branch.
name: Bazel
on:
@ -184,6 +206,11 @@ on:
type: choice
default: "doltserver"
options: [ "doltserver", "docker" ]
fresh-test-results:
description: "Re-execute every test (--config=fresh: no cached test results), as nightly does"
required: false
type: boolean
default: false
workflow_call:
inputs:
rbe:
@ -228,6 +255,16 @@ on:
type: boolean
required: false
default: false
# true (nightly.yml only): every `bazel test` re-executes every test
# (--config=fresh), the run that samples flaky and -race failures.
# Everyone else reuses cached results for unchanged tests. A boolean:
# null on push, so push to main reuses too.
fresh-test-results:
description: >
true (nightly.yml) re-executes every test: no cached test results.
type: boolean
required: false
default: false
build-artifact-name:
description: >
Name of the uploaded bd artifact (ci-build-artifacts layout). pr.yml
@ -290,9 +327,12 @@ on:
# request it, but no caller ever does: pr.yml and nightly.yml pass it
# straight through (both are same-repo/trusted triggers only);
# bazel-farm.yml's pull_request_target call does not, so no pre-warm
# credential ever reaches a fork-authored run (B1, security review of
# bdef342d5 - accepted risk is same-repo runs reaching the shared
# gascity scaler key, not forks). See
# credential reaches a fork-authored run before a maintainer queues
# it (B1, security review of bdef342d5 - accepted risk is same-repo
# runs reaching the shared gascity scaler key, not forks). Exception:
# a merge_group run executes the queued commit's workflows, so a
# queued fork PR's edits run with this key (merging-level trust; see
# the header). See
# engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md, "rbe-west Pre-warm".
RBE_POOL_APP_PRIVATE_KEY:
required: false
@ -354,6 +394,11 @@ permissions:
env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
# Appended last to every `bazel test` (after the lane's config and
# sole-run): --config=fresh (.bazelrc, --nocache_test_results) only when
# the caller asks for fresh results (nightly.yml, or a dispatch); empty
# otherwise, so results are cached and reused. See the header.
BAZEL_FRESH: ${{ inputs.fresh-test-results && '--config=fresh' || '' }}
# Phase B report-only budget for T1/T2 (tools/bazel/critpath.py).
BAZEL_BUDGET_SECONDS: "420"
@ -554,7 +599,10 @@ jobs:
# above): every byte this step executes comes from this workflow
# definition, which pull_request_target always loads from the base
# branch and which editing suppresses pull_request runs under the
# org's approval policy (see the header). steps.mint.outputs.token
# org's approval policy (see the header). Not on merge_group: a queue
# entry runs its own commit's copy of this file with no approval
# gate, so a queued fork PR's edit here runs with the key (review
# .github/ changes before queueing). steps.mint.outputs.token
# appears nowhere else in this file (policy-tested): this is the only
# step with the credential in its environment, and no step after it
# touches a repository path or runs a local composite action.
@ -648,13 +696,13 @@ jobs:
outputs:
result: ${{ steps.result.outputs.result }}
env:
# D2 step 3: on covered PRs (always mode remote) this lane is the only
# pre-merge run of pr.yml's legacy PR Core job, which ran every test
# every time and never retried: --config=sole-run then executes every
# test (no cached results) and fails on a remote cache eviction
# instead of re-running the whole invocation. Fork modes do the same
# (with BAZEL_COVERS_FORKS "true" it is their only run too). Local and
# cache runs (the legacy jobs still run) keep cached results.
# D2 step 3: on covered PRs and merge groups (always mode remote) this
# lane is the only pre-merge run of pr.yml's legacy PR Core job, which
# never retried: --config=sole-run then fails on a remote cache eviction
# instead of re-running the whole invocation (whose retry could turn a
# failed test green). Fork modes do the same (with BAZEL_COVERS_FORKS
# "true" it is their only run too). Test results are cached and reused
# like every lane's; only nightly re-executes them all (BAZEL_FRESH).
BAZEL_SOLE_RUN: ${{ needs.rbe.outputs.enabled == 'true' && '--config=sole-run' || '' }}
steps:
# inputs.checkout-sha: see the header (empty: the event's default ref).
@ -730,7 +778,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=ci ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} \
bazel test //... --config=ci ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--profile="$RUNNER_TEMP/bazel-profile.json" \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
@ -895,13 +943,14 @@ jobs:
result: ${{ steps.result.outputs.result }}
env:
PURE_CMD_BD_TESTS: '^Test(Help|CheckRemoteSafety|FormatDestroyToken|ShouldWireInitRemote|ExtractPrefix|IsNumericID|GetWorktreeGitDir|DriftItemStatuses|RunDriftChecks|IsServerProbablyRunning|CheckHooksDriftNotGitRepo|CheckServerDriftNoBeadsDir|CheckRemoteDriftNoBeadsDir|NocgoFactoriesHonorSharedServer|NocgoNewDoltStoreFromConfig_ErrorSuggestsCorrectFlag|NocgoNewReadOnlyStoreFromConfig_ErrorSuggestsCorrectFlag)'
# D2 step 3: on covered PRs (always mode remote) this lane is the only
# pre-merge run of pr.yml's legacy pure-Go and js/wasm job, which ran every test
# every time and never retried: --config=sole-run then executes every
# test (no cached results) and fails on a remote cache eviction
# instead of re-running the whole invocation. Fork modes do the same
# (with BAZEL_COVERS_FORKS "true" it is their only run too). Local and
# cache runs (the legacy jobs still run) keep cached results.
# D2 step 3: on covered PRs and merge groups (always mode remote) this
# lane is the only pre-merge run of pr.yml's legacy pure-Go and js/wasm
# job, which never retried: --config=sole-run then fails on a remote
# cache eviction instead of re-running the whole invocation (whose retry
# could turn a failed test green). Fork modes do the same (with
# BAZEL_COVERS_FORKS "true" it is their only run too). Test results are
# cached and reused like every lane's; only nightly re-executes them all
# (BAZEL_FRESH).
BAZEL_SOLE_RUN: ${{ needs.rbe.outputs.enabled == 'true' && '--config=sole-run' || '' }}
steps:
# inputs.checkout-sha: see the header (empty: the event's default ref).
@ -1000,7 +1049,7 @@ jobs:
run: |
set -euo pipefail
bazel run --config=pure //cmd/bd:bd -- version
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} \
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
//internal/storage/embeddeddolt:embeddeddolt_test \
//internal/tracker:tracker_test \
--test_sharding_strategy=disabled \
@ -1012,7 +1061,7 @@ jobs:
- name: Run pure-Go cmd/bd test subset (--config=pure)
run: |
set -euo pipefail
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} //cmd/bd:bd_test \
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} //cmd/bd:bd_test \
--test_sharding_strategy=disabled \
"--test_arg=-test.run=$PURE_CMD_BD_TESTS"
n="$(grep -c '<testcase ' bazel-testlogs/cmd/bd/bd_test/test.xml || true)"
@ -1130,7 +1179,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=embedded \
bazel test //... --config=embedded ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=embedded: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
@ -1273,7 +1322,7 @@ jobs:
if [[ -n "$EXCLUDE_TARGETS" ]]; then
echo "bazel-cmd-dolt is required: excluding $EXCLUDE_TARGETS (it runs there)" | tee -a "$GITHUB_STEP_SUMMARY"
fi
bazel test //... --config=integration \
bazel test //... --config=integration ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
${EXCLUDE_TARGETS:+-- "$EXCLUDE_TARGETS"} \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
@ -1328,13 +1377,14 @@ jobs:
result: ${{ steps.result.outputs.result }}
env:
BAZEL_DOLT_LANE: ${{ inputs.dolt-lane || 'doltserver' }}
# D2 step 3: on covered PRs (always mode remote) this lane is the only
# pre-merge run of pr.yml's legacy domain+uow and contract corpus jobs, which ran every test
# every time and never retried: --config=sole-run then executes every
# test (no cached results) and fails on a remote cache eviction
# instead of re-running the whole invocation. Fork modes do the same
# (with BAZEL_COVERS_FORKS "true" it is their only run too). Local and
# cache runs (the legacy jobs still run) keep cached results.
# D2 step 3: on covered PRs and merge groups (always mode remote) this
# lane is the only pre-merge run of pr.yml's legacy domain+uow and
# contract corpus jobs, which never retried: --config=sole-run then
# fails on a remote cache eviction instead of re-running the whole
# invocation (whose retry could turn a failed test green). Fork modes do
# the same (with BAZEL_COVERS_FORKS "true" it is their only run too).
# Test results are cached and reused like every lane's; only nightly
# re-executes them all (BAZEL_FRESH).
BAZEL_SOLE_RUN: ${{ needs.rbe.outputs.enabled == 'true' && '--config=sole-run' || '' }}
steps:
# inputs.checkout-sha: see the header (empty: the event's default ref).
@ -1373,7 +1423,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... "--config=$BAZEL_DOLT_LANE" ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
bazel test //... "--config=$BAZEL_DOLT_LANE" ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=$BAZEL_DOLT_LANE: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
exit "$rc"
@ -1499,7 +1549,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=doltserver-proxied \
bazel test //... --config=doltserver-proxied ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=doltserver-proxied: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
@ -1610,7 +1660,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=doltserver-integration \
bazel test //... --config=doltserver-integration ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=doltserver-integration: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
@ -1722,7 +1772,7 @@ jobs:
set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=doltserver-cmd \
bazel test //... --config=doltserver-cmd ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=doltserver-cmd: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
@ -1790,8 +1840,8 @@ jobs:
- name: Decide applicability
id: detect
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
PUSH_AFTER_SHA: ${{ github.sha }}
run: ./scripts/ci/detect-package-gates.sh
@ -1909,8 +1959,8 @@ jobs:
- name: Decide applicability
id: detect
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
PUSH_AFTER_SHA: ${{ github.sha }}
run: ./scripts/ci/detect-package-gates.sh

View file

@ -115,6 +115,10 @@ jobs:
with:
details: true
go-test-json-artifact: bazel-equivalence-go-test-json
# The one run that re-executes every test (no cached test results):
# PRs, merge groups and pushes to main reuse unchanged tests' PASSes,
# so this keeps sampling flaky and -race failures every night.
fresh-test-results: true
full-test:
name: Full Test Suite

View file

@ -3,7 +3,15 @@ name: PR Risk
on:
pull_request:
branches: [ main, 'release/**', 'hotfix/**' ]
# Merge queue (engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md, "Merge Queue"):
# the ruleset's required gate must also report on each queue entry's
# merge-group commit, or a queued PR waits until the queue times it out.
# checks_requested is the queue asking for those checks; pinned
# explicitly (scripts/ci_merge_queue_test.go). The concurrency group
# below keys a merge group on its own gh-readonly-queue/* ref, so queue
# runs never cancel each other or a PR's own runs.
merge_group:
types: [ checks_requested ]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
@ -13,7 +21,7 @@ env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
# D2: "true" retires a PR Risk legacy tier on same-repo, non-Dependabot
# pull_requests; pr.yml's gated Bazel lane(s) for it are then the tier's
# pull_requests and on merge groups (merge queue); pr.yml's gated Bazel lane(s) for it are then the tier's
# only pre-merge run, and pr.yml's gate goes red unless they ran remotely
# and passed. Committed, not repo variables, so a re-run can never change
# them; each must equal pr.yml's / pr-risk.yml's copy
@ -94,13 +102,15 @@ jobs:
# test-server-storage* jobs; Bazel `proxied-server tier` and `server-Dolt
# storage tier`), plus `pr_lanes`, which only pr.yml reads (its own PR
# Core, build-artifacts, pure-Go, domain+uow and contract corpus jobs).
# Each is true only with its committed BAZEL_RETIRES_LEGACY_* flag, on a same-repo (not fork) pull_request whose actor is not
# Dependabot. pr.yml runs this same job (policy-tested identical) and its
# gate goes red unless the lanes then ran remotely and passed, so neither
# the kill switch (mode skip) nor a missing executor secret (mode cache)
# can silently drop a tier. Forks and Dependabot (no secrets), merge_group
# and every other event keep the legacy tiers. The step reads no secret or
# variable and runs no repository code.
# Each is true only with its committed BAZEL_RETIRES_LEGACY_* flag, on a
# same-repo (not fork) pull_request whose actor is not Dependabot, or on a
# merge_group (merge queue) run. pr.yml runs this same job (policy-tested
# identical) and its gate goes red unless the lanes then ran remotely and
# passed, so neither the kill switch (mode skip) nor a missing executor
# secret (mode cache) can silently drop a tier. Forks and Dependabot (no
# secrets; unless BAZEL_COVERS_FORKS) and every other event keep the
# legacy tiers. The step reads no secret or variable and runs no
# repository code.
bazel-coverage:
name: Bazel tier coverage
# F3: same-repo PRs and merge_group get the org's Blacksmith pool; forks,
@ -135,10 +145,11 @@ jobs:
RETIRED_PR_LANES: ${{ env.BAZEL_RETIRES_LEGACY_PR_LANES == 'true' }}
COVERS_FORKS: ${{ env.BAZEL_COVERS_FORKS == 'true' }}
PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
FORK: ${{ github.event.pull_request.head.repo.fork == true }}
DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }}
run: |
for v in RETIRED_EMBEDDED RETIRED_DOLT_SERVER RETIRED_PR_LANES COVERS_FORKS PULL_REQUEST FORK DEPENDABOT; do
for v in RETIRED_EMBEDDED RETIRED_DOLT_SERVER RETIRED_PR_LANES COVERS_FORKS PULL_REQUEST MERGE_GROUP FORK DEPENDABOT; do
case "${!v}" in
true|false) ;;
*) echo "::error::$v is '${!v}', want true or false"; exit 1 ;;
@ -146,9 +157,16 @@ jobs:
done
# Covered: the Bazel lanes are this run's only run of the retired
# tiers. Same-repo PRs (the CI secrets); fork and Dependabot PRs
# too while BAZEL_COVERS_FORKS is "true".
# too while BAZEL_COVERS_FORKS is "true"; and every merge group: it
# runs on the queue's gh-readonly-queue/* branch of this repository
# with the CI secrets, its actor is github-merge-queue[bot] (never
# Dependabot), and bazel.yml's rbe job takes mode remote for it
# like for a same-repo PR, so a missing secret or the farm switch
# off turns pr.yml's gate red rather than dropping a tier.
covered=false
if [ "$PULL_REQUEST" = true ]; then
if [ "$MERGE_GROUP" = true ]; then
covered=true
elif [ "$PULL_REQUEST" = true ]; then
if [ "$FORK" = false ] && [ "$DEPENDABOT" = false ]; then
covered=true
elif [ "$COVERS_FORKS" = true ]; then
@ -172,7 +190,7 @@ jobs:
echo "dolt_server=$dolt_server"
echo "pr_lanes=$pr_lanes"
} >> "$GITHUB_OUTPUT"
echo "Legacy tiers retired in favour of the Bazel lanes: embedded Dolt **$embedded**, proxied and server Dolt **$dolt_server**, pr.yml's PR Core/build/pure-Go/domain+uow/contract jobs **$pr_lanes** (pull_request: $PULL_REQUEST, fork: $FORK, dependabot: $DEPENDABOT, forks covered: $COVERS_FORKS, retired embedded: $RETIRED_EMBEDDED, retired proxied/server: $RETIRED_DOLT_SERVER, retired pr.yml jobs: $RETIRED_PR_LANES)" | tee -a "$GITHUB_STEP_SUMMARY"
echo "Legacy tiers retired in favour of the Bazel lanes: embedded Dolt **$embedded**, proxied and server Dolt **$dolt_server**, pr.yml's PR Core/build/pure-Go/domain+uow/contract jobs **$pr_lanes** (pull_request: $PULL_REQUEST, merge_group: $MERGE_GROUP, fork: $FORK, dependabot: $DEPENDABOT, forks covered: $COVERS_FORKS, retired embedded: $RETIRED_EMBEDDED, retired proxied/server: $RETIRED_DOLT_SERVER, retired pr.yml jobs: $RETIRED_PR_LANES)" | tee -a "$GITHUB_STEP_SUMMARY"
# End-to-end coverage for proxied-server CLI subcommands, sharded across the
# CI matrix. Each sub-test drives the bd CLI subprocess against a real dolt

View file

@ -6,7 +6,15 @@ on:
# the release branch, not on main. Without it they run almost no CI and the
# first full signal is the tag build, where a failure burns the tag.
branches: [ main, 'release/**', 'hotfix/**' ]
# Merge queue (engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md, "Merge Queue"):
# the ruleset's required gate must also report on each queue entry's
# merge-group commit, or a queued PR waits until the queue times it out.
# checks_requested is the queue asking for those checks; pinned
# explicitly (scripts/ci_merge_queue_test.go). The concurrency group
# below keys a merge group on its own gh-readonly-queue/* ref, so queue
# runs never cancel each other or a PR's own runs.
merge_group:
types: [ checks_requested ]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
@ -16,7 +24,7 @@ env:
BD_DISABLE_METRICS: "1"
BD_DISABLE_EVENT_FLUSH: "1"
# D2: "true" retires a PR Risk legacy tier on same-repo, non-Dependabot
# pull_requests; pr.yml's gated Bazel lane(s) for it are then the tier's
# pull_requests and on merge groups (merge queue); pr.yml's gated Bazel lane(s) for it are then the tier's
# only pre-merge run, and pr.yml's gate goes red unless they ran remotely
# and passed. Committed, not repo variables, so a re-run can never change
# them; each must equal pr.yml's / pr-risk.yml's copy
@ -69,7 +77,8 @@ env:
jobs:
# D2 step 3: stands down where bazel-coverage says pr_lanes (same-repo,
# non-Dependabot PRs while BAZEL_RETIRES_LEGACY_PR_LANES is "true"): its
# non-Dependabot PRs and merge groups while BAZEL_RETIRES_LEGACY_PR_LANES
# is "true"): its
# consumers then stand down too. F3: the package gates (package-mcp,
# package-npm) are no longer among those consumers - they moved into
# bazel.yml and build their own bd (Bazel-built on same-repo PRs, `go
@ -204,15 +213,23 @@ jobs:
run: ./scripts/check-migration-hygiene.sh
# Fast check to catch accidental .beads/issues.jsonl changes from
# contributors. pull_request-only, same as before the fold: merge_group
# has no base_ref to diff against, so the step (and therefore this
# token) is skipped there, and merge_group's CI_GATE_SKIPPED_OK
# allow-lists exactly that skip below.
# contributors. Runs on both PR triggers: a pull_request diffs against
# origin/<base branch> (GITHUB_BASE_REF), a merge group (which has no
# base_ref) against the queue's merge_group.base_sha, the commit the
# group's head is built on (fetch-depth 0 above fetches it).
- name: Check for .beads/issues.jsonl changes
id: no-beads-changes
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
if: ${{ !cancelled() }}
env:
MERGE_GROUP_BASE_SHA: ${{ github.event.merge_group.base_sha }}
run: |
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "^\.beads/issues\.jsonl$"; then
base="${MERGE_GROUP_BASE_SHA:-origin/${GITHUB_BASE_REF:-main}}"
# Fail closed: a pipe into grep -q would pass on a failed diff.
if ! git rev-parse --verify --quiet "$base^{commit}" >/dev/null; then
echo "::error::diff base $base is unavailable"
exit 1
fi
if git diff --name-only "$base"...HEAD | grep -q "^\.beads/issues\.jsonl$"; then
echo "This PR includes changes to .beads/issues.jsonl"
echo ""
echo "This file is the project's issue database and should not be modified in PRs."
@ -854,6 +871,12 @@ jobs:
- name: Validate docs against CLI
env:
DOC_DRIFT_PATCH_OUT: ${{ runner.temp }}/cli-docs-freshness.patch
# Merge queue: a merge group has no GITHUB_BASE_REF, and without a
# diff base check-cli-docs-drift.sh fails on any drift, including
# drift already on main that the PR run attributed away, which
# would eject every queued PR. Diff against the queue's base
# commit instead (empty on pull_request: origin/$GITHUB_BASE_REF).
BD_DOCS_DIFF_BASE: ${{ github.event.merge_group.base_sha }}
run: |
./scripts/check-doc-flags.sh ./bd
./scripts/check-doc-freshness.sh
@ -2270,8 +2293,8 @@ jobs:
# (PR Core, build-artifacts, the pure-Go/js-wasm check, domain+uow and
# contract corpus, and pr-risk.yml's embedded-Dolt, proxied-server and
# server-Dolt storage tiers), all of which stay required ids, but stand
# down on same-repo PRs with a non-Dependabot actor while their D2 flag
# is "true" (bazel-coverage): pr-risk.yml's embedded-Dolt test jobs
# down on same-repo PRs with a non-Dependabot actor, and on merge groups,
# while their D2 flag is "true" (bazel-coverage): pr-risk.yml's embedded-Dolt test jobs
# (BAZEL_RETIRES_LEGACY_EMBEDDED, step 1), its proxied-server and
# server-Dolt storage test jobs (BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS,
# step 2), and this workflow's PR Core, build-artifacts, pure-Go/js-wasm,
@ -2285,8 +2308,10 @@ jobs:
# proxied or server-storage lane) or skip, and exports that for ci-gate.
# Its bazel-integration lane (main.yml's integration jobs, which run only
# on push to main) is on and required here in modes remote and cache:
# same-repo PRs run it remotely, fork and Dependabot PRs locally with the
# read-only cache. Its bd artifact is renamed
# same-repo PRs and merge groups run it remotely, fork and Dependabot PRs
# locally with the read-only cache. Test results are cached: a PR or
# merge group re-runs only tests whose inputs changed (nightly re-runs
# everything; .bazelrc test:fresh). Its bd artifact is renamed
# (bazel-ci-build-artifacts) so it cannot collide with build-artifacts'
# upload. F3: the package gates build their own bd (via this call's rbe
# job) and do not consume this artifact; it is kept for the F3.5.3
@ -2352,10 +2377,11 @@ jobs:
RETIRED_PR_LANES: ${{ env.BAZEL_RETIRES_LEGACY_PR_LANES == 'true' }}
COVERS_FORKS: ${{ env.BAZEL_COVERS_FORKS == 'true' }}
PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
MERGE_GROUP: ${{ github.event_name == 'merge_group' }}
FORK: ${{ github.event.pull_request.head.repo.fork == true }}
DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }}
run: |
for v in RETIRED_EMBEDDED RETIRED_DOLT_SERVER RETIRED_PR_LANES COVERS_FORKS PULL_REQUEST FORK DEPENDABOT; do
for v in RETIRED_EMBEDDED RETIRED_DOLT_SERVER RETIRED_PR_LANES COVERS_FORKS PULL_REQUEST MERGE_GROUP FORK DEPENDABOT; do
case "${!v}" in
true|false) ;;
*) echo "::error::$v is '${!v}', want true or false"; exit 1 ;;
@ -2363,9 +2389,16 @@ jobs:
done
# Covered: the Bazel lanes are this run's only run of the retired
# tiers. Same-repo PRs (the CI secrets); fork and Dependabot PRs
# too while BAZEL_COVERS_FORKS is "true".
# too while BAZEL_COVERS_FORKS is "true"; and every merge group: it
# runs on the queue's gh-readonly-queue/* branch of this repository
# with the CI secrets, its actor is github-merge-queue[bot] (never
# Dependabot), and bazel.yml's rbe job takes mode remote for it
# like for a same-repo PR, so a missing secret or the farm switch
# off turns pr.yml's gate red rather than dropping a tier.
covered=false
if [ "$PULL_REQUEST" = true ]; then
if [ "$MERGE_GROUP" = true ]; then
covered=true
elif [ "$PULL_REQUEST" = true ]; then
if [ "$FORK" = false ] && [ "$DEPENDABOT" = false ]; then
covered=true
elif [ "$COVERS_FORKS" = true ]; then
@ -2389,7 +2422,7 @@ jobs:
echo "dolt_server=$dolt_server"
echo "pr_lanes=$pr_lanes"
} >> "$GITHUB_OUTPUT"
echo "Legacy tiers retired in favour of the Bazel lanes: embedded Dolt **$embedded**, proxied and server Dolt **$dolt_server**, pr.yml's PR Core/build/pure-Go/domain+uow/contract jobs **$pr_lanes** (pull_request: $PULL_REQUEST, fork: $FORK, dependabot: $DEPENDABOT, forks covered: $COVERS_FORKS, retired embedded: $RETIRED_EMBEDDED, retired proxied/server: $RETIRED_DOLT_SERVER, retired pr.yml jobs: $RETIRED_PR_LANES)" | tee -a "$GITHUB_STEP_SUMMARY"
echo "Legacy tiers retired in favour of the Bazel lanes: embedded Dolt **$embedded**, proxied and server Dolt **$dolt_server**, pr.yml's PR Core/build/pure-Go/domain+uow/contract jobs **$pr_lanes** (pull_request: $PULL_REQUEST, merge_group: $MERGE_GROUP, fork: $FORK, dependabot: $DEPENDABOT, forks covered: $COVERS_FORKS, retired embedded: $RETIRED_EMBEDDED, retired proxied/server: $RETIRED_DOLT_SERVER, retired pr.yml jobs: $RETIRED_PR_LANES)" | tee -a "$GITHUB_STEP_SUMMARY"
ci-gate:
name: CI Gate / Required
@ -2538,9 +2571,6 @@ jobs:
BAZEL_COVERS_PR_LANES: ${{ needs.bazel-coverage.outputs.pr_lanes }}
run: |
skipped_ok=""
if [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then
skipped_ok="CHECK_NO_BEADS_CHANGES"
fi
# F4 side-by-side rollout: WINDOWS_PREBUILT_REQUIRED (top of this
# file) flips which pair of Windows jobs ci-gate enforces with a
# single committed flag, instead of three edits per job

View file

@ -177,10 +177,11 @@ the `bazel` call) and `PR Risk Gate / Required` (`pr-risk.yml`). PR Risk's
gate job was renamed from `CI Gate / Required` to `PR Risk Gate / Required`
(#6939), so the two required contexts are distinct; before that both
workflows reported the same check name. Organization admins and one team
may bypass it. There is no merge queue (no `merge_queue` rule, and no
`merge_group` run has ever happened), so the checks run on `pull_request`
only, and the ruleset does not require branches to be up to date
(strict off). The ruleset applies to the default branch only: PRs into
may bypass it. The ruleset has no `merge_queue` rule yet, so the checks
run on `pull_request` only, and the ruleset does not require branches to
be up to date (strict off). Both workflows are merge-queue ready (see
[Merge Queue](#merge-queue)): adding the queue rule is the only remaining
step. The ruleset applies to the default branch only: PRs into
`release/**` run both workflows (and the Bazel lane), but neither gate is
enforced there.
@ -480,6 +481,14 @@ its own pool from inside its own `bazel-test.yml` job, same-repo, with
`github.token`; beads cannot use its own `GITHUB_TOKEN` against gascity's
repository, so this job needs its own credential into gascity instead.
Merge queue caveat: a `merge_group` run executes the queued commit's
workflow files, so once a maintainer queues a fork PR, that PR's own edits
to `bazel.yml` or `pr.yml` (this job included) run with the shared
`bazel-allocator` key. The B1 protections below (inlined dispatch logic,
base-branch workflow, approval-gated workflow edits) hold only for runs of
the committed file. Review fork PRs' `.github/` changes before queueing
(see [Merge Queue](#merge-queue)).
**What it does.** A job of its own (not a step inside `rbe`, so it never
delays the mode decision every lane waits on), gated on
`needs.rbe.outputs.mode == 'remote'` only - the one mode whose lanes target
@ -615,8 +624,8 @@ would only be needed if maintainers still want exactly one required check.
- Baseline aggregate candidate: `PR / CI Gate / Required`
- Risk aggregate candidate: `PR Risk / PR Risk Gate / Required`
- Source: GitHub Actions
- Required on: pull requests (and merge queue groups, if a queue is ever
added) targeting `main`; not on `release/**`
- Required on: pull requests and merge queue groups targeting `main`; not
on `release/**`
Do not require these existing check names directly:
@ -676,6 +685,7 @@ on:
pull_request:
branches: [ main ]
merge_group:
types: [ checks_requested ]
```
Do not add `paths`, `paths-ignore`, or narrower branch filters to `pr.yml` or
@ -775,8 +785,9 @@ Dolt test jobs, and `test-nix`.
`failure` or `cancelled` result. It accepts `skipped` only for jobs that are
intentionally absent for that event or risk tier:
- `CHECK_NO_BEADS_CHANGES=skipped` is acceptable on `merge_group` because the
job is PR-only.
- (Historical: `CHECK_NO_BEADS_CHANGES=skipped` was accepted on
`merge_group` while the step was PR-only. It now runs on `merge_group`
too, against `merge_group.base_sha`, and no skip of it is excused.)
- In the risk aggregate, `BUILD_EMBEDDED` and the embedded, proxied and server
Dolt test ids may be `skipped` when `FULL_EMBEDDED != true`.
- In the risk aggregate, `TEST_EMBEDDED_STORAGE`, `TEST_EMBEDDED_CONFORMANCE`
@ -950,15 +961,14 @@ manifests. On those PRs they are the tiers' only pre-merge run, and
tests with `go list`, not with PR Core's run, so it is unaffected;
`nightly.yml` still runs PR Core's `go test -json` for the skip-parity
check.
- `--config=sole-run` (`--nocache_test_results`,
`--experimental_remote_cache_eviction_retries=0`, the step 1 and 2
hardening) is added to every `bazel test` of the three lanes wherever
they execute remotely (`BAZEL_SOLE_RUN`: modes `remote`, `fork-ro` and
`fork-rw`), which every covered PR runs in. Runs in modes `cache` and
`local`, whose legacy jobs still run, keep cached results, which keeps
their local runs short. Measured
2026-10-02: `bazel test //... --config=ci --nocache_test_results`
remotely took 132 s (113 targets).
- `--config=sole-run` (`--experimental_remote_cache_eviction_retries=0`,
the step 1 and 2 hardening) is added to every `bazel test` of the three
lanes wherever they execute remotely (`BAZEL_SOLE_RUN`: modes `remote`,
`fork-ro` and `fork-rw`), which every covered PR runs in. It used to
carry `--nocache_test_results` too; test results are now cached on every
run but nightly's (see [Merge Queue](#merge-queue), "Test result
caching"). Measured 2026-10-02: `bazel test //... --config=ci
--nocache_test_results` remotely took 132 s (113 targets).
- Pinned for step 3 (`scripts/pr_lanes_bazel_coverage_test.go`): the
three lanes' Bazel steps and the `prcore`, `ci`, `doltserver`, `pure`,
`js-wasm` and `sole-run` rc lines exactly; no other rc line of a config
@ -996,10 +1006,15 @@ manifests. On those PRs they are the tiers' only pre-merge run, and
- Dependabot PRs, likewise (no Actions secrets; `github.actor`, unlike
`github.triggering_actor`, stays `dependabot[bot]` when someone else
re-runs them);
- every `merge_group` run (there is no merge queue today, so this is not
a pre-merge net);
- every PR while that step's flag is `"false"`.
Every `merge_group` run (merge queue) is covered like a same-repo PR: it
runs on this repository's `gh-readonly-queue/*` branch with the CI
secrets, its actor is `github-merge-queue[bot]`, and `bazel.yml`'s `rbe`
job takes mode `remote` for it, so the Bazel lanes are the queue entry's
only run of each retired tier and `CI Gate / Required` is red unless they
ran remotely and passed (see [Merge Queue](#merge-queue)).
`main.yml`'s embedded and proxied jobs on push to `main` are untouched.
- How:
- `pr-risk.yml` and `pr.yml` each run the identical `bazel-coverage` job
@ -1060,18 +1075,21 @@ manifests. On those PRs they are the tiers' only pre-merge run, and
- Enforcement scope: the beads-only ruleset requires both gates on the
default branch (`main`) only. On PRs into `release/**` both workflows run
and report, but merging does not wait for them, before or after this
change. There is no merge queue and `strict` is off, so no
change. Without the merge queue rule and with `strict` off, no
pre-merge run catches a gap; only `main.yml`'s embedded and proxied jobs
and `bazel.yml`'s push run do, after merge (`main.yml` has no server-Dolt
storage jobs; `bazel.yml`'s push run covers that tier).
- Lane hardening that the retirement relies on, for `bazel-embedded`,
`bazel-proxied` and `bazel-server-storage` alike (policy-tested in
`scripts/ci_workflow_test.go` and `scripts/pr_risk_bazel_coverage_test.go`):
- `--nocache_test_results` in `test:embedded`, `test:doltserver-proxied`
and `test:doltserver-integration`: every run executes every test, like
the legacy `-test.count=1` jobs, so a stale or poisoned entry in the
shared farm action cache cannot stand in for a run. Nothing else in
`.bazelrc` sets test result caching except `test:docker` (also off).
- Test result caching: originally `--nocache_test_results` in
`test:embedded`, `test:doltserver-proxied` and
`test:doltserver-integration` (every run executed every test, like the
legacy `-test.count=1` jobs). Since merge queue readiness these lanes
cache results like every other lane, and nightly's `--config=fresh`
re-executes every test once a day (see [Merge Queue](#merge-queue),
"Test result caching"). Only `test:docker` and `test:fresh` set result
caching in `.bazelrc`.
- No retries: no `--flaky_test_attempts` or
`--runs_per_test_detects_flakes` anywhere, and no `flaky =` other than
a literal `False`. Each lane also runs
@ -1084,8 +1102,8 @@ manifests. On those PRs they are the tiers' only pre-merge run, and
By default (5) Bazel re-runs the entire `bazel test` invocation when an
input was evicted from the remote cache ("Lost inputs ... Found
transient remote cache error, retrying the build"), and that exit code
outranks a test failure. With `--keep_going` and
`--nocache_test_results`, a test that failed in the first attempt is
outranks a test failure. With `--keep_going` (and a failed test, which
is never served from the cache), a test that failed in the first attempt is
then executed again and only the retry's result (and BEP) is reported,
so a flaky failure could turn green. With 0, an eviction fails the step
instead; "Re-run failed jobs" retries it visibly. Reproduced against a
@ -1172,9 +1190,10 @@ scope, not this slice's.
the whole job is lost before any step reports, the five per-check tokens all
read `skipped` (not `skipped_ok`, so the gate still reds), but `FAST_CHECKS`
gives `ci-gate.sh` one clear line naming the job instead of five confusing
ones. `TestPRCIGateFastChecksTokens` pins the whole mapping, including
`CHECK_NO_BEADS_CHANGES`'s `pull_request`-only step `if:` and its
`merge_group` entry in `CI_GATE_SKIPPED_OK`, both unchanged by the fold.
ones. `TestPRCIGateFastChecksTokens` pins the whole mapping. (The fold
kept `CHECK_NO_BEADS_CHANGES`'s `pull_request`-only step `if:` and its
`merge_group` entry in `CI_GATE_SKIPPED_OK`; merge queue readiness later
made the step run on `merge_group` too and dropped that entry.)
- **Cross-compilation 8 → 2.** `check-release-target-cross-compilation`'s
eight per-target matrix legs (one `go build` each) became two legs
(`unix`, `desktop`) driven by `scripts/ci/release-targets.txt`, a
@ -1318,26 +1337,191 @@ inside the required topology. Do not require matrix-expanded
matrix into one job per 5-version chunk; the per-chunk job name changed but
the "do not require individually" guidance is unchanged).
## Merge Queue Behavior
## Merge Queue
Required aggregate checks must be reported for `merge_group`.
Otherwise, GitHub can enqueue a PR and then fail to merge because the required
check was never reported for the synthetic merge group commit.
`pr.yml` and `pr-risk.yml` run on `merge_group` (`types: [
checks_requested ]`) and report `CI Gate / Required` and `PR Risk Gate /
Required` on each queue entry's merge-group commit, so the ruleset's two
required contexts work unchanged once the queue rule is on.
`scripts/ci_merge_queue_test.go` simulates a `merge_group` run through the
shared `evalGHExpr` evaluator and the workflows' own step scripts.
### Queueing a PR
```bash
gh pr merge <number> --auto --squash --repo gastownhall/beads
```
On a green PR this adds it to the queue; while the PR's own required
checks are still running, `--auto` queues it once they pass (this needs
the repository's "Allow auto-merge" setting). The queue's own merge
method (squash) decides how it lands. `gh pr merge <number>
--disable-auto` (or "Remove from queue" in the UI) takes it out; `--admin`
(bypass actors only) merges directly, skipping the queue.
Planned queue settings (`merge_queue` rule in the `beads main: required
CI gates` ruleset): merge method `SQUASH`, grouping strategy `ALLGREEN`,
`max_entries_to_merge` 5, `max_entries_to_build` 3, `min_entries_to_merge`
1, `min_entries_to_merge_wait_minutes` 2 (it only delays merging while
fewer than `min_entries_to_merge` entries are queued, so at 1 it never
waits), `check_response_timeout_minutes` 60. A same-repo `pr.yml` run takes
about 10-11 minutes today. The build limit (3) and the timeout (60) leave
headroom while the farm scales from zero, so a backlog does not time
entries out and set off a rebuild cascade. Watch the first days'
`merge_group` durations before raising the build limit. The required status checks
stay exactly `CI Gate / Required` and `PR Risk Gate / Required` (GitHub
Actions).
### What runs on a merge group
Each queue entry gets a commit on `gh-readonly-queue/main/pr-<n>-<sha>`:
`main` plus every PR ahead of it in the queue plus this PR. Both
workflows run on that commit like a same-repo PR:
- Trust: same repository, CI secrets present, actor
`github-merge-queue[bot]`. Every Blacksmith ternary names
`merge_group` explicitly, `bazel.yml`'s `rbe` job takes mode `remote`
(never asks rbe-fork), and `rbe-prewarm` runs (mode `remote`).
A merge group runs the workflow files and scripts of the queued commit,
not of `main`, and no approval gate applies. A queued fork PR's own edits
to `.github/`, `.bazelrc`, `tools/bazel/`, `MODULE.bazel`, BUILD files or
`scripts/ci/` therefore run with every CI secret: the RBE client
certificate and the shared `bazel-allocator` app key (rbe-prewarm). They
run even if the entry is later ejected and never merges. A queued
Dependabot PR likewise runs with the Actions secrets. That is the trust
of merging (a push to `main` would run the same code). **Maintainer
rule: review a fork PR's changes to those paths before queueing it,
exactly as before merging.** A ruleset `pull_request` rule (1 approval,
approval of the most recent push) would enforce a review before queueing.
That decision is pending.
- D2: `bazel-coverage` covers every merge group, so the retired legacy
tiers (embedded, proxied/server Dolt, pr.yml's PR Core/build/pure-Go/
domain+uow/contract jobs) stay retired and the gate requires their
Bazel lanes to have run remotely and passed. With the farm switch off
(mode `skip`) or a missing executor secret (mode `cache`) the gate is
red, exactly as on a same-repo PR: turn the flags off first (runbook in
[Current State](#current-state)).
- `bazel-cmd-dolt` (required while `BAZEL_CMD_DOLT_REQUIRED` is `"true"`),
`bazel-integration`, the package gates and the F4 prebuilt Windows pair
run as on a PR. `detect-ci-tier` reports full embedded coverage (moot
while the tiers are retired).
- Diff bases: a merge group has no `pull_request` payload and no
`base_ref`. The migration-hygiene `BASE_SHA`, the package gates'
`PR_BASE_SHA`/`PR_HEAD_SHA`, the `.beads/issues.jsonl` guard and the
CLI-docs drift attribution (`BD_DOCS_DIFF_BASE`; without a base it would
fail every entry on drift already on `main`) fall back to
`github.event.merge_group.base_sha`/`head_sha`; every other
`github.event.pull_request.*` read is classified in
`TestMergeQueuePullRequestFieldsHandleMergeGroup` (null is correct
there: fork facts, the rbe-fork PR number, autofix metadata). With
ALLGREEN every entry must pass, so each entry's own diff from its base
commit is enough (the base is `main` or the entry ahead of it). With
HEADGREEN only the batch head would have to pass and a path-filtered
package gate could miss an earlier entry's change: keep ALLGREEN.
- Concurrency: groups key on `github.event.pull_request.number ||
github.ref`, and a merge group's ref is its own queue branch, so queue
entries never cancel each other or the PR's own runs. `bazel.yml` never
cancels in progress for a merge group.
- Autofix: `bazel-autofix.yml` and `docs-autofix.yml` act only on
`pull_request` runs; a red merge group never gets an autofix push.
### Test result caching
Bazel lanes rerun only what changed. Test results are cached (read and
written, Bazel's default) on every run except nightly's: on a PR (any
attempt), a merge group and a push to `main` alike. A test whose action key
(test binary, runfiles, test env, platform) is unchanged reuses the PASS
the farm recorded for it; a test whose inputs changed runs. The PR's own
run seeds the cache, so a merge group re-runs only the tests the merge
changed (on a fresh base, those depending on what landed in between).
`nightly.yml` passes `fresh-test-results: true`, so every `bazel test` in
`bazel.yml` appends `--config=fresh` (`--nocache_test_results`) last, and
the whole suite re-executes once a day. A dispatch of `bazel.yml` can ask
for the same.
This replaces the D2 rule "always execute" (`--nocache_test_results` in the
retired tiers' configs and `sole-run`, parity with the legacy
`-test.count=1` jobs, review F2). That rule also stopped Bazel *writing*
results, so nothing could ever be reused. Why caching is safe:
- A cached PASS is valid for identical inputs: these targets are hermetic
(dolt and every input are runfiles). The docker-backed lane, whose
result depends on host state outside the key, keeps
`--nocache_test_results` and is dispatch-only.
- A cached failure is never reused: Bazel treats a failed cached action
as a miss, so whatever failed before runs again.
- Poisoning is bounded: only rbe-west's workers write the action cache
(client writes are refused, forks are read-only), so a cached PASS is a
real remote execution, and anyone able to run a same-repo branch already
holds the CI certificate (accepted risk in `bazel.yml`'s header).
- What is given up is re-sampling a nondeterministic (-race, timing) test
on unchanged inputs between nightlies. A flaky test fails at most once
per change before it is cached as passing, and nightly samples
everything again.
- No retries were added: `--experimental_remote_cache_eviction_retries=0`
(retired tiers' configs and `sole-run`) and the no-`flaky_test_attempts`
policy are unchanged.
To confirm reuse on the farm, count `testResult` events with
`cachedRemotely` in the BEP of the first few merge-group runs. The same
check shows that `test.xml` is downloaded for cache hits, which
`equivalence.py`, `check_testcases.py` and the pure-Go lane's test-count
check read.
Non-Bazel required jobs re-run in full on every merge group (approximate
PR timings, 2026-10): `fast-checks` (~40 s), `pr-policy-wrapper`
(~2.5 min), `scripts-go-checks` (3 legs, up to ~3.5 min), `pr-lint-wrapper`
(native/darwin/windows, up to ~4 min), `check-doc-flags` (~1.7 min),
`check-doc-freshness-platforms` and `pr-preflight-platforms` (Linux,
Windows and macOS legs, up to ~5 min on Windows),
`check-release-target-cross-compilation` (~5 min),
`test-dolt-server-fingerprint` (~1 min), `windows-make-shell` (~2.7 min),
`windows-test-binaries` plus the prebuilt Windows pair (~7 min end to
end), the advisory native Windows pair (~5 min; the gate waits for them),
`test-nix` (~3 min) and the package gates (seconds unless their paths
changed). None caches results the way Bazel does; most are cheap or
already path- or tier-gated. Candidates to skip on `merge_group`, not
done here: the advisory native Windows pair (`test-windows-liveness`,
`worktree-remove-windows`, advisory while `WINDOWS_PREBUILT_REQUIRED` is
`"true"`), and the macOS legs of the preflight/doc-freshness matrices
(platform behavior the PR run already checked on the same inputs). With
result reuse the merge group's critical path is the Windows
cross-compile and the Windows matrix legs (~5-7 min), not the Bazel
lanes once their tests are cached. An entry's first build after a base
change still compiles what changed.
### Failures and flakes
A red required gate on an entry ejects that PR from the queue (GitHub
comments on it); every entry behind it is rebuilt without it and re-runs.
With ALLGREEN a batch merges only when every entry in it is green. A
flake therefore costs the flaky PR its place and re-runs everything
behind it; re-queue the PR (`gh pr merge --auto --squash` again). A
re-queued entry on unchanged inputs reuses its Bazel lanes' passing
results, so the retry re-runs the failed tests and the non-Bazel jobs; a
reused PASS cannot hide a failure, because failures are never cached. The
same holds for "Re-run jobs" on a PR: passing tests are not re-executed.
To re-sample a suspected flake on unchanged inputs, dispatch `bazel.yml`
on the branch with `fresh-test-results` checked. Runs of queue entries
that were invalidated (an entry ahead was ejected) keep running to
completion and use farm capacity; plan the build limit with that in mind.
The 60-minute check timeout ejects an entry whose gates never report;
both gates normally finish in about 10-15 minutes.
Rollback: delete the `merge_queue` rule from the ruleset. Queued PRs fall
back to the normal merge button; the `merge_group` triggers are inert
without a queue.
Policy for `merge_group`:
- `PR` and `PR Risk` must include `merge_group`.
- `detect-ci-tier` should keep treating `merge_group` as full embedded coverage.
- There is no merge queue today (see Current State), so these runs are not a
pre-merge safety net for anything PRs skip; in particular they are not one
for the retired legacy tiers (D2). `merge_group` keeps those tiers only
so a queue added later starts with full coverage.
- `PR` and `PR Risk` must include `merge_group` (`checks_requested`), and
no job or step condition in them may key on the event: decisions belong
in detector jobs (`TestMergeQueueRequiredGatesRunOnMergeGroup`).
- Any risk detector added to the required topology should default to run on
`merge_group`, because the merge group commit may combine individually safe
PRs into a risky integration state.
- The aggregate gate should evaluate the merge group results exactly like PR
results, except PR-only hygiene checks such as `Check for .beads changes` may
be skipped by design.
- The aggregate gates evaluate merge group results exactly like PR results;
no skip is excused for `merge_group` alone.
## Initial Rollout Snapshot

View file

@ -34,6 +34,7 @@ go_test(
"ci_capability_selector_test.go",
"ci_f7b_review_test.go",
"ci_f7c_advisory_test.go",
"ci_merge_queue_test.go",
"ci_workflow_apt_get_timeout_test.go",
"ci_workflow_test.go",
"complexity_script_test.go",

View file

@ -56,12 +56,20 @@ case "$event_name" in
fi
;;
merge_group)
if git rev-parse --verify --quiet HEAD^ >/dev/null; then
if ! changed_files="$(git diff --name-only HEAD^ HEAD)"; then
run_all "merge-group diff failed; running all package gates"
fi
else
run_all "merge-group parent unavailable; running all package gates"
# PR_BASE_SHA/PR_HEAD_SHA carry merge_group.base_sha/head_sha here:
# the commit the queue entry is built on and the entry itself. Not
# HEAD^: a rebase-method queue entry stacks every commit of the PR,
# so its first parent would hide all but the last one. With the
# ALLGREEN grouping strategy every entry of a batch is checked, so
# each entry's own diff is enough. (With SQUASH, HEAD^ already was
# base_sha; this matters for the merge and rebase methods.) As with
# PR-time path filtering, entry N's gate does not re-test entry
# N-1's package change combined with N's; N-1's own run tested it.
if [[ -z "$pr_base_sha" || -z "$pr_head_sha" ]]; then
run_all "merge-group diff bounds unavailable; running all package gates"
fi
if ! changed_files="$(git diff --name-only "$pr_base_sha" "$pr_head_sha")"; then
run_all "merge-group diff failed; running all package gates"
fi
;;
*)

View file

@ -2,6 +2,8 @@ package scripts_test
import (
"fmt"
"math"
"strconv"
"strings"
"testing"
)
@ -92,8 +94,16 @@ const sameRepoPlatformsMatrixMarkerRunsOn = "${{ matrix.runner == 'same-repo-lin
// string, for the small subset of the GitHub Actions expression language
// this repo's same-repo Blacksmith ternaries use: string literals, dotted
// identifier lookups (resolved from a caller-supplied context map), ==, !=,
// &&, ||, !, and parentheses. It is not a general-purpose GHA expression
// engine - no functions, no numbers, no object/array literals.
// &&, ||, !, parentheses, and the true/false/null literals. Identifiers may
// contain '-' (inputs.fork-farm), and == / != follow GitHub's loose equality
// (ghEquals: strings case-insensitively, mixed types as numbers). It is not a general-purpose GHA
// expression engine - no functions, no numbers, no object/array literals.
//
// Merge queue (ci_merge_queue_test.go): callers simulate a merge_group run
// with github.event_name "merge_group", github.actor
// "github-merge-queue[bot]", github.ref "refs/heads/gh-readonly-queue/...",
// the github.event.merge_group.* fields, and no github.event.pull_request.*
// key at all (null on that event).
//
// && and || use GitHub's own short-circuit-returns-operand semantics (not
// strict booleans: `false && 'x'` is `false`, not `false`'s boolean negation
@ -109,7 +119,7 @@ func ghTokenize(s string) ([]ghToken, error) {
var toks []ghToken
i := 0
isIdentByte := func(b byte) bool {
return b == '.' || b == '_' ||
return b == '.' || b == '_' || b == '-' ||
(b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9')
}
for i < len(s) {
@ -166,7 +176,7 @@ func ghTokenize(s string) ([]ghToken, error) {
type ghParser struct {
toks []ghToken
pos int
ctx map[string]string
ctx map[string]any
}
func (p *ghParser) peek() (ghToken, bool) {
@ -283,13 +293,22 @@ func (p *ghParser) parsePrimary() (any, error) {
case "string":
return tok.val, nil
case "ident":
switch tok.val {
case "true":
return true, nil
case "false":
return false, nil
case "null":
return nil, nil
}
v, ok := p.ctx[tok.val]
if !ok {
// An identifier the caller's context does not mention (for
// example a deleted fork's head.repo.full_name) is null in the
// real evaluator; treat it as the empty string, which compares
// unequal to every non-empty literal this repo's expressions use.
return "", nil
// example a deleted fork's head.repo.full_name, or any
// github.event.pull_request.* field on merge_group) is null in
// the real evaluator: falsy, == null and == '' (both 0), unequal
// to every non-empty, non-numeric literal.
return nil, nil
}
return v, nil
default:
@ -310,8 +329,53 @@ func ghTruthy(v any) bool {
}
}
// ghEquals: GitHub's loose equality for the operand kinds this evaluator
// produces. Two strings compare case-insensitively; two booleans, or two
// nulls, directly; otherwise both sides are coerced to numbers (null and ”
// to 0, true to 1, false to 0, any other string to its numeric value or
// NaN) and NaN equals nothing. So `true == 'true'` is false, as on GitHub
// (the classic workflow_call boolean-input bug), and `false == ”` is true.
func ghEquals(a, b any) bool {
return fmt.Sprint(a) == fmt.Sprint(b)
if sa, ok := a.(string); ok {
if sb, ok := b.(string); ok {
return strings.EqualFold(sa, sb)
}
}
if ba, ok := a.(bool); ok {
if bb, ok := b.(bool); ok {
return ba == bb
}
}
if a == nil && b == nil {
return true
}
na, nb := ghNumber(a), ghNumber(b)
return !math.IsNaN(na) && !math.IsNaN(nb) && na == nb
}
// ghNumber: GitHub's coercion of an operand to a number.
func ghNumber(v any) float64 {
switch x := v.(type) {
case nil:
return 0
case bool:
if x {
return 1
}
return 0
case string:
t := strings.TrimSpace(x)
if t == "" {
return 0
}
f, err := strconv.ParseFloat(t, 64)
if err != nil {
return math.NaN()
}
return f
default:
return math.NaN()
}
}
// evalGHExpr evaluates a GitHub Actions `${{ ... }}` expression (the wrapper
@ -319,6 +383,16 @@ func ghEquals(a, b any) bool {
// "github.event_name") to its string value. See the package comment above
// for the supported subset.
func evalGHExpr(expr string, ctx map[string]string) (any, error) {
typed := make(map[string]any, len(ctx))
for k, v := range ctx {
typed[k] = v
}
return evalGHExprTyped(expr, typed)
}
// evalGHExprTyped: evalGHExpr with typed context values (a bool for a
// boolean input such as inputs.fresh-test-results, nil for null).
func evalGHExprTyped(expr string, ctx map[string]any) (any, error) {
expr = strings.TrimSpace(expr)
expr = strings.TrimPrefix(expr, "${{")
expr = strings.TrimSuffix(expr, "}}")

View file

@ -0,0 +1,606 @@
package scripts_test
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
"gopkg.in/yaml.v3"
)
// Merge queue readiness (engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md, "Merge
// Queue"). The default-branch ruleset requires "CI Gate / Required" (pr.yml)
// and "PR Risk Gate / Required" (pr-risk.yml); with a merge queue both must
// also report on every queue entry's merge-group commit, from a merge_group
// run that has no github.event.pull_request at all. These tests simulate
// that event with the shared evalGHExpr evaluator (ci_blacksmith_runner_test.go)
// and the workflows' real step scripts.
const (
// Test results are cached (read and written) on every run but
// nightly's: nightly.yml passes fresh-test-results: true, and bazel.yml
// appends BAZEL_FRESH (--config=fresh, --nocache_test_results) last to
// every `bazel test`.
bazelFreshEnv = "${{ inputs.fresh-test-results && '--config=fresh' || '' }}"
bazelFreshArg = `${BAZEL_FRESH:+"$BAZEL_FRESH"}`
bazelFreshRCLine = "test:fresh --nocache_test_results"
mergeQueueActor = "github-merge-queue[bot]"
mergeQueueOwnRepo = "gastownhall/beads"
)
// mergeGroupCtx: an evalGHExpr context for a merge_group run of entry n
// (no github.event.pull_request.* key: null on this event).
func mergeGroupCtx(n int, extra map[string]string) map[string]string {
ctx := map[string]string{
"github.event_name": "merge_group",
"github.repository": mergeQueueOwnRepo,
"github.actor": mergeQueueActor,
"github.ref": fmt.Sprintf("refs/heads/gh-readonly-queue/main/pr-%d-%040d", 7000+n, n),
"github.run_attempt": "1",
"github.event.merge_group.base_sha": fmt.Sprintf("%040d", 100+n),
"github.event.merge_group.head_sha": fmt.Sprintf("%040d", 200+n),
"github.event.merge_group.base_ref": "refs/heads/main",
"github.event.merge_group.head_ref": fmt.Sprintf("refs/heads/gh-readonly-queue/main/pr-%d-%040d", 7000+n, n),
}
for k, v := range extra {
ctx[k] = v
}
return ctx
}
// pullRequestCtx: an evalGHExpr context for a same-repo pull_request run.
func pullRequestCtx(n int, extra map[string]string) map[string]string {
ctx := map[string]string{
"github.event_name": "pull_request",
"github.repository": mergeQueueOwnRepo,
"github.actor": "alice",
"github.ref": fmt.Sprintf("refs/pull/%d/merge", 7000+n),
"github.run_attempt": "1",
"github.event.pull_request.number": strconv.Itoa(7000 + n),
"github.event.pull_request.base.sha": fmt.Sprintf("%040d", 300+n),
"github.event.pull_request.head.sha": fmt.Sprintf("%040d", 400+n),
"github.event.pull_request.head.repo.full_name": mergeQueueOwnRepo,
"github.event.pull_request.head.repo.fork": "false",
}
for k, v := range extra {
ctx[k] = v
}
return ctx
}
// interpolateGH replaces every ${{ ... }} in s with its evalGHExpr value.
func interpolateGH(t *testing.T, s string, ctx map[string]string) string {
t.Helper()
re := regexp.MustCompile(`\$\{\{(.*?)\}\}`)
return re.ReplaceAllStringFunc(s, func(m string) string {
v, err := evalGHExpr(m, ctx)
if err != nil {
t.Fatalf("evalGHExpr(%q): %v", m, err)
}
switch x := v.(type) {
case nil:
return ""
case bool:
return strconv.FormatBool(x)
default:
return fmt.Sprint(x)
}
})
}
// The two required gates: their workflows run on merge_group (exactly the
// checks_requested type), the gate jobs keep their ruleset names and always
// run, and no job's or step's condition in either workflow keys on the
// event, so the merge group runs (or skips) exactly what the decision jobs
// say, like a PR.
func TestMergeQueueRequiredGatesRunOnMergeGroup(t *testing.T) {
gates := map[string]string{"pr.yml": "CI Gate / Required", prRiskWorkflowName: "PR Risk Gate / Required"}
for name, gateName := range gates {
var doc struct {
On map[string]yaml.Node `yaml:"on"`
}
if err := yaml.Unmarshal([]byte(readPolicyFile(t, sourceRepoRoot(t), ".github/workflows/"+name)), &doc); err != nil {
t.Fatal(err)
}
mg, ok := doc.On["merge_group"]
if !ok {
t.Fatalf("%s has no merge_group trigger; a queued PR would wait forever for %q", name, gateName)
}
var trig struct {
Types []string `yaml:"types"`
}
if err := mg.Decode(&trig); err != nil || strings.Join(trig.Types, ",") != "checks_requested" {
t.Errorf("%s merge_group trigger types = %v (%v), want exactly [checks_requested]", name, trig.Types, err)
}
w := readCIWorkflow(t, name)
gate := w.job(t, "ci-gate")
if gate.Name != gateName || gate.If != "${{ always() }}" {
t.Errorf("%s ci-gate: name %q, if %q; want %q (the ruleset's exact context), if ${{ always() }}", name, gate.Name, gate.If, gateName)
}
// The gate runs on Blacksmith for a merge group (same-repo trust).
if got := mustEvalGHRunsOn(t, gate.RunsOn, mergeGroupCtx(1, nil)); !strings.HasPrefix(got, "blacksmith-") {
t.Errorf("%s ci-gate runs-on for merge_group = %q, want a Blacksmith runner", name, got)
}
event := regexp.MustCompile(`github\.event_name|github\.event\.|github\.base_ref|github\.head_ref`)
for jobName, job := range w.Jobs {
if event.MatchString(job.If) {
t.Errorf("%s job %s if %q keys on the event; decide in a job (detect-ci-tier, bazel-coverage) and read its outputs", name, jobName, job.If)
}
for _, step := range job.Steps {
if event.MatchString(step.If) {
t.Errorf("%s job %s step %q if %q keys on the event; a merge group must run it like a PR", name, jobName, step.Name, step.If)
}
if strings.Contains(step.Run, "github.base_ref") || strings.Contains(step.Run, "github.head_ref") {
t.Errorf("%s job %s step %q interpolates base_ref/head_ref, which a merge group lacks", name, jobName, step.Name)
}
}
}
}
}
// Concurrency: a merge group's runs key on its own gh-readonly-queue/* ref,
// so two queue entries never share a group (cancel-in-progress would
// otherwise cancel the earlier entry's required checks), and a PR's own
// runs never cancel its queue entry's or the other way round. bazel.yml's
// called-workflow group never cancels a merge group either.
func TestMergeQueueConcurrencyNeverCancelsQueueRuns(t *testing.T) {
for _, name := range []string{"pr.yml", prRiskWorkflowName, bazelWorkflowName} {
var doc struct {
Concurrency struct {
Group string `yaml:"group"`
CancelInProgress any `yaml:"cancel-in-progress"`
} `yaml:"concurrency"`
}
if err := yaml.Unmarshal([]byte(readPolicyFile(t, sourceRepoRoot(t), ".github/workflows/"+name)), &doc); err != nil {
t.Fatal(err)
}
group := func(ctx map[string]string) string {
c := map[string]string{"github.workflow": strings.TrimSuffix(name, ".yml")}
for k, v := range ctx {
c[k] = v
}
return interpolateGH(t, doc.Concurrency.Group, c)
}
mg1, mg2 := group(mergeGroupCtx(1, nil)), group(mergeGroupCtx(2, nil))
pr1 := group(pullRequestCtx(1, nil))
if mg1 == mg2 || mg1 == pr1 || !strings.Contains(mg1, "gh-readonly-queue/main/pr-7001") {
t.Errorf("%s concurrency group: merge group 1 %q, merge group 2 %q, PR %q; want one group per queue entry, apart from the PR's", name, mg1, mg2, pr1)
}
if name == bazelWorkflowName {
if got := interpolateGH(t, fmt.Sprint(doc.Concurrency.CancelInProgress), mergeGroupCtx(1, nil)); got != "false" {
t.Errorf("%s cancel-in-progress on merge_group = %q, want false", name, got)
}
}
}
}
// Every github.event.pull_request.* read in the required topology either
// falls back to the merge_group field (evaluated below: the queue's SHAs on
// merge_group, the PR's on pull_request) or is listed here with why null is
// right on a merge group. A new read fails until it is classified.
func TestMergeQueuePullRequestFieldsHandleMergeGroup(t *testing.T) {
// path suffix (workflow:YAML path) -> why null on merge_group is right.
nullOK := map[string]string{
"pr.yml:.concurrency.group": "falls back to github.ref (TestMergeQueueConcurrencyNeverCancelsQueueRuns)",
"pr-risk.yml:.concurrency.group": "falls back to github.ref",
"bazel.yml:.concurrency.group": "falls back to github.ref",
"bazel-coverage.steps[0].env.FORK": "null == true is false: a merge group is never a fork (bazel.yml's rbe job's expression, verbatim)",
"rbe.steps[0].env.FORK": "null == true is false: a merge group is never a fork",
"rbe.steps[0].env.PR_NUMBER": "read only for fork/Dependabot pull_request runs (the rbe-fork mint)",
".env.RBE_FORK_PR": "setup-bazel reads it only in the fork modes, which a merge group never takes",
"detect-ci-tier.steps[1].env.PR_BASE_SHA": "ci-embedded-tier.sh returns full coverage for merge_group before reading it",
"detect-ci-tier.steps[1].env.PR_HEAD_SHA": "ci-embedded-tier.sh returns full coverage for merge_group before reading it",
"detect-ci-tier.steps[2].env.PR_BASE_SHA": "advisory shadow selector; merge_group selects everything",
"detect-ci-tier.steps[2].env.PR_HEAD_SHA": "advisory shadow selector; merge_group selects everything",
"bazel-test.steps[*].env.PR_NUMBER": "bazel-sync patch metadata; bazel-autofix.yml ignores non-pull_request runs",
"bazel-test.steps[*].env.PR_HEAD_SHA": "bazel-sync patch metadata; bazel-autofix.yml ignores non-pull_request runs",
}
used := map[string]bool{}
var fallbacks []string
for _, name := range []string{"pr.yml", prRiskWorkflowName, bazelWorkflowName} {
walkYAML(readYAMLNode(t, filepath.Join(".github", "workflows", name)), "", func(path string, key bool, value string) {
if key || !strings.Contains(value, "github.event.pull_request.") {
return
}
// The Blacksmith venue ternaries name merge_group explicitly
// (TestSameRepoBlacksmithExpressionSemantics).
if strings.HasSuffix(path, ".runs-on") && strings.Contains(value, "github.event_name == 'merge_group' ||") {
return
}
if strings.Contains(value, "github.event.merge_group.") {
fallbacks = append(fallbacks, value)
return
}
for suffix := range nullOK {
// steps[*] matches any step index (the sync step moves when
// steps are added before it).
re := regexp.MustCompile(regexp.QuoteMeta(suffix) + "$")
if strings.Contains(suffix, "[*]") {
re = regexp.MustCompile(strings.ReplaceAll(regexp.QuoteMeta(suffix), `\[\*\]`, `\[[0-9]+\]`) + "$")
}
if re.MatchString(name + ":" + path) {
used[suffix] = true
return
}
}
t.Errorf("%s %s reads %q, which is null on merge_group: add a github.event.merge_group.* fallback or classify it here", name, path, value)
})
}
for suffix, why := range nullOK {
if !used[suffix] {
t.Errorf("stale merge_group classification %q (%s): nothing matches it", suffix, why)
}
}
if len(fallbacks) < 3 {
t.Fatalf("found %d merge_group fallbacks, want at least the migration-hygiene BASE_SHA and both package gates' bounds", len(fallbacks))
}
for _, expr := range fallbacks {
mg, pr := interpolateGH(t, expr, mergeGroupCtx(1, nil)), interpolateGH(t, expr, pullRequestCtx(1, nil))
if !strings.HasPrefix(mg, "0000") || mg == pr || !strings.HasPrefix(pr, "0000") {
t.Errorf("%q: merge_group %q, pull_request %q; want the queue's SHA and the PR's", expr, mg, pr)
}
}
}
// D2 on merge_group: both workflows' bazel-coverage decision, with its env
// evaluated by evalGHExpr for a merge group, retires every flagged legacy
// tier (the Bazel lanes cover them), and bazel.yml's rbe step, evaluated the
// same way, takes mode remote with the CI secrets, so pr.yml's gate requires
// those lanes to have run remotely and passed. Without the secret or with
// the farm switch off the mode is cache or skip, and the gate is red
// (TestPRRiskDecisionMatchesBazelMode's named merge_group cases).
func TestMergeQueueBazelCoversRetiredTiers(t *testing.T) {
requireHostTool(t, "bash")
for _, name := range []string{"pr.yml", prRiskWorkflowName} {
step := coverageStep(t, name)
ctx := mergeGroupCtx(1, nil)
for k, v := range workflowEnv(t, name) {
ctx["env."+k] = v
}
env := map[string]string{}
for k, v := range step.Env {
env[k] = interpolateGH(t, v, ctx)
}
if env["MERGE_GROUP"] != "true" || env["PULL_REQUEST"] != "false" || env["FORK"] != "false" || env["DEPENDABOT"] != "false" {
t.Errorf("%s bazel-coverage env on merge_group = %v", name, env)
}
out, err := runBazelRBEDecision(t, step.Run, env)
if err != nil {
t.Fatalf("%s bazel-coverage on merge_group: %v", name, err)
}
for _, r := range retiredTiers {
want := strconv.FormatBool(ctx["env."+r.flag] == "true")
if out[r.output] != want {
t.Errorf("%s bazel-coverage %s on merge_group = %q, want %s (flag %s %q)", name, r.output, out[r.output], want, r.flag, ctx["env."+r.flag])
}
}
}
rbe := readCIWorkflow(t, bazelWorkflowName).job(t, bazelRBEJobName)
for _, c := range []struct {
name, varOn, secret, mode string
}{
{"farm on, secrets", "true", "grpcs://rbe.example:443", "remote"},
{"secret missing", "true", "", "cache"},
{"farm switch off", "", "grpcs://rbe.example:443", "skip"},
} {
ctx := mergeGroupCtx(1, map[string]string{"vars.RBE_WEST_WORKERS": c.varOn, "secrets.RBE_WEST_EXECUTOR": c.secret, "inputs.rbe": "on", "inputs.fork-farm": "off"})
env := map[string]string{}
for k, v := range rbe.Steps[0].Env {
env[k] = interpolateGH(t, v, ctx)
}
out, log, err := runBazelRBEDecisionLog(t, rbe.Steps[0].Run, env)
if err != nil {
t.Fatalf("rbe on merge_group (%s): %v", c.name, err)
}
if out["mode"] != c.mode || log != "" {
t.Errorf("rbe on merge_group (%s): mode %q (mint asked: %q), want %s without asking rbe-fork", c.name, out["mode"], log, c.mode)
}
if got := mustEvalGHRunsOn(t, rbe.RunsOn, ctx); !strings.HasPrefix(got, "blacksmith-") {
t.Errorf("rbe runs-on for merge_group = %q, want Blacksmith", got)
}
}
}
// Test result caching: every `bazel test` in bazel.yml reuses cached
// results except where the caller asks for fresh ones. BAZEL_FRESH is one
// workflow-level env, --config=fresh only when inputs.fresh-test-results is
// true (nightly.yml passes it; nothing else does), appended after every
// other --config of each `bazel test` so its --nocache_test_results wins;
// no lane config turns caching off except docker (host state outside the
// action key); and nothing adds retries (eviction retries stay 0 where
// set, TestBazelRetiredLanesArePinned / TestBazelPRLanesArePinned).
func TestBazelTestResultCachingPolicy(t *testing.T) {
var doc struct {
Env map[string]string `yaml:"env"`
On struct {
Dispatch struct {
Inputs map[string]struct {
Type string `yaml:"type"`
Default any `yaml:"default"`
} `yaml:"inputs"`
} `yaml:"workflow_dispatch"`
Call struct {
Inputs map[string]struct {
Type string `yaml:"type"`
Default any `yaml:"default"`
} `yaml:"inputs"`
} `yaml:"workflow_call"`
} `yaml:"on"`
}
if err := yaml.Unmarshal([]byte(readPolicyFile(t, sourceRepoRoot(t), ".github/workflows/"+bazelWorkflowName)), &doc); err != nil {
t.Fatal(err)
}
if doc.Env["BAZEL_FRESH"] != bazelFreshEnv {
t.Errorf("%s env BAZEL_FRESH = %q, want %q", bazelWorkflowName, doc.Env["BAZEL_FRESH"], bazelFreshEnv)
}
for name, in := range map[string]struct {
Type string `yaml:"type"`
Default any `yaml:"default"`
}{"workflow_call": doc.On.Call.Inputs["fresh-test-results"], "workflow_dispatch": doc.On.Dispatch.Inputs["fresh-test-results"]} {
if in.Type != "boolean" || in.Default != false {
t.Errorf("%s input fresh-test-results: type %q default %v; want boolean, default false", name, in.Type, in.Default)
}
}
for _, c := range []struct {
name string
v any
want string
}{
{"nightly (true)", true, "--config=fresh"},
{"default (false)", false, ""},
{"push (null)", nil, ""},
} {
got, err := evalGHExprTyped(bazelFreshEnv, map[string]any{"inputs.fresh-test-results": c.v})
if err != nil {
t.Fatal(err)
}
if got != c.want {
t.Errorf("%s: BAZEL_FRESH = %#v, want %q", c.name, got, c.want)
}
}
w := readCIWorkflow(t, bazelWorkflowName)
bazelTest := regexp.MustCompile(`^\s*bazel\s+test\b`)
tests := 0
for name, job := range w.Jobs {
if _, ok := job.Env["BAZEL_FRESH"]; ok {
t.Errorf("%s sets BAZEL_FRESH; only the workflow env may", name)
}
for _, step := range job.Steps {
if strings.Contains(step.Run, "--config=fresh") || strings.Contains(step.Run, "cache_test_results") || strings.Contains(step.Run, "BAZEL_REUSE_RESULTS") {
t.Errorf("%s step %q names result caching directly; only BAZEL_FRESH may", name, step.Name)
}
for _, line := range strings.Split(step.Run, "\n") {
if !bazelTest.MatchString(line) {
continue
}
tests++
i := strings.Index(line, bazelFreshArg)
if i < 0 || strings.Contains(line[i:], "--config") || strings.Contains(line[i:], "SOLE_RUN") {
t.Errorf("%s step %q: %q must pass %s after every --config", name, step.Name, line, bazelFreshArg)
}
}
}
}
if tests < 9 {
t.Errorf("found %d `bazel test` lines in %s, want every lane's (at least 9)", tests, bazelWorkflowName)
}
nightly := readCIWorkflow(t, "nightly.yml").job(t, "bazel")
if nightly.With["fresh-test-results"] != "true" {
t.Errorf("nightly.yml's bazel call with fresh-test-results = %q, want true (the run that samples flakes)", nightly.With["fresh-test-results"])
}
for _, name := range []string{"pr.yml", "bazel-farm.yml"} {
for jobName, job := range readCIWorkflow(t, name).Jobs {
if _, ok := job.With["fresh-test-results"]; ok {
t.Errorf("%s %s passes fresh-test-results; only nightly re-executes every test", name, jobName)
}
}
}
rc := readPolicyFile(t, bazelPolicyRoot(t), ".bazelrc")
var lines []string
for _, line := range strings.Split(rc, "\n") {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "#") {
continue
}
head, _, _ := strings.Cut(line, " ")
if strings.HasSuffix(head, ":fresh") {
lines = append(lines, line)
}
if strings.Contains(line, "cache_test_results") && line != bazelFreshRCLine && line != "test:docker --nocache_test_results" {
t.Errorf(".bazelrc %q: only test:docker and test:fresh set test result caching", line)
}
}
if strings.Join(lines, "\n") != bazelFreshRCLine {
t.Errorf(".bazelrc --config=fresh = %q, want exactly %q", lines, bazelFreshRCLine)
}
if !strings.Contains(rc, "\ntest:docker --nocache_test_results\n") {
t.Error(".bazelrc lost test:docker --nocache_test_results")
}
}
// detect-package-gates.sh on merge_group diffs the queue's own bounds
// (merge_group.base_sha..head_sha), not HEAD^: a rebase-method entry
// stacks every commit of the PR, and only the first touches a package.
func TestMergeQueueDetectPackageGatesUsesQueueBounds(t *testing.T) {
requireHostTool(t, "git")
requireHostTool(t, "bash")
dir, base, head := mergeQueueRepo(t, []string{"npm-package/package.json"}, []string{"README.md"})
script := filepath.Join(sourceRepoRoot(t), "scripts/ci/detect-package-gates.sh")
run := func(env ...string) map[string]string {
t.Helper()
out := filepath.Join(t.TempDir(), "out")
cmd := exec.Command("bash", script)
cmd.Dir = dir
cmd.Env = append([]string{"PATH=" + os.Getenv("PATH"), "GITHUB_OUTPUT=" + out, "GITHUB_EVENT_NAME=merge_group"}, env...)
if b, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("detect-package-gates.sh: %v\n%s", err, b)
}
data, err := os.ReadFile(out)
if err != nil {
t.Fatal(err)
}
got := map[string]string{}
for _, l := range strings.Split(strings.TrimSpace(string(data)), "\n") {
k, v, _ := strings.Cut(l, "=")
got[k] = v
}
return got
}
if got := run("PR_BASE_SHA="+base, "PR_HEAD_SHA="+head); got["npm_package"] != "true" || got["mcp_package"] != "false" {
t.Errorf("merge group whose first commit changes npm-package/: %v, want npm_package only", got)
}
if got := run(); got["npm_package"] != "true" || got["mcp_package"] != "true" {
t.Errorf("merge group without bounds: %v, want every gate", got)
}
if got := run("PR_BASE_SHA="+head+"^", "PR_HEAD_SHA="+head); got["npm_package"] != "false" {
t.Errorf("merge group touching only README.md: %v, want no gate", got)
}
}
// fast-checks' .beads guard runs on merge_group against the queue's base
// commit and on pull_request against origin/<base branch>.
func TestMergeQueueBeadsGuardRuns(t *testing.T) {
requireHostTool(t, "git")
requireHostTool(t, "bash")
step := readCIWorkflow(t, "pr.yml").job(t, "fast-checks").step(t, "Check for .beads/issues.jsonl changes")
for _, c := range []struct {
name string
changed string
pass bool
}{
{"unrelated change", "README.md", true},
{".beads change", ".beads/issues.jsonl", false},
} {
dir, base, _ := mergeQueueRepo(t, []string{c.changed})
gitIn(t, dir, "update-ref", "refs/remotes/origin/main", base)
for event, env := range map[string][]string{
"merge_group": {"MERGE_GROUP_BASE_SHA=" + interpolateGH(t, step.Env["MERGE_GROUP_BASE_SHA"], mergeGroupCtx(1, map[string]string{"github.event.merge_group.base_sha": base}))},
"pull_request": {"MERGE_GROUP_BASE_SHA=" + interpolateGH(t, step.Env["MERGE_GROUP_BASE_SHA"], pullRequestCtx(1, nil)), "GITHUB_BASE_REF=main"},
} {
// GitHub's default shell for a run step without `shell:`.
cmd := exec.Command("bash", "--noprofile", "--norc", "-e", "-c", step.Run)
cmd.Dir = dir
cmd.Env = append([]string{"PATH=" + os.Getenv("PATH")}, env...)
out, err := cmd.CombinedOutput()
if (err == nil) != c.pass {
t.Errorf("%s, %s: err %v, want pass %v\n%s", event, c.name, err, c.pass, out)
}
}
}
}
// The guard fails closed when its diff base is missing (a failed git diff
// piped into grep -q would otherwise pass).
func TestMergeQueueBeadsGuardFailsWithoutBase(t *testing.T) {
requireHostTool(t, "git")
requireHostTool(t, "bash")
step := readCIWorkflow(t, "pr.yml").job(t, "fast-checks").step(t, "Check for .beads/issues.jsonl changes")
dir, _, _ := mergeQueueRepo(t, []string{"README.md"})
for name, env := range map[string][]string{
"merge_group, unknown base_sha": {"MERGE_GROUP_BASE_SHA=" + strings.Repeat("e", 40)},
"pull_request, no origin/main": {"GITHUB_BASE_REF=main"},
} {
cmd := exec.Command("bash", "--noprofile", "--norc", "-e", "-c", step.Run)
cmd.Dir = dir
cmd.Env = append([]string{"PATH=" + os.Getenv("PATH")}, env...)
if out, err := cmd.CombinedOutput(); err == nil || !strings.Contains(string(out), "unavailable") {
t.Errorf("%s: err %v, want a failure naming the missing base\n%s", name, err, out)
}
}
}
// check-doc-flags' CLI-docs drift attribution needs a diff base; a merge
// group has no GITHUB_BASE_REF, so the step passes the queue's base commit
// (and nothing on pull_request, where origin/$GITHUB_BASE_REF applies).
// Without it, drift already on main fails every queue entry.
func TestMergeQueueDocDriftHasDiffBase(t *testing.T) {
step := readCIWorkflow(t, "pr.yml").job(t, "check-doc-flags").step(t, "Validate docs against CLI")
expr := step.Env["BD_DOCS_DIFF_BASE"]
if got := interpolateGH(t, expr, mergeGroupCtx(1, nil)); got != fmt.Sprintf("%040d", 101) {
t.Errorf("check-doc-flags BD_DOCS_DIFF_BASE on merge_group = %q (%q), want merge_group.base_sha", got, expr)
}
if got := interpolateGH(t, expr, pullRequestCtx(1, nil)); got != "" {
t.Errorf("check-doc-flags BD_DOCS_DIFF_BASE on pull_request = %q, want empty (origin/$GITHUB_BASE_REF)", got)
}
drift := readPolicyFile(t, sourceRepoRoot(t), "scripts/check-cli-docs-drift.sh")
if !strings.Contains(drift, `BASE_REF="${BD_DOCS_DIFF_BASE:-}"`) {
t.Error("check-cli-docs-drift.sh no longer reads BD_DOCS_DIFF_BASE")
}
}
// The shared evaluator follows GitHub's loose equality, so a boolean input
// compared with a string ('true') is false, as on GitHub, instead of
// masking that classic workflow_call bug.
func TestGHExprLooseEquality(t *testing.T) {
for _, c := range []struct {
expr string
ctx map[string]any
want bool
}{
{"${{ inputs.b == 'true' }}", map[string]any{"inputs.b": true}, false},
{"${{ inputs.b == true }}", map[string]any{"inputs.b": true}, true},
{"${{ inputs.b == false }}", map[string]any{"inputs.b": false}, true},
{"${{ inputs.b == '' }}", map[string]any{"inputs.b": false}, true},
{"${{ github.event.pull_request.head.repo.fork == true }}", map[string]any{}, false},
{"${{ github.event.pull_request.number == '' }}", map[string]any{}, true},
{"${{ vars.X == 'true' }}", map[string]any{"vars.X": "TRUE"}, true},
{"${{ github.run_attempt != '1' }}", map[string]any{"github.run_attempt": "2"}, true},
} {
got, err := evalGHExprTyped(c.expr, c.ctx)
if err != nil {
t.Fatal(err)
}
if got != c.want {
t.Errorf("%s with %v = %v, want %v", c.expr, c.ctx, got, c.want)
}
}
}
// mergeQueueRepo: a git repo with a base commit and one commit per file
// group on top; returns its dir, the base SHA and the head SHA.
func mergeQueueRepo(t *testing.T, commits ...[]string) (dir, base, head string) {
t.Helper()
dir = t.TempDir()
gitIn(t, dir, "init", "-q", "-b", "main")
write := func(rel, content string) {
p := filepath.Join(dir, rel)
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(p, []byte(content), 0o644); err != nil {
t.Fatal(err)
}
}
write("base.txt", "base\n")
gitIn(t, dir, "add", "-A")
gitIn(t, dir, "commit", "-q", "-m", "base")
base = strings.TrimSpace(gitIn(t, dir, "rev-parse", "HEAD"))
for i, files := range commits {
for _, f := range files {
write(f, fmt.Sprintf("change %d\n", i))
}
gitIn(t, dir, "add", "-A")
gitIn(t, dir, "commit", "-q", "-m", fmt.Sprintf("change %d", i))
}
head = strings.TrimSpace(gitIn(t, dir, "rev-parse", "HEAD"))
return dir, base, head
}
func gitIn(t *testing.T, dir string, args ...string) string {
t.Helper()
cmd := exec.Command("git", args...)
cmd.Dir = dir
cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL="+os.DevNull,
"GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@example.com", "GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@example.com")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("git %v: %v\n%s", args, err, out)
}
return string(out)
}

View file

@ -3310,13 +3310,10 @@ func TestPRCIGateFastChecksTokens(t *testing.T) {
"migration-hygiene": "Run migration hygiene checks", "no-beads-changes": "Check for .beads/issues.jsonl changes",
"fmt": "Check gofmt",
}[stepID])
// Every step runs on both PR triggers, merge_group included (the
// .beads diff takes merge_group.base_sha there), so the gate
// excuses none of their skips.
wantIf := "${{ !cancelled() }}"
if stepID == "no-beads-changes" {
// pull_request-only, same as before the fold: merge_group has no
// base_ref to diff against. The CI_GATE_SKIPPED_OK allowlist
// below covers exactly that skip on merge_group runs.
wantIf = "${{ !cancelled() && github.event_name == 'pull_request' }}"
}
if step.ID != stepID || step.If != wantIf {
t.Errorf("fast-checks step %q: id %q, if %q; want id %q, if %q", step.Name, step.ID, step.If, stepID, wantIf)
}
@ -3332,11 +3329,17 @@ func TestPRCIGateFastChecksTokens(t *testing.T) {
t.Errorf("ci-gate env %s = %q, want %q", m.token, gateStep.Env[m.token], wantEnv)
}
}
// CHECK_NO_BEADS_CHANGES's step only runs on pull_request; the gate's own
// run: script must still allow-list exactly that skip on merge_group,
// unchanged by the fold.
if !strings.Contains(gateStep.Run, `skipped_ok="CHECK_NO_BEADS_CHANGES"`) {
t.Error("ci-gate run script no longer allow-lists CHECK_NO_BEADS_CHANGES's merge_group skip")
// Merge queue: the .beads guard runs on merge_group too, diffing
// against the queue's base commit (a merge group has no base_ref), and
// the gate no longer excuses its skip there.
noBeads := job.step(t, "Check for .beads/issues.jsonl changes")
if noBeads.Env["MERGE_GROUP_BASE_SHA"] != "${{ github.event.merge_group.base_sha }}" ||
!strings.Contains(noBeads.Run, `base="${MERGE_GROUP_BASE_SHA:-origin/${GITHUB_BASE_REF:-main}}"`) ||
!strings.Contains(noBeads.Run, `git diff --name-only "$base"...HEAD`) || strings.Contains(noBeads.Run, "${{") {
t.Errorf("fast-checks .beads guard must diff merge_group.base_sha (merge queue) or origin/$GITHUB_BASE_REF (pull_request) without interpolating expressions: env %v\n%s", noBeads.Env, noBeads.Run)
}
if strings.Contains(gateStep.Run, "CHECK_NO_BEADS_CHANGES") {
t.Error("ci-gate run script excuses a CHECK_NO_BEADS_CHANGES skip; the guard runs on merge_group too")
}
// Review N-6 (2026-10-03): pin the folded steps' actual commands/env, not
@ -4823,7 +4826,7 @@ func TestBazelIntegrationJob(t *testing.T) {
}
cmd := regexp.MustCompile(`\s*\\\n\s*`).ReplaceAllString(test.Run, " ")
// EXCLUDE_TARGETS: TestBazelIntegrationExcludesBdTestOnlyWhereCmdDoltCovers.
const wantCmd = `bazel test //... --config=integration --build_event_json_file="$RUNNER_TEMP/bazel-bep.json" ${EXCLUDE_TARGETS:+-- "$EXCLUDE_TARGETS"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?`
const wantCmd = `bazel test //... --config=integration ` + bazelFreshArg + ` --build_event_json_file="$RUNNER_TEMP/bazel-bep.json" ${EXCLUDE_TARGETS:+-- "$EXCLUDE_TARGETS"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?`
if !strings.Contains(cmd, wantCmd) || !strings.Contains(test.Run, "set -o pipefail") {
t.Errorf("%s test step does not run exactly %q:\n%s", bazelIntegJobName, wantCmd, test.Run)
}
@ -4882,6 +4885,9 @@ func assertBazelTierStep(t *testing.T, job ciWorkflowJob, jobName, config string
}
cmd := regexp.MustCompile(`\s*\\\n\s*`).ReplaceAllString(step.Run, " ")
wantCmd := `bazel test //... --config=` + config + ` --build_event_json_file="$RUNNER_TEMP/` + bep + `"`
// Every `bazel test` ends its configs with nightly's fresh-results
// switch (ci_merge_queue_test.go).
wantCmd = `bazel test //... --config=` + config + ` ` + bazelFreshArg + ` --build_event_json_file="$RUNNER_TEMP/` + bep + `"`
if !strings.Contains(cmd, wantCmd) || !strings.Contains(step.Run, "set -o pipefail") || strings.Count(step.Run, "bazel test //") != 1 ||
strings.Contains(step.Run, "--config=remote-exec") || strings.Contains(step.Run, "--test_tag_filters") {
t.Errorf("%s step --config=%s does not run exactly %q:\n%s", jobName, config, wantCmd, step.Run)
@ -5155,15 +5161,15 @@ func TestBazelDoltServerTiersMirrorPRRisk(t *testing.T) {
const bazelEmbeddedTestRun = `set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=embedded \
bazel test //... --config=embedded ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=embedded: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
exit "$rc"`
// .bazelrc's --config=embedded, exactly and in order (review F4): no
// --test_filter, no -test.short/-test.run/-test.skip, no retries, no
// result caching. The conformance targets' own -test.run/-test.skip args
// --test_filter, no -test.short/-test.run/-test.skip, no retries (result
// caching as every lane's: nightly re-executes). The conformance targets' own -test.run/-test.skip args
// (the legacy jobs' partition) are checked against pr-risk.yml below.
var bazelEmbeddedRCLines = []string{
"test:embedded --@rules_go//go/config:race",
@ -5175,7 +5181,6 @@ var bazelEmbeddedRCLines = []string{
"test:embedded --test_arg=-test.parallel=4",
"test:embedded --test_env=GO_TEST_WRAP_TESTV=1",
"test:embedded --remote_download_regex=.*/test\\.xml$",
"test:embedded --nocache_test_results",
"test:embedded --experimental_remote_cache_eviction_retries=0",
}
@ -5217,9 +5222,6 @@ func TestBazelEmbeddedJobMirrorsEmbeddedTier(t *testing.T) {
"test:embedded --test_tag_filters=embedded",
// The jobs pass no -parallel: GOMAXPROCS on 4-vCPU ubuntu-latest.
"test:embedded --test_arg=-test.parallel=4",
// The tier's only pre-merge run (D2 step 1) must execute, like the
// legacy jobs' -test.count=1, never replay a cached result.
"test:embedded --nocache_test_results",
} {
if !rc[want] {
t.Errorf(".bazelrc lacks %q", want)
@ -5248,13 +5250,11 @@ func TestBazelEmbeddedJobMirrorsEmbeddedTier(t *testing.T) {
t.Errorf("setup-bazel's generated rc selects or narrows tests; it may only configure remote execution")
}
for line := range rc {
// Nothing turns result caching back on for the embedded lane (a
// later --cache_test_results wins over --nocache_test_results).
// Result caching: only the docker lane and nightly's fresh config
// turn it off (ci_merge_queue_test.go).
if !strings.HasPrefix(line, "#") && strings.Contains(line, "cache_test_results") &&
line != "test:embedded --nocache_test_results" && line != "test:docker --nocache_test_results" &&
line != "test:doltserver-proxied --nocache_test_results" && line != "test:doltserver-integration --nocache_test_results" &&
line != bazelSoleRunNoCacheLine {
t.Errorf(".bazelrc %q: only test:embedded and test:docker set test result caching", line)
line != "test:docker --nocache_test_results" && line != bazelFreshRCLine {
t.Errorf(".bazelrc %q: only test:docker and test:fresh set test result caching", line)
}
if strings.HasPrefix(line, "test:embedded ") && (strings.Contains(line, "-test.short") || strings.Contains(line, "BEADS_TEST_SKIP")) {
t.Errorf(".bazelrc %q: the embedded jobs run without -short and BEADS_TEST_SKIP", line)
@ -5405,7 +5405,7 @@ func TestBazelPureJobMirrorsPureGoJob(t *testing.T) {
t.Errorf("%s PURE_CMD_BD_TESTS = %q, want pr.yml's -short -run selector %q", bazelPureJobName, job.Env["PURE_CMD_BD_TESTS"], m[1])
}
run := job.step(t, "Run pure-Go cmd/bd test subset (--config=pure)").Run
for _, required := range []string{"bazel test --config=pure " + bazelSoleRunArg + " //cmd/bd:bd_test", `"--test_arg=-test.run=$PURE_CMD_BD_TESTS"`, "(( n > 0 ))"} {
for _, required := range []string{"bazel test --config=pure " + bazelSoleRunArg + " " + bazelFreshArg + " //cmd/bd:bd_test", `"--test_arg=-test.run=$PURE_CMD_BD_TESTS"`, "(( n > 0 ))"} {
if !strings.Contains(run, required) {
t.Errorf("pure subset step does not contain %q:\n%s", required, run)
}

View file

@ -38,7 +38,6 @@ const (
// BAZEL_COVERS_FORKS covers it).
bazelSoleRunEnv = "${{ needs.rbe.outputs.enabled == 'true' && '--config=sole-run' || '' }}"
bazelSoleRunArg = `${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"}`
bazelSoleRunNoCacheLine = "test:sole-run --nocache_test_results"
bazelSoleRunEvictionLine = "test:sole-run --experimental_remote_cache_eviction_retries=0"
)
@ -100,7 +99,7 @@ var bazelPRLaneRCLines = map[string][]string{
"build:js-wasm --use_target_platform_for_tests",
"build:js-wasm --remote_download_outputs=toplevel",
},
"sole-run": {bazelSoleRunNoCacheLine, bazelSoleRunEvictionLine},
"sole-run": {bazelSoleRunEvictionLine},
}
// The steps of step 3's lanes that run Bazel, exactly (as review F4 of
@ -111,7 +110,7 @@ var bazelPRLaneSteps = map[string]map[string]string{
"bazel test //... --config=ci": `set -o pipefail
start=$(date +%s)
rc=0
bazel test //... --config=ci ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} \
bazel test //... --config=ci ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
--profile="$RUNNER_TEMP/bazel-profile.json" \
--build_event_json_file="$RUNNER_TEMP/bazel-bep.json" \
2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
@ -122,14 +121,14 @@ exit "$rc"`,
bazelPureJobName: {
"Start every pure-Go artifact (gozstd contamination check)": `set -euo pipefail
bazel run --config=pure //cmd/bd:bd -- version
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} \
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} \
//internal/storage/embeddeddolt:embeddeddolt_test \
//internal/tracker:tracker_test \
--test_sharding_strategy=disabled \
'--test_arg=-test.run=^$' \
--test_env=BEADS_TEST_SKIP=dolt`,
"Run pure-Go cmd/bd test subset (--config=pure)": `set -euo pipefail
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} //cmd/bd:bd_test \
bazel test --config=pure ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} //cmd/bd:bd_test \
--test_sharding_strategy=disabled \
"--test_arg=-test.run=$PURE_CMD_BD_TESTS"
n="$(grep -c '<testcase ' bazel-testlogs/cmd/bd/bd_test/test.xml || true)"
@ -140,7 +139,7 @@ echo "pure cmd/bd subset: $n test cases"
"bazel test //... --config=doltserver": `set -o pipefail
start=$(date +%s)
rc=0
bazel test //... "--config=$BAZEL_DOLT_LANE" ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
bazel test //... "--config=$BAZEL_DOLT_LANE" ${BAZEL_SOLE_RUN:+"$BAZEL_SOLE_RUN"} ${BAZEL_FRESH:+"$BAZEL_FRESH"} 2>&1 | tee "$RUNNER_TEMP/bazel-test.log" || rc=$?
echo "bazel test --config=$BAZEL_DOLT_LANE: exit $rc, $(( $(date +%s) - start ))s wall" | tee -a "$GITHUB_STEP_SUMMARY"
exit "$rc"`,
},
@ -287,6 +286,22 @@ func TestPRLegacyLanesDeferToBazelLanes(t *testing.T) {
add("covered, remote, lanes passed, legacy skipped", prGateFor(t, lanes, "pull_request", "remote", cov("true")), true, "")
add("not covered, remote, legacy ran", prGateFor(t, lanes, "pull_request", "remote", cov("false")), true, "")
add("merge_group, not covered, remote", prGateFor(t, lanes, "merge_group", "remote", cov("false")), true, "")
// The merge queue retires the legacy jobs like a same-repo PR
// (bazel-coverage covers every merge group): green with the lanes run
// remotely, red when a lane failed or the run was not remote.
add("merge_group, covered, remote, lanes passed, legacy skipped", prGateFor(t, lanes, "merge_group", "remote", cov("true")), true, "")
for _, lane := range tier.bazelLanes {
sc := prGateFor(t, lanes, "merge_group", "remote", cov("true"))
sc.outputs[lane] = "failure"
add("merge_group, covered, "+lane+" failed", sc, false, tier.retiredID)
}
for _, mode := range []string{"skip", "cache"} {
sc := prGateFor(t, lanes, "merge_group", mode, cov("true"))
for _, lane := range tier.bazelLanes {
sc.outputs[lane] = "success"
}
add("merge_group, covered, mode "+mode+", lanes reported success", sc, false, tier.retiredID)
}
// rbe-fork: a covered fork or Dependabot PR (BAZEL_COVERS_FORKS) whose
// lanes ran remotely with a mint certificate.
for _, mode := range []string{"fork-ro", "fork-rw"} {
@ -449,8 +464,9 @@ func testPackageGateJobs(t *testing.T, prGateRequired []string) {
detect := job.step(t, "Decide applicability")
wantDetectEnv := map[string]string{
"PR_BASE_SHA": "${{ github.event.pull_request.base.sha }}",
"PR_HEAD_SHA": "${{ github.event.pull_request.head.sha }}",
// The merge queue's bounds where there is no pull_request.
"PR_BASE_SHA": "${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}",
"PR_HEAD_SHA": "${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}",
"PUSH_BEFORE_SHA": "${{ github.event.before }}",
"PUSH_AFTER_SHA": "${{ github.sha }}",
}

View file

@ -33,6 +33,10 @@ const (
prRiskWorkflowName = "pr-risk.yml"
prRiskCoverageJobName = "bazel-coverage"
prRiskPullRequestValue = "${{ github.event_name == 'pull_request' }}"
// A merge group (merge queue) is covered like a same-repo PR: it runs
// on this repository's gh-readonly-queue/* branch with the CI secrets
// and its actor is github-merge-queue[bot].
prRiskMergeGroupValue = "${{ github.event_name == 'merge_group' }}"
// pr-risk.yml's and pr.yml's gate id for the decision job's result.
prRiskCoverageGateID = "BAZEL_COVERAGE"
// build-embedded's artifact (embedded-test-binaries) feeds exactly the
@ -160,12 +164,20 @@ func (f rbeFacts) String() string {
f.event, f.rbeVar, f.secret != "", f.fork, f.retired, f.dependabot, f.coversForks, f.mint)
}
// covers: whether a pull_request with tier i's flag set is covered, the
// decision both workflows must take for tier i: same-repo, non-Dependabot
// PRs always; fork and Dependabot PRs while BAZEL_COVERS_FORKS is "true".
// Never what the mint says: a covered fork run it does not serve is red.
// covers: whether a run with tier i's flag set is covered, the decision
// both workflows must take for tier i: every merge group (the queue's
// branch is this repository's, with the CI secrets; bazel.yml's rbe job
// never treats it as a fork); same-repo, non-Dependabot PRs always; fork
// and Dependabot PRs while BAZEL_COVERS_FORKS is "true". Never what the
// mint says: a covered fork run it does not serve is red.
func (f rbeFacts) covers(i int) bool {
return strings.EqualFold(f.retired[i], "true") && f.event == "pull_request" &&
if !strings.EqualFold(f.retired[i], "true") {
return false
}
if f.event == "merge_group" {
return true
}
return f.event == "pull_request" &&
(!f.fork && !f.dependabot || strings.EqualFold(f.coversForks, "true"))
}
@ -259,6 +271,8 @@ func evalRBEExpr(t *testing.T, expr string, f rbeFacts, with map[string]string)
return ""
case prRiskPullRequestValue:
return strconv.FormatBool(f.event == "pull_request")
case prRiskMergeGroupValue:
return strconv.FormatBool(f.event == "merge_group")
case prRiskDependabotValue:
return strconv.FormatBool(f.dependabot)
case "${{ vars.RBE_WEST_WORKERS == 'true' }}":
@ -330,7 +344,7 @@ func TestPRRiskBazelCoverageJob(t *testing.T) {
prRiskCoverageJobName, job.Needs, job.If, job.RunsOn, job.Env, job.ContinueOnError, job.TimeoutMinutes, sameRepoBlacksmith2vcpu)
}
wantOutputs := map[string]string{}
wantEnv := map[string]string{"PULL_REQUEST": prRiskPullRequestValue, "DEPENDABOT": prRiskDependabotValue, "COVERS_FORKS": prCoversForksValue}
wantEnv := map[string]string{"PULL_REQUEST": prRiskPullRequestValue, "MERGE_GROUP": prRiskMergeGroupValue, "DEPENDABOT": prRiskDependabotValue, "COVERS_FORKS": prCoversForksValue}
for _, r := range retiredTiers {
wantOutputs[r.output] = "${{ steps.decide.outputs." + r.output + " }}"
wantEnv[r.envKey] = r.retiredValue()
@ -708,8 +722,13 @@ func TestPRRiskDecisionMatchesBazelMode(t *testing.T) {
{"covered Dependabot PR, rbe-fork ro", rbeFacts{"pull_request", "true", "", false, both, true, "true", "ro"}, "fork-ro", coveredAll("true"), true, nil},
{"covered Dependabot PR, rbe-fork closed", rbeFacts{"pull_request", "", "", false, both, true, "true", "closed"}, "cache", coveredAll("true"), false, allRetired},
{"covered fork PR, only pr.yml's jobs retired, rbe-fork closed", rbeFacts{"pull_request", "true", "", true, prOnly, false, "true", "closed"}, "cache", map[string]string{"embedded": "false", "dolt_server": "false", "pr_lanes": "true"}, false, []string{"BAZEL_PR_LANES_RETIRED"}},
{"merge_group", rbeFacts{"merge_group", "true", "x", false, both, false, "false", ""}, "remote", coveredAll("false"), true, nil},
{"merge_group, var unset", rbeFacts{"merge_group", "", "x", false, both, false, "false", ""}, "skip", coveredAll("false"), true, nil},
// Merge queue: covered like a same-repo PR (the legacy tiers stay
// retired), so the Bazel lanes must run remotely and pass.
{"merge_group", rbeFacts{"merge_group", "true", "x", false, both, false, "false", ""}, "remote", coveredAll("true"), true, nil},
{"merge_group, kill switch (var unset)", rbeFacts{"merge_group", "", "x", false, both, false, "false", ""}, "skip", coveredAll("true"), false, allRetired},
{"merge_group, executor secret missing", rbeFacts{"merge_group", "true", "", false, both, false, "false", ""}, "cache", coveredAll("true"), false, allRetired},
{"merge_group, flags reverted, var unset", rbeFacts{"merge_group", "", "x", false, none, false, "false", ""}, "skip", coveredAll("false"), true, nil},
{"merge_group, only embedded retired", rbeFacts{"merge_group", "true", "x", false, embOnly, false, "false", ""}, "remote", map[string]string{"embedded": "true", "dolt_server": "false", "pr_lanes": "false"}, true, nil},
} {
d := decide(t, c.f)
if !reflect.DeepEqual(d.covered, c.covered) || d.mode != c.mode {
@ -1903,8 +1922,8 @@ func bazelTierTestRun(config string) string {
// .bazelrc's --config=doltserver-proxied and --config=doltserver-integration,
// exactly and in order (D2 step 2, as review F4 for embedded): no
// --test_filter, no -test.short/-test.run/-test.skip, no retries, no result
// caching. Their targets' own args (the conformance target's -test.run, the
// --test_filter, no -test.short/-test.run/-test.skip, no retries (results
// are cached like every lane's; nightly's --config=fresh re-executes). Their targets' own args (the conformance target's -test.run, the
// legacy job's) are pinned by TestBazelRetiredLanesCannotBeNarrowed.
var bazelDoltServerRCLines = map[string][]string{
"doltserver-proxied": {
@ -1918,7 +1937,6 @@ var bazelDoltServerRCLines = map[string][]string{
"test:doltserver-proxied --test_arg=-test.parallel=4",
"test:doltserver-proxied --local_test_jobs=4",
"test:doltserver-proxied --remote_download_regex=.*/test\\.(log|xml)$",
"test:doltserver-proxied --nocache_test_results",
"test:doltserver-proxied --experimental_remote_cache_eviction_retries=0",
},
"doltserver-integration": {
@ -1933,15 +1951,14 @@ var bazelDoltServerRCLines = map[string][]string{
"test:doltserver-integration --test_arg=-test.parallel=4",
"test:doltserver-integration --local_test_jobs=4",
"test:doltserver-integration --remote_download_regex=.*/test\\.(log|xml)$",
"test:doltserver-integration --nocache_test_results",
"test:doltserver-integration --experimental_remote_cache_eviction_retries=0",
},
}
// D2 step 2, as review F2/F4 for embedded: the proxied and server lanes run
// exactly `bazel test //... --config=<config>` with a BEP and nothing else,
// their configs are exactly the pinned lines (results never cached), and no
// .bazelrc line of any config turns caching back on for them.
// exactly `bazel test //... --config=<config>` (plus nightly's BAZEL_FRESH)
// with a BEP and nothing else, their configs are exactly the pinned lines,
// and only test:docker and test:fresh set result caching.
func TestBazelRetiredLanesArePinned(t *testing.T) {
workflow := readCIWorkflow(t, bazelWorkflowName)
for lane, config := range bazelRetiredLaneConfigs {
@ -1963,9 +1980,8 @@ func TestBazelRetiredLanesArePinned(t *testing.T) {
if !reflect.DeepEqual(got, want) {
t.Errorf(".bazelrc --config=%s lines changed; want exactly:\n%s\ngot:\n%s", config, strings.Join(want, "\n"), strings.Join(got, "\n"))
}
if !contains(want, "test:"+config+" --nocache_test_results") {
t.Errorf("pinned --config=%s lacks --nocache_test_results: the tier's only pre-merge run must execute", config)
}
// Results are cached like every lane's; only nightly's
// --config=fresh re-executes them (ci_merge_queue_test.go).
}
// Review F1 (step 2): no whole-invocation retry after a remote cache
// eviction in any retired lane (it would re-run, and could turn green,
@ -1990,14 +2006,13 @@ func TestBazelRetiredLanesArePinned(t *testing.T) {
}
}
// A later --cache_test_results (any config the lanes use) would win.
allowed := map[string]bool{"test:docker --nocache_test_results": true, "test:embedded --nocache_test_results": true, bazelSoleRunNoCacheLine: true}
for config := range bazelDoltServerRCLines {
allowed["test:"+config+" --nocache_test_results"] = true
}
// Only the docker lane and nightly's --config=fresh (appended only when
// the caller asks, ci_merge_queue_test.go) turn result caching off.
allowed := map[string]bool{"test:docker --nocache_test_results": true, bazelFreshRCLine: true}
for _, line := range strings.Split(rc, "\n") {
line = strings.TrimSpace(line)
if !strings.HasPrefix(line, "#") && strings.Contains(line, "cache_test_results") && !allowed[line] {
t.Errorf(".bazelrc %q: only the docker and retired tiers' configs set test result caching (to off)", line)
t.Errorf(".bazelrc %q: only test:docker and test:fresh set test result caching", line)
}
}
}