Skip to content

ci: harden trunk gating - #488

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

Low Risk
Workflow-only changes that restrict when CI runs and strengthen merge policy; no application or secrets logic changes.

Overview
Tightens trunk → main CI so expensive jobs only run when the PR is this repo’s trunk branch targeting main, not merely when the head ref is named trunk (e.g. forks or wrong bases).

The shared job if in CI, container-integration, and preview cleanup now requires github.event.pull_request.head.repo.full_name == github.repository and github.base_ref == 'main' alongside github.head_ref == 'trunk'.

Trunk guard switches to pull_request_target (with edited), empty permissions, and fails when the head isn’t trunk or the head repo isn’t the upstream repository—so the guard runs from base-branch workflow code and blocks fork or non-trunk merges into main.

Reviewed by Cursor Bugbot for commit 37c3236. 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 8436dc7 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: c6534cfb-fd08-4545-b840-3bb59aa7d9b3
📥 Commits

Reviewing files that changed from the base of the PR and between 57f8e21 and 37c3236.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .github/workflows/container-integration.yml
  • .github/workflows/preview.yml
  • .github/workflows/trunk-guard.yml
 ______________________________________________________________
< I had to scroll so far I hit the heat death of the universe. >
 --------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ 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 found 1 potential issue.

Devin Review

name: Cleanup Preview
if: >-
((github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.head_ref == 'trunk') &&
((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
Contributor

Choose a reason for hiding this comment

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

🟡 Closed preview workers remain deployed

When a feature PR with a preview worker closes, cleanup-preview skips deletion because its head is not trunk. The worker remains deployed after the PR closes.

Learn more

Preview workers were previously deployed for same-repository feature PRs by the deploy-preview job before trunk gating removed it. The current cleanup job runs only on closed events, but the trunk-only predicate discards those events for feature PRs. The remaining predicate already restricts deletion to same-repository PRs, and a closed PR always has a closed state. This leaves previously deployed workers active unless the separate audit runs in removal mode.

Example: PR #400 deployed relaycast-pr-400 before trunk gating. Closing PR #400 from feature/search skips cleanup, leaving the worker active instead of deleting it.

Recommended fix: Gate cleanup-preview only on a closed event from the same repository. Keep the existing same-repository restriction and delete both worker names as before.

Suggested change
((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')) &&
(github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == github.repository) &&

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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

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 37c3236. Configure here.

name: Cleanup Preview
if: >-
((github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.head_ref == 'trunk') &&
((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
Contributor

Choose a reason for hiding this comment

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

Closed cleanup remains trunk-gated

Medium Severity

cleanup-preview still requires a same-repo trunk → main pull request, so closing any other PR skips teardown. This change was supposed to ungate closed-only workflows, but the job kept the trunk gate and added base_ref plus head-repo checks.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 37c3236. 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