Skip to content

ci: pass changed files to getsentry dispatch for selective testing#110668

Open
joshuarli wants to merge 4 commits intomasterfrom
ci-selective-testing-dispatch-clean
Open

ci: pass changed files to getsentry dispatch for selective testing#110668
joshuarli wants to merge 4 commits intomasterfrom
ci-selective-testing-dispatch-clean

Conversation

@joshuarli
Copy link
Member

@joshuarli joshuarli commented Mar 13, 2026

Clean version of #110103.

Won't be merged until https://github.com/getsentry/getsentry/pull/19553 goes in then this is tested.

Changes in this PR

  • backend.yml — Replaces the inline prepare-selective-tests job (120+ lines of GCS lookup, coverage download, test computation) with a 2-line call to getsentry/getsentry/.github/workflows/select-sentry-tests.yml@master. The reusable workflow has the same output interface (has-selected-tests, test-count) and uploads the same artifact name, so calculate-shards and backend-test work without modification.
    • unfortunately this can't be tested until getsentry's PR is merged
  • getsentry-dispatch.yml — Adds fetch-depth: 0 to checkout and a git diff --name-only step to compute changed files. Passes them to the dispatch script via SENTRY_CHANGED_FILES env var.
  • getsentry-dispatch.js — Accepts sentryChangedFiles parameter and forwards it as the sentry-changed-files workflow dispatch input to getsentry's backend.yml.
    • this also can't be tested until getsentry's PR is merged - currently it'll just dispatch getsentry full backend which is fine

requires https://github.com/getsentry/getsentry/pull/19553 to be merged to master first because of 2 constraints:

  1. Cross-repo reusable workflows must be on the default branch of the
    callee repo
  2. Dispatch always targets getsentry master

The only way to test end-to-end without merging: merge the getsentry PR
first. It's safe because:

  • The new sentry-changed-files input to backend.yml is optional with no
    default behavior change
  • select-sentry-tests.yml is a new file, only invoked when explicitly
    called
  • The select-tests and calculate-shards jobs in backend.yml only activate
    when sentry-changed-files is provided or it's a PR — existing dispatch
    behavior is unchanged
  • backend-with-coverage.yml only runs on schedule/dispatch, not on PRs or
    pushes

Once getsentry's merged I'll test:

  1. Sentry PR → prepare-selective-tests calls select-sentry-tests.yml@master
  2. Sentry dispatch → getsentry backend.yml on master receives
    sentry-changed-files

Compute changed files via GitHub API in the dispatch workflow and forward
them as the sentry-changed-files input to getsentry's backend.yml. This
enables getsentry to run only affected tests when a sentry PR is opened.

Also add commented-out cutover in backend.yml showing how to replace
prepare-selective-tests with getsentry's cross-repo coverage workflow.
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Mar 13, 2026
@github-actions
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Replace the inline prepare-selective-tests job with a call to getsentry's
select-sentry-tests.yml reusable workflow, which uses a cross-repo coverage
DB that maps sentry source files to tests with better accuracy.

The reusable workflow has the same output interface (has-selected-tests,
test-count) and uploads the same artifact name, so calculate-shards and
backend-test work without modification.
@joshuarli joshuarli force-pushed the ci-selective-testing-dispatch-clean branch from 9578f22 to 7dd5c34 Compare March 13, 2026 21:22
@joshuarli joshuarli requested a review from a team as a code owner March 13, 2026 21:22
Copy link
Contributor

@cursor cursor bot left a comment

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 and found 3 potential issues.

Fix All in Cursor

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

FAILED = "failed", gettext_lazy("Failed")


print("hi")
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug print("hi") accidentally committed in production model

High Severity

A print("hi") statement was accidentally committed in src/sentry/replays/models.py. This is not mentioned in the PR description (which only covers CI changes) and will execute every time the module is imported, writing to stdout in production. This pollutes logs and could interfere with any process that parses stdout.

Fix in Cursor Fix in Web

Copy link
Member

Choose a reason for hiding this comment

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

Yeah @joshuarli make sure to remove

name: selected-tests-${{ github.run_id }}
path: .artifacts/selected-tests.txt
retention-days: 1
uses: getsentry/getsentry/.github/workflows/select-sentry-tests.yml@ci-generate-cross-repo-coverage-clean-diff-2
Copy link
Contributor

Choose a reason for hiding this comment

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

Reusable workflow references temporary feature branch, not master

High Severity

The reusable workflow is referenced at @ci-generate-cross-repo-coverage-clean-diff-2, a temporary feature branch in getsentry. The PR description states the intent is to call @master once the companion getsentry PR is merged. If this ships as-is, the prepare-selective-tests job will break when that branch is deleted.

Fix in Cursor Fix in Web

HEAD_SHA="${{ github.event.pull_request.head.sha }}"
BASE_SHA="${{ github.event.pull_request.base.sha }}"

CHANGED_FILES=$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" | tr '\n' ' ')
Copy link
Contributor

Choose a reason for hiding this comment

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

Shallow fetch may break triple-dot diff for multi-commit PRs

Medium Severity

The PR head is fetched with --depth=1, but git diff --name-only "$BASE_SHA"..."$HEAD_SHA" uses triple-dot syntax which requires finding the merge-base. For multi-commit PRs (especially from forks), the intermediate commits between the PR head and the fork point won't be available locally, so git cannot traverse from HEAD_SHA back to the merge-base, likely causing the diff command to fail.

Fix in Cursor Fix in Web

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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants