ci: pass changed files to getsentry dispatch for selective testing#110668
ci: pass changed files to getsentry dispatch for selective testing#110668
Conversation
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.
|
🚨 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 |
65fd855 to
9578f22
Compare
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.
9578f22 to
7dd5c34
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
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") |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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' ' ') |
There was a problem hiding this comment.
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.


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 inlineprepare-selective-testsjob (120+ lines of GCS lookup, coverage download, test computation) with a 2-line call togetsentry/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, socalculate-shardsandbackend-testwork without modification.getsentry-dispatch.yml— Addsfetch-depth: 0to checkout and agit diff --name-onlystep to compute changed files. Passes them to the dispatch script viaSENTRY_CHANGED_FILESenv var.getsentry-dispatch.js— AcceptssentryChangedFilesparameter and forwards it as thesentry-changed-filesworkflow dispatch input to getsentry'sbackend.yml.requires https://github.com/getsentry/getsentry/pull/19553 to be merged to master first because of 2 constraints:
callee repo
The only way to test end-to-end without merging: merge the getsentry PR
first. It's safe because:
default behavior change
called
when sentry-changed-files is provided or it's a PR — existing dispatch
behavior is unchanged
pushes
Once getsentry's merged I'll test:
sentry-changed-files