Skip to content

fix(ci): skip the diff-based audits on branch creation instead of guessing a base - #7034

Open
waleedlatif1 wants to merge 1 commit into
stagingfrom
fix-branch-creation-audit-skip
Open

fix(ci): skip the diff-based audits on branch creation instead of guessing a base#7034
waleedlatif1 wants to merge 1 commit into
stagingfrom
fix-branch-creation-audit-skip

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Follow-up to #7033, which merged with a Greptile P1 thread still open. This closes it.

The finding

Branch creation audits only tip — when the first push creates main, staging, or dev with multiple commits, the all-zero github.event.before selects HEAD~1, so both audits inspect only the final commit.

Correct. It is the same failure #7033 set out to remove — a partial audit reported as a complete one — one case further along.

Why there is no base to substitute

Nothing precedes a branch-creating push. The alternatives are both wrong:

  • HEAD~1 audits one arbitrary commit and reports on the whole push.
  • The whole history would lint every migration ever written; --all mode already exits 1 on this repo for exactly that reason.

So the audits now skip, and say so:

::notice::Branch created — no preceding commit to diff against; skipping the diff-based audits.

A stated skip is honest. A partial audit wearing a green check is what this whole line of work exists to stop.

Reachability

Only by deleting and recreating main, staging or dev — the three branches the push trigger covers, all of which exist. This closes a gap, not an incident, and I'd rather say that plainly than dress it up.

It makes #7033 smaller

fetch-depth: 2 existed solely to give the HEAD~1 fallback something to resolve to. With the fallback gone its only consumer goes too, and since before is fetched by SHA the checkout returns to its default depth — untouched, as it was before #7033.

Net −9 lines against #7033.

Verification

  • HEAD~1 no longer appears anywhere in the workflow
  • Both audits still pass against a raw SHA base (exit=0)
  • YAML parses; both audit steps carry the same if: steps.audit_base.outputs.ref != '' guard, so they cannot diverge on when they run

@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 24, 2026 8:25am

Request Review

@cursor

cursor Bot commented Aug 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CI-only workflow tweak. Branch-create pushes (rare for existing protected branches) skip the DDL/registry audits instead of running a misleading partial check.

Overview
Stops the migration and block-registry audits from treating a branch-creating push as a one-commit diff.

When github.event.before is the all-zero SHA, the workflow no longer falls back to HEAD~1 (which audited only the tip while reporting on the whole push). It now emits a notice, leaves the base ref empty, and both audit steps skip via if: steps.audit_base.outputs.ref != ''.

Checkout also drops fetch-depth: 2, which existed only for that fallback; push bases are still fetched by SHA at depth 1.

Reviewed by Cursor Bugbot for commit dcf5863. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces the HEAD~1 fallback with an explicit skip for branch-creating pushes and removes the checkout depth that supported that fallback.

  • Resolves push and pull-request audit bases once for both diff-based checks.
  • Skips both audits with a notice when github.event.before is all zeros.
  • Reverts checkout to its default shallow depth.
  • Leaves manual workflow dispatches without a valid base-ref path.

Confidence Score: 4/5

The PR should not merge until manual workflow dispatches handle their absent before value without failing the test-build job.

The new resolver assumes every non-PR, non-creation event supplies a push base SHA, but the workflow also declares workflow_dispatch, whose empty before reaches an invalid fetch.

Files Needing Attention: .github/workflows/test-build.yml

Important Files Changed

Filename Overview
.github/workflows/test-build.yml Correctly skips audits for branch creation, but the revised event branching breaks the workflow's direct manual-dispatch path.

Reviews (1): Last reviewed commit: "fix(ci): skip the diff-based audits on b..." | Re-trigger Greptile

Comment thread .github/workflows/test-build.yml Outdated
Comment on lines 127 to 134
elif [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
# Branch creation: nothing precedes this push, so there is no base to
# diff against. Say so and let the audits skip. Naming a commit here
# would audit that one commit while reporting on the whole push.
echo "::notice::Branch created — no preceding commit to diff against; skipping the diff-based audits."
echo "ref=" >> "$GITHUB_OUTPUT"
else
git fetch --depth=1 origin "${{ github.event.before }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Manual dispatch base resolution fails

When this workflow runs through its declared workflow_dispatch trigger, github.event.before is empty rather than the all-zero branch-creation value, so the resolver executes git fetch --depth=1 origin "", causing the base-resolution step and the manually dispatched test-build job to fail.

… guessing one

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. Nothing precedes the push, and diffing
the whole history would lint every migration ever written. So the audits skip
with a `::notice::` naming the reason. A stated skip is honest; a partial audit
wearing a green check is not.

The same branch also covers `workflow_dispatch`, where `before` is empty rather
than all-zero because there is no push payload at all. The guard has to test both
— an empty `before` reaching the fetch would run `git fetch origin ""` and fail
the job outright, which this workflow allows since it declares `workflow_dispatch`.

Dropping the fallback 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.

Traced all four event shapes through the branch — PR, ordinary push, branch
creation, manual dispatch — and verified both audits still pass against a raw SHA
base.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant