Improved E2E MySQL setup performance#28525
Conversation
no ref Browser E2E setup clones and configures a MySQL database for every isolated environment. Combining the create, restore, and setting update work into one container exec keeps the same isolation semantics while reducing repeated Docker exec overhead.
WalkthroughThis PR refactors the test database setup in 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run @tryghost/admin:build |
✅ Succeeded | 5s | View ↗ |
nx run-many -t lint -p @tryghost/e2e |
✅ Succeeded | 4s | View ↗ |
nx run ghost:build:assets |
✅ Succeeded | 2s | View ↗ |
nx run ghost:build:tsc |
✅ Succeeded | 5s | View ↗ |
nx run-many --target=build --projects=@tryghost... |
✅ Succeeded | <1s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-11 22:17:45 UTC
There was a problem hiding this comment.
🧹 Nitpick comments (1)
e2e/helpers/environment/service-managers/mysql-manager.ts (1)
245-249: 💤 Low valueConsider documenting the limited escaping scope.
The
escapeSqlStringfunction handles\and', which is sufficient for the controlled inputs (UUIDs and Stripe test keys). For clarity, consider adding a brief doc comment noting this is intentionally minimal for known-safe inputs:+ /** + * Escapes a string for use in a SQL single-quoted literal. + * Sufficient for controlled inputs like UUIDs and Stripe test keys. + */ private escapeSqlString(value: string): string {This helps future maintainers understand the escaping is scoped to expected inputs rather than being a general-purpose SQL escape function.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@e2e/helpers/environment/service-managers/mysql-manager.ts` around lines 245 - 249, Add a short JSDoc above the private method escapeSqlString explaining that it only escapes backslashes and single quotes (via .replace(/\\/g, '\\\\') and .replace(/'/g, '\\\'')) and that this minimal escaping is intentional because inputs are constrained (UUIDs and Stripe test keys); explicitly note it is NOT a general-purpose SQL-escaping function and should not be used for untrusted or arbitrary input.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@e2e/helpers/environment/service-managers/mysql-manager.ts`:
- Around line 245-249: Add a short JSDoc above the private method
escapeSqlString explaining that it only escapes backslashes and single quotes
(via .replace(/\\/g, '\\\\') and .replace(/'/g, '\\\'')) and that this minimal
escaping is intentional because inputs are constrained (UUIDs and Stripe test
keys); explicitly note it is NOT a general-purpose SQL-escaping function and
should not be used for untrusted or arbitrary input.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2f485af9-4ef1-48bf-a9d6-5b484856c0b8
📒 Files selected for processing (1)
e2e/helpers/environment/service-managers/mysql-manager.ts

Summary
Why
Every isolated browser E2E environment creates a database, restores the snapshot, updates
site_uuid, and sometimes writes Stripe settings. Those operations previously used multiple Docker exec calls per environment. Combining the hot setup path preserves the same database isolation model while reducing repeated Docker exec overhead.Testing
pnpm --filter @tryghost/e2e test:typese2e/helpers/environment/service-managers/mysql-manager.tsgit diff --checksettingstable/tmp/dump.sqlsnapshot throughMySQLManager.createSnapshot()MySQLManager.setupTestDatabase()with Stripe settings enabledsite_uuid = new-site-uuidstripe_publishable_key = pk_test_e2estripe_secret_key = sk_test_e2e80ms,45ms,38ms,38ms,37msfor five create/restore/configure/drop cycles on the small dumpNotes
The benchmark loop uses a tiny synthetic dump, so it is a correctness and overhead smoke rather than a full Ghost E2E runtime estimate. Earlier investigation on a Ghost-sized dump showed combining Docker execs saved roughly 0.17s per environment cycle locally.