Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:

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.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
# fails on any `rusqlite` type in the listing: an embedder never holds a
# raw connection. See docs/sourcing-sdk.md.
public-api:
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
# published-crate-consumer workflow builds the same example against the
# crate crates.io actually serves.
rust-consumer:
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
# tell a regression here from breakage in burn. Making the job a required
# check is a branch-protection setting.
burn-contract-drift:
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')
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
run: node scripts/burn-guardrails.mjs run-parity --burn-dir burn

msrv:
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -244,7 +244,7 @@ jobs:
run: cargo check -p ai-hist --all-features --locked

node-22-sdk:
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -264,7 +264,7 @@ jobs:
run: npm ci && npm test

optional-history-plugins:
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')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -313,7 +313,7 @@ jobs:
node scripts/smoke-history-packages.mjs --helpers helper-packs

windows-helper-cancellation:
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')
runs-on: windows-latest
defaults:
run:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/trunk-guard.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: Trunk guard

# Only the `trunk` branch may merge into main. Feature branches merge into
# `trunk` (via the merge train); CI runs only on the trunk -> main PR.
# Only this repository's `trunk` branch may merge into main. Feature branches
# merge into `trunk`; CI runs only on the trunk -> main PR.
# pull_request_target loads this workflow from the base branch, so a PR cannot
# edit the guard to pass itself. It never checks out PR code.
on:
pull_request:
pull_request_target:
branches: [main]
types: [opened, synchronize, reopened, edited]

permissions: {}

jobs:
only-trunk-merges-to-main:
if: github.head_ref != 'trunk'
if: github.head_ref != 'trunk' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- run: |
echo "::error::Only the 'trunk' branch may merge into main. Retarget this PR to 'trunk'."
echo "::error::Only this repository's 'trunk' branch may merge into main. Retarget this PR to 'trunk'."
exit 1
Loading