From ae31e1c0a84df9fd5c3fbcfdd770f261a17f560c Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 11 Nov 2026 06:08:39 -0800 Subject: [PATCH] chore(cloud): premerge re-runs itself from the merged worktree and lists the tests it selected A branch cut before #437 ran its own old copy of premerge-check.sh (the integration merge only happened in the temp worktree), so #440's first gate selected 0 tests although the merged gate selects the parity test. The script now merges, then execs the merged copy; it also prints every targeted test file. --- .../cloud-integration/premerge-check.sh | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/config/scripts/cloud-integration/premerge-check.sh b/config/scripts/cloud-integration/premerge-check.sh index 094060062ea..6591db0daa9 100755 --- a/config/scripts/cloud-integration/premerge-check.sh +++ b/config/scripts/cloud-integration/premerge-check.sh @@ -5,17 +5,27 @@ # pnpm typecheck, the full pnpm lint suite (pre-commit hooks only lint staged files), and vitest for the tests your # branch touched: changed *.test.ts(x), every test in the folder of each changed source, every test that imports a # changed module, and each touched cloud/apps/* package's own suite. PREMERGE_FULL=1 runs the whole vitest suite. +# The merged copy of this script is what runs, so the gate is always integration's current one. # Prints "premerge OK" only when everything passes. Nothing here reads /tmp state. On macOS (no flock) wrap heavy runs # as /tmp/vdrv/heavy.sh 'config/scripts/cloud-integration/premerge-check.sh'. set -euo pipefail -branch=$(git rev-parse --abbrev-ref HEAD) -git fetch -q private +cloud/integration:refs/remotes/private/cloud/integration base=private/cloud/integration -dir=$(mktemp -d "${TMPDIR:-/tmp}/cloud-premerge-XXXX") -trap 'git worktree remove --force "$dir" >/dev/null 2>&1 || true' EXIT -git worktree add -q --detach "$dir" HEAD +if [[ -z "${PREMERGE_IN_WORKTREE:-}" ]]; then + branch=$(git rev-parse --abbrev-ref HEAD) + git fetch -q private +cloud/integration:refs/remotes/private/cloud/integration + dir=$(mktemp -d "${TMPDIR:-/tmp}/cloud-premerge-XXXX") + git worktree add -q --detach "$dir" HEAD + if ! (cd "$dir" && git merge -q --no-edit "$base"); then + git worktree remove --force "$dir" >/dev/null 2>&1 || true + exit 1 + fi + # Re-run the MERGED copy of this script, so a branch cut before a gate change still gets the current gate. + exec env PREMERGE_IN_WORKTREE="$dir" PREMERGE_BRANCH="$branch" bash "$dir/config/scripts/cloud-integration/premerge-check.sh" +fi +dir=$PREMERGE_IN_WORKTREE +branch=${PREMERGE_BRANCH:-unknown} +trap 'git -C "$dir" worktree remove --force "$dir" >/dev/null 2>&1 || true' EXIT cd "$dir" -git merge -q --no-edit "$base" pnpm install --frozen-lockfile >/dev/null pnpm typecheck pnpm lint @@ -47,6 +57,8 @@ else done < <(git diff --name-only --diff-filter=AMR "$base"...HEAD -- 'src/*') if ((${#tests[@]} > 0)); then tests=($(printf "%s\n" "${tests[@]}" | sort -u)) # repo paths have no spaces + echo "premerge: ${#tests[@]} targeted test file(s):" + printf " %s\n" "${tests[@]}" node config/scripts/workspace-package-build/build-workspace-packages.mjs >/dev/null node config/scripts/native-build/node-addons/ensure-native-runtime.mjs --runtime=node >/dev/null # run-vitest.mjs applies the repo's test env policy (e.g. ORCA_BACKGROUND_LAUNCH=1); bare vitest gives false failures.