Skip to content

ref(ci): parallel devservices startup and more robust bootstrap-snuba#112381

Merged
joshuarli merged 13 commits into
masterfrom
ref-ci-speedup-setup-sentry
Apr 7, 2026
Merged

ref(ci): parallel devservices startup and more robust bootstrap-snuba#112381
joshuarli merged 13 commits into
masterfrom
ref-ci-speedup-setup-sentry

Conversation

@joshuarli

@joshuarli joshuarli commented Apr 7, 2026

Copy link
Copy Markdown
Member

setup-sentry takes ~2min per backend and acceptance test shard - most of this overhead is ~90s container setup

this intros a new setup-devservices composite action which devservices up in the background immediately after checkout, no setup-sentry required cause we can just parse devservices version from uv.lock with stdlib python

i'm observing ~30-40s saved per acceptance test shard and similar numbers for backend and the rest

example: https://github.com/getsentry/sentry/actions/runs/24096487514/job/70296340867
time to start running acceptance tests is 1m50s
before: ~2m30s https://github.com/getsentry/sentry/actions/runs/24096224167/job/70295443714

backend: ~45s saved!
before https://github.com/getsentry/sentry/actions/runs/24096491312/job/70296457386 2m45s before tests run
after https://github.com/getsentry/sentry/actions/runs/24096896697/job/70297892709: 2m before tests run

also applies to the rest of the setup-sentry callers: backend-migration-tests, cli, api-docs, api-url-typescript, migration, monolith-dbs, migrations, migrations-drift, openapi, openapi-diff

setup-sentry takes ~2min per backend test shard, with ~90s spent on
devservices (Docker image pulls + container health checks). This all
runs serially after Python/venv setup, even though image pulls don't
depend on the venv at all.

Add a setup-devservices composite action that:
- Parses uv.lock (via tomllib) for the pinned devservices version
- Installs it into an isolated /tmp venv using system Python
- Starts `devservices up` in the background immediately after checkout

The full setup-sentry venv restore (~19s) now runs concurrently with
Docker image pulls. A wait script polls for completion with proper
error handling and timeout.

Also extract the Snuba per-worker bootstrap into a two-phase script:
- Phase 1 (early): Polls for ClickHouse readiness and runs the
  expensive `bootstrap --force` while devservices is still bringing
  up remaining containers
- Phase 2 (after devservices): Stops the default Snuba container and
  starts per-worker API instances

Net saving: ~25-35s per shard depending on container startup order.
Apply the same early-devservices pattern from the backend test change.
Acceptance tests have several minutes of webpack/node build between
checkout and setup-sentry, so devservices will be fully ready by the
time the venv is set up — the entire ~90s of container startup becomes
free.
@joshuarli joshuarli requested a review from a team as a code owner April 7, 2026 17:43
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 7, 2026
Apply the same overlap pattern to every workflow that uses setup-sentry:
backend-migration-tests, cli, api-docs, api-url-typescript, migration,
monolith-dbs, migrations, migrations-drift, openapi, and openapi-diff.
Comment thread .github/workflows/backend.yml Outdated

@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 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 e8287ab. Configure here.

Comment thread .github/actions/setup-devservices/action.yml
Comment thread .github/actions/setup-devservices/bootstrap-snuba.sh Outdated
- Use strict shell (set -euo pipefail) at action level
- Fix set -e preventing exit code file from being written in subshell
- Add 10-minute timeout to Snuba bootstrap wait loop
- Move devservices start after chartcuterie build in acceptance
- Revert migrations/migrations-drift (checkout master first, action doesn't exist there yet)
@joshuarli joshuarli requested a review from a team as a code owner April 7, 2026 18:09
@joshuarli joshuarli changed the title ref(ci): overlap devservices startup with venv setup in backend and acceptance tests ref(ci): parallel devservices startup Apr 7, 2026
Comment thread .github/workflows/backend.yml
Comment thread .github/actions/setup-devservices/bootstrap-snuba.sh Outdated
Comment thread .github/actions/setup-devservices/bootstrap-snuba.py Outdated
@joshuarli joshuarli requested a review from rbro112 April 7, 2026 21:38
@joshuarli joshuarli changed the title ref(ci): parallel devservices startup ref(ci): parallel devservices startup and more robust bootstrap-snuba Apr 7, 2026
@joshuarli joshuarli requested a review from mchen-sentry April 7, 2026 22:54

@mchen-sentry mchen-sentry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left some comments

Comment thread .github/workflows/backend-with-coverage.yml
@@ -0,0 +1,38 @@
name: 'Early Devservices'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: This action + wait.sh could live inside setup-sentry instead of being a separate action. setup-sentry already has skip-devservices and devservices-timeout-minutes inputs. We can add a parallel-devservices mode to let it start the background process early (before venv setup) and
wait at the end (where it currently runs devservices up synchronously). I notice we're repeating the same 3-step pattern across all the 10 or so jobs, but just parallel-devservices: 'true' on the existing setup-sentry step would be a lot easier

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i would like to cut down on the boilerplate too but we'd lose most of the benefit for acceptance because webpacking requires setup-sentry and we want to be pulling stuff while webpacking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sure, let's just tackle this later.

@joshuarli joshuarli merged commit 78c74d1 into master Apr 7, 2026
56 checks passed
@joshuarli joshuarli deleted the ref-ci-speedup-setup-sentry branch April 7, 2026 23:25
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
…#112381)

`setup-sentry` takes ~2min per backend and acceptance test shard - most
of this overhead is ~90s container setup

this intros a new `setup-devservices` composite action which
`devservices up` in the background immediately after checkout, no
setup-sentry required cause we can just parse `devservices` version from
uv.lock with stdlib python

i'm observing ~30-40s saved per acceptance test shard and similar
numbers for backend and the rest
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants