From 071167cb2a0536725afae2b202aa40c84e17032f Mon Sep 17 00:00:00 2001 From: Stephen Freudenthaler Date: Wed, 2 Sep 2026 13:37:21 -0400 Subject: [PATCH] fix(ci): select the nightly build ref along main's first-parent line `git log --before=midnight -1` walks the whole reachable graph in commit-date order, not main's mainline. With squash merging disabled every feature-branch commit lands on main verbatim, carrying the commit date it had on the branch -- so a commit authored days ago but merged after the nightly ran can win the `-1`, and it was never main's tip. Reproduced against real history (all three most recent nightly windows pick a non-mainline commit today): 2026-08-31 without: e379884d35 Merge branch 'main' into nicobytes/issue-36850-... with: 31928163af fix(clustering): propagate system table set() ... 2026-09-01 without: f7294b1ac0 test(block-editor): cover codeBlock ... with: be94fd0a7f fix(evergreen-tracks): make dry-run unmissable ... The scheduled 03:30 runs got the right answer only by timing: e379884d35 is dated 2026-08-30T14:59Z but did not enter main until 2026-08-31T21:35Z, so the 03:31 run could not see it. That breaks the repeatability guarantee this branch of the script exists to provide -- re-running the 2026-08-31 nightly today to investigate a failure now builds a feature branch instead of main. --first-parent on both the midnight selection and the empty-result fallback. Also refreshes the commits/day figure the fetch-depth: 1000 bound is justified against: ~19/day under squash, ~40/day now (118 commits across v26.08.28-01...v26.08.31-01), so 1000 is ~25 days rather than ~52. Closes: #37202 Co-Authored-By: Claude Opus 5 --- .github/workflows/cicd_4-nightly.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cicd_4-nightly.yml b/.github/workflows/cicd_4-nightly.yml index 8f0b5b8e919f..0d359ebebc68 100644 --- a/.github/workflows/cicd_4-nightly.yml +++ b/.github/workflows/cicd_4-nightly.yml @@ -92,9 +92,10 @@ jobs: with: # Bounded shallow checkout: Find Build Commit walks `git log` on main # back to midnight UTC. The window that matters is commits landing - # between midnight and run time (~3h); max observed is ~19 commits/day, - # so 1000 commits is ~52 days of volume and can't realistically overrun - # the midnight boundary. use-latest-commit only needs HEAD. Avoids the + # between midnight and run time (~3h). Under merge commits every branch + # commit lands on main, so volume is ~40 commits/day (118 across + # v26.08.28-01...v26.08.31-01), making 1000 commits ~25 days — still far + # past the midnight boundary. use-latest-commit only needs HEAD. Avoids the # fetch-depth: 0 full fetch (~2k+ branches, ~1.1 GB pack) when only # main's recent history is consulted. fetch-depth: 1000 @@ -113,13 +114,17 @@ jobs: # Default for both scheduled and manual dispatch: use the last commit # at or before midnight UTC. This ensures repeatability — manually # re-running later in the day to investigate a failure gives the same build. + # --first-parent is load-bearing: squash merging is disabled, so every + # feature-branch commit lands on main verbatim. Without it, `git log` + # walks into a merged branch and can select a commit that was never + # main's tip — building a tree no one ever tested on main. MIDNIGHT=$(date -u +"%Y-%m-%dT00:00:00") - BUILD_REF=$(git log --before="${MIDNIGHT}" --format="%H" -1) + BUILD_REF=$(git log --first-parent --before="${MIDNIGHT}" --format="%H" -1) if [[ -z "${BUILD_REF}" ]]; then # No commits before today's midnight — use the absolute last commit. # This handles edge cases (e.g., very new repos) without falling back to # current HEAD which might include post-midnight commits. - BUILD_REF=$(git log --format="%H" -1) + BUILD_REF=$(git log --first-parent --format="%H" -1) echo "⚠️ No commit found before ${MIDNIGHT}, using last available commit: ${BUILD_REF}" else echo "Building from commit at midnight UTC (${MIDNIGHT}): ${BUILD_REF}"