Skip to content

#150 — harden pr-preview cleanup commit guard (explicit staged-check) - #151

Merged
cmbays merged 1 commit into
mainfrom
ci-150-cleanup-commit-guard
Jun 8, 2026
Merged

cmbays merged 1 commit into
mainfrom
ci-150-cleanup-commit-guard

Conversation

@cmbays

@cmbays cmbays commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pr-preview-cleanup.yml (and the mirrored consumer recipe §8) ended the
cleanup with git commit … || exit 0. That swallows the intended no-op
(nothing staged when the pr-<N>/ dir was already absent) — but it also
swallows a genuine commit failure (a hook or git-config error), silently
leaving a stale preview dir behind. gemini-code-assist flagged this on PR #149.

Change

Replace || exit 0 with an explicit staged-changes check, in both the
dogfood workflow and the recipe snippet (kept in sync — dogfood ≡ recipe):

git rm -r --ignore-unmatch "pr-${PR_NUMBER}"
if git diff --cached --quiet; then
  echo "No pr-${PR_NUMBER}/ preview to remove — nothing to clean up."
  exit 0
fi
git commit -m "…"
git push

Already-absent dir → skip cleanly (green). A real commit failure now surfaces
red instead of being masked into a silent stale-dir.

Validation

  • actionlint clean (it runs the bundled shellcheck on the run: block).
  • shellcheck clean on the extracted script.
  • Zero crate code changed → ci: prefix (no version bump).

Do not merge — Christopher's call.

Closes #150

🤖 Generated with Claude Code


Open in Stage

Summary by CodeRabbit

  • Chores

    • Improved PR preview cleanup workflow to validate changes before committing, ensuring stale preview directories are properly removed without suppressing errors.
  • Documentation

    • Updated workflow documentation to reflect improved cleanup logic.

The pr-preview-cleanup workflow (and the mirrored recipe §8) used
`git commit … || exit 0`, which ends green when nothing is staged — but
also masks a *genuine* commit failure (hook/config error), silently
leaving a stale pr-<N>/ preview dir behind. Replace with an explicit
`git diff --cached --quiet` staged-changes check: skip cleanly when the
preview dir was already absent, but let a real commit failure surface red.

Kept the dogfood workflow and the consumer recipe snippet in sync
(dogfood ≡ recipe). actionlint + shellcheck clean.

Closes #150

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ghost

ghost commented Jun 8, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 2 individual chapters for you:

Title
1 Harden dogfood workflow commit guard
2 Update recipe documentation with hardened commit guard
Open in Stage

Chapters generated by Stage for commit ad36175 on Jun 8, 2026 1:38am UTC.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0f7f4f00-97a8-4a4a-b44e-098b33c756c6

📥 Commits

Reviewing files that changed from the base of the PR and between 6777d16 and ad36175.

📒 Files selected for processing (2)
  • .github/workflows/pr-preview-cleanup.yml
  • book/src/recipes/github-actions-pr-review.md

📝 Walkthrough

Walkthrough

The PR hardens the PR preview cleanup workflow and its recipe by replacing conditional commit failure suppression with an explicit staged-changes guard. Both .github/workflows/pr-preview-cleanup.yml and the recipe documentation now check whether git rm staged any changes before committing, exiting cleanly if nothing was removed and only proceeding with the commit when staged changes exist.

Changes

Cleanup commit guard hardening

Layer / File(s) Summary
Staged-changes guard and cleanup commit
.github/workflows/pr-preview-cleanup.yml, book/src/recipes/github-actions-pr-review.md
The workflow and recipe replace git commit ... || exit 0 with an explicit git diff --cached --quiet check that exits early if no staged changes are present, then proceeds to commit only when deletions were staged. This prevents real commit errors from being masked and ensures the cleanup behavior is intentional rather than silent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A cleanup once hid its true shame,
With exit 0 masking blame—
Now staged changes shine so clear,
No more silent errors here!
The workflow stands guard, strong and true. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: hardening the cleanup commit guard by using an explicit staged-change check instead of || exit 0.
Linked Issues check ✅ Passed The PR successfully implements both acceptance criteria from #150: replaces || exit 0 with explicit git diff --cached --quiet check in both pr-preview-cleanup.yml and the recipe, and validates with actionlint and shellcheck.
Out of Scope Changes check ✅ Passed All changes are directly related to the #150 objective: modifying the cleanup logic in the workflow file and recipe to replace error-masking || exit 0 with explicit staged-changes checks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci-150-cleanup-commit-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the GitHub Actions PR review recipe in the documentation. It replaces the git commit ... || exit 0 command with an explicit check for staged changes using git diff --cached --quiet to avoid silently masking genuine commit failures. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

📄 Rendered report preview

All golden examples regenerated cleanly.

🟡 Golden examples

Committed to examples/ and byte-identity gated — the canonical reports contributors and consumers browse. Stable across PRs.

Report View Download
jaffle-shop-report.html ▶ Open ↗ ⬇ Download
playground-report.html ▶ Open ↗ ⬇ Download
diff-showcase-report.html ▶ Open ↗ ⬇ Download

🐶 Live dogfood preview

This PR doesn't touch dbt-project/, so there's no live dogfood preview.

▶ Open ↗ opens the report in your browser in one click —
published to this repo's GitHub Pages under /pr-151/.
⬇ Download fetches the same self-contained HTML as a workflow
artifact (auth-gated; works fully offline). Either way the report
makes zero external resource requests.

The Pages preview may take ~1 min to update after this comment
posts. On PRs from forks the Open link is unavailable (read-only
token) — use Download.

Alternative: GitHub CLI
# gh CLI >= 2.63 extracts into ./report-preview-playground/.
gh run download 27111264353 -R breezy-bays-labs/cute-dbt -n report-preview-playground
open report-preview-playground/playground-report.html

Posted by report-preview.yml for ad361755f5f41a62779f8b9ce01b02c704dfaf45. Affordance only — never blocks merge.

@cmbays
cmbays merged commit e6d3df7 into main Jun 8, 2026
31 checks passed
@cmbays
cmbays deleted the ci-150-cleanup-commit-guard branch June 8, 2026 01:54
github-actions Bot added a commit that referenced this pull request Jun 8, 2026
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.

Harden pr-preview cleanup commit guard (avoid || exit 0 masking real failures)

1 participant