Skip to content

ci: harden trunk gating - #396

Merged
kjgbot merged 1 commit into
mainfrom
trunk
Oct 8, 2026
Merged

kjgbot merged 1 commit into
mainfrom
trunk

Conversation

@kjgbot

@kjgbot kjgbot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Hardens the trunk-only CI gating per review on AgentWorkforce/relay#1932: head repo + base branch checks in every gate; guard via pull_request_target with edited; closed-only workflows ungated.

🤖 Generated with Claude Code


Note

Medium Risk
Changes branch-protection and CI trigger logic; mistakes could block legitimate merges or skip checks, but no application runtime code is touched.

Overview
Tightens trunk-only CI so the heavy ci.yml jobs no longer run on every PR whose head branch is named trunk. On pull requests they now run only when the head is trunk, the PR targets main, and the head ref lives in this repository (not a fork).

Trunk guard is hardened for the same policy: it triggers on pull_request_target (workflow definition always comes from the base branch, with no PR checkout), uses minimal permissions, reacts to PR edited events, and fails merges that are not in-repo trunk → main, with an updated error message.

Reviewed by Cursor Bugbot for commit 5d6f874. Bugbot is set up for automated code reviews on this repo. Configure here.

- CI gates also require the head repo to be this repository and the base to
  be main (a fork branch named trunk, or trunk into another branch, no
  longer runs CI).
- Trunk guard runs via pull_request_target (loaded from the base branch, so
  a PR cannot edit it to pass), re-runs on base edits, and checks head repo.
- Workflows that only react to a PR closing are no longer gated.
@kjgbot
kjgbot merged commit c9feba4 into main Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc6e98cf-348a-4fda-b290-9757624f273a
📥 Commits

Reviewing files that changed from the base of the PR and between 388ba7b and 5d6f874.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • .github/workflows/trunk-guard.yml
 ______________________________________________________________________________________________________
< Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. - Alan Perlis >
 ------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5d6f874. Configure here.

Comment thread .github/workflows/ci.yml
jobs:
verify:
if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.head_ref == 'trunk'
if: (github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || (github.head_ref == 'trunk' && github.event.pull_request.head.repo.full_name == github.repository && github.base_ref == 'main')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI misses retargeted trunk PRs

Medium Severity

The new base_ref == 'main' condition skips every CI job when a same-repo trunk pull request does not already target main. ci.yml still uses default pull_request types, so changing the base to main does not start a new run, and the earlier skipped jobs can remain the passing required checks.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5d6f874. Configure here.

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