Skip to content

Commit dcf5863

Browse files
committed
fix(ci): skip the diff-based audits on branch creation instead of guessing a base
Follow-up to #7033, which merged with this thread open. A push that creates a branch reports an all-zero `github.event.before`, and the fallback answered that with `HEAD~1` — auditing the single tip commit while reporting on the whole push. That is the same partial-audit-reported-as-complete failure #7033 set out to remove, one case further along. There is no correct base to substitute here: nothing precedes the push, and diffing the whole history would lint every migration ever written. So the audits now skip with a `::notice::` naming the reason. A stated skip is honest; a partial audit wearing a green check is not. Reachable only by deleting and recreating `main`, `staging` or `dev`, so this fixes a gap rather than an incident. Dropping the fallback also drops its only consumer: `fetch-depth: 2` existed to give `HEAD~1` something to resolve to, and `before` is fetched by SHA, so the checkout returns to the default depth. Net -9 lines against #7033. Verified both audits still pass against a raw SHA base.
1 parent efe8a14 commit dcf5863

1 file changed

Lines changed: 19 additions & 28 deletions

File tree

.github/workflows/test-build.yml

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,8 @@ jobs:
1414
timeout-minutes: 15
1515

1616
steps:
17-
# The diff-based audits below need a base commit to read, and the default
18-
# depth of 1 clones a single commit with no parent. They normally fetch
19-
# their base by SHA (see "Resolve base ref"), so this depth only covers the
20-
# `HEAD~1` fallback — but without it that fallback resolves to nothing.
21-
#
22-
# Worth stating because the failure was invisible for so long: the migration
23-
# audit read the resulting `git diff` failure as "no migrations changed" and
24-
# exited 0, so it had never actually run on a push build.
2517
- name: Checkout code
2618
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
27-
with:
28-
fetch-depth: 2
2919

3020
- name: Setup Bun
3121
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
@@ -114,39 +104,39 @@ jobs:
114104
115105
echo "✅ All env flags are properly configured"
116106
117-
# One fetch for both base-ref audits, and no `|| true`: a swallowed fetch leaves
118-
# the base ref absent, which neither audit can tell apart from a branch that
119-
# changed nothing. The block-registry check at least degrades to a visible
120-
# `⚠ … skipping` line; the migration audit printed `✓ No new migrations to
121-
# check` and exited 0, clearing the only guard on production DDL.
122-
#
123-
# Depth stays at 1 — without a merge-base the migration audit diffs the two
124-
# tips, which under `--diff-filter=AM` is exactly the migrations new here.
125107
# Resolved once for both diff-based audits, and never with `|| true`: a
126108
# swallowed fetch leaves the base absent, which neither audit can tell apart
127-
# from a branch that changed nothing.
109+
# from a branch that changed nothing. That is how the migration audit came
110+
# to print `✓ No new migrations to check` and exit 0 on every push build,
111+
# having read nothing — and it is the only guard on production DDL.
128112
#
129113
# On push the base is `github.event.before`, the tip the branch had before
130-
# this push — not `HEAD~1`, which names only the last commit and would let a
131-
# multi-commit push slip every earlier commit's migrations past the audit.
132-
# It is fetched by SHA at depth 1; the audits diff two tips and need no
133-
# common ancestry. An all-zero `before` means the branch is new and has no
134-
# predecessor to diff, so `HEAD~1` remains the fallback there.
114+
# this push. It is fetched by SHA at depth 1, so the checkout needs no extra
115+
# history; the audits diff two tips and need no common ancestry between them.
116+
#
117+
# A push that creates the branch reports an all-zero `before` and genuinely
118+
# has no predecessor, so the audits skip with a notice rather than falling
119+
# back to a commit. Auditing one commit while reporting on the whole push is
120+
# the failure this step exists to remove.
135121
- name: Resolve base ref for diff-based audits
136122
id: audit_base
137123
run: |
138124
if [ "${{ github.event_name }}" = "pull_request" ]; then
139125
git fetch --depth=1 origin "${{ github.base_ref }}"
140126
echo "ref=origin/${{ github.base_ref }}" >> "$GITHUB_OUTPUT"
141-
elif [ -n "${{ github.event.before }}" ] &&
142-
[ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
127+
elif [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
128+
# Branch creation: nothing precedes this push, so there is no base to
129+
# diff against. Say so and let the audits skip. Naming a commit here
130+
# would audit that one commit while reporting on the whole push.
131+
echo "::notice::Branch created — no preceding commit to diff against; skipping the diff-based audits."
132+
echo "ref=" >> "$GITHUB_OUTPUT"
133+
else
143134
git fetch --depth=1 origin "${{ github.event.before }}"
144135
echo "ref=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
145-
else
146-
echo "ref=HEAD~1" >> "$GITHUB_OUTPUT"
147136
fi
148137
149138
- name: Check block registry invariants
139+
if: steps.audit_base.outputs.ref != ''
150140
run: bun run apps/sim/scripts/check-block-registry.ts "${{ steps.audit_base.outputs.ref }}"
151141

152142
- name: Lint code
@@ -162,6 +152,7 @@ jobs:
162152
run: bun run docs-manifest:check
163153

164154
- name: Migration safety (zero-downtime) audit
155+
if: steps.audit_base.outputs.ref != ''
165156
run: bun run check:migrations "${{ steps.audit_base.outputs.ref }}"
166157

167158
# Every workspace, not just realtime. packages/emcn, packages/utils,

0 commit comments

Comments
 (0)