Skip to content

fix(ci): Only auto-commit generated backend changes on pull requests - #131262

Merged
BYK merged 1 commit into
masterfrom
ci/gate-autocommit-on-pull-request
Nov 18, 2026
Merged

BYK merged 1 commit into
masterfrom
ci/gate-autocommit-on-pull-request

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Three steps in backend.yml commit generated changes back through getsentry/action-github-commit: requirements (re-freeze), api-url-typescript (URL sync), and typing (mypy blocklist). They only ran when github.ref != 'refs/heads/master'.

The action picks its target branch as process.env.GITHUB_HEAD_REF || 'master' (pinned 31f6706, src/main.ts and dist/index.js). GITHUB_HEAD_REF is only set for pull_request events. So any non-PR run off master passes the old guard and commits to master:

  • merge_group runs, where the ref is refs/heads/gh-readonly-queue/master/.... We're preparing to enable a merge queue, so this has to land first.
  • workflow_dispatch on any branch other than master. This can already happen today.

This PR gates the three steps on github.event_name == 'pull_request' instead. PR behavior doesn't change, and push-to-master already skipped them.

pre-commit.yml's autofix step is already gated on startsWith(github.ref, 'refs/pull'), so it's safe on merge_group and I left it alone. No other workflow in the repo uses action-github-commit.

Refs DI-2870

via @BYK.

--

View Session [Sentry]

@linear-code

linear-code Bot commented Nov 16, 2026

Copy link
Copy Markdown

DI-2870

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 16, 2026
@sentry-junior
sentry-junior Bot added this pull request to stack #131265 November 16, 2026 15:47
@BYK
BYK marked this pull request as ready for review November 17, 2026 12:54
@BYK
BYK requested a review from a team as a code owner November 17, 2026 12:54
@sentry-junior
sentry-junior Bot requested a review from BYK November 17, 2026 12:54
The requirements, api-url-typescript, and mypy blocklist steps commit through getsentry/action-github-commit, which targets GITHUB_HEAD_REF or falls back to master. Their guard only excluded refs/heads/master, so a merge_group run (ref gh-readonly-queue/master/...) or a workflow_dispatch on another branch would commit straight to master. Gate them on pull_request events, where GITHUB_HEAD_REF is the PR branch.

Refs DI-2870

Co-Authored-By: Burak Yigit Kaya <[email protected]>
@sentry-junior
sentry-junior Bot force-pushed the ci/gate-autocommit-on-pull-request branch from 33e5674 to dd5f810 Compare November 17, 2026 12:56
@BYK
BYK merged commit bab2647 into master Nov 18, 2026
68 checks passed
@BYK
BYK deleted the ci/gate-autocommit-on-pull-request branch November 18, 2026 09:53
BYK added a commit that referenced this pull request Nov 18, 2026
Stacked on #131262, which has to land first. Without it,
`backend.yml`'s auto-commit steps would commit straight to master from
merge queue runs.

This adds `merge_group: {types: [checks_requested]}` to `backend.yml`,
`frontend.yml`, `acceptance.yml`, and `pre-commit.yml`. It also adds
`merge_group` to the event allow-list on `acceptance.yml`'s
`files-changed` job, which only allowed `pull_request` and `push`.
Without that, the acceptance suite would skip on merge groups while
`Acceptance` still passed. Together these changes make sure `Backend`,
`Frontend`, `Acceptance`, and `pre-commit lint` report on merge queue
commits. **No merge queue is configured on master yet, so this does
nothing until one is enabled.** `getsentry / backend` needs a separate
dispatch change and is not part of this PR.

What a `merge_group` run does with the current workflows:

- **Change detection:** `dorny/paths-filter` v4.0.2 diffs
`merge_group.base_sha..head_sha`, so jobs are path-filtered like
push-to-master. In a batched queue, that diff covers every PR in the
group.
- **Test scope:** `select-tests` is PR-only in both `backend.yml` and
`acceptance.yml`, so the backend and acceptance suites run in full, and
`backend-migration-tests` runs too. `git-merge-base.sh` exits early on
any event other than `pull_request`, so Jest and oxlint run at full
scope. That's the right call: with squash merges a merge group commit
has no `HEAD^2`, and even with merge commits `HEAD^1..HEAD^2` would miss
the other PRs batched ahead of it.
- **Required-check jobs** (`Backend`, `Frontend`, `Acceptance`) use `if:
always()`. They report even when every job is filtered out.
- **Runners:** every runner check falls back to the master runners
(x86).
- **Concurrency:** `head_ref` is empty, so each group falls back to
`run_id`. Queue entries never cancel each other.
- **PR-only steps:** the steps that read `github.event.pull_request` are
already gated on `pull_request`, or fall back safely when the PR field
is empty: selected tests, failure reporting, lint baseline, suppression
pruning, and pre-commit autofix (`refs/pull`).
- **Lint ratchet:** oxlint runs `lint:suppressions --ci` without
`--base`, the same as master. Live debt still has to fit the committed
budgets.

`report-backend-test-failures` stays PR-only. It posts and cleans up a
comment on `context.payload.pull_request`, which a merge group doesn't
have. You could parse a PR number out of `merge_group.head_ref`, but in
a batched group that names only the last PR, which may not have caused
the failure. Its stale-comment cleanup would also delete that PR's own
failure report. The queue already links the failing check when it
removes an entry.

Refs DI-2871

<!-- junior-request-attribution:start -->
via @BYK, **michael**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ad99527799d5e0fe45fe4791535d47143 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ad99527799d5e0fe45fe4791535d47143)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ad99527799d5e0fe45fe4791535d47143/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Burak Yigit Kaya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant