Repository navigation
ci(migrations): Cache the migrated test databases between runs - #128394
Conversation
The migration tests job spends about 4 minutes building the test databases by running every migration from scratch. Master now saves a pg_dump of them keyed on the migration files, and later runs restore the newest dump so pytest only applies the migrations added since. A dump that records migrations missing from the checkout, such as a master dump restored on a PR branch that is behind, is dropped and the databases are built from scratch. Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
|
🚨 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 |
Check a saved manifest of migration files instead of running Django through sentry exec and parsing psql output, and name the workflow's repeated cache path and save condition once. Co-Authored-By: Joshua Li <14209781+joshuarli@users.noreply.github.com>
new_migrations/** also matched __pycache__ bytecode, which changes every run and kept the exact cache key from ever hitting.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4a148db. Configure here.

backend / backend migration testsspends about 237s on master CI buildingtest_region,test_controlandtest_secondary. The first test's setup runs every migration from scratch.With this change:
pg_dumpof the three test databases plus a manifest of the migration files it was built from. The cache key hashessrc/**/migrations/*.pyandsrc/sentry/new_migrations/**.restore-keys, before running pytest. The job already uses--reuse-db, so pytest-django keeps the restored databases and applies only the migrations added since the dump..github/file-filters.yml: changes to the new script now trigger the migration tests.Local measurements (single migration test,
--migrations --reuse-db)Not verified yet
keepdbplusmigrate.via @joshuarli.
--
View Junior Session [Sentry]