Skip to content

Made automations test database more reliable#28520

Merged
EvanHahn merged 1 commit into
mainfrom
make-automations-test-database-more-reliable
Jun 11, 2026
Merged

Made automations test database more reliable#28520
EvanHahn merged 1 commit into
mainfrom
make-automations-test-database-more-reliable

Conversation

@EvanHahn

Copy link
Copy Markdown
Contributor

ref https://github.com/TryGhost/Ghost/actions/runs/27375153163/

This database will soon be removed, but let's make it a little more reliable in the meantime because CI is flaky. Let's ensure there's just one connection at a time.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fe9f5d18-52ad-4d10-9cee-0060fe3f7ab3

📥 Commits

Reviewing files that changed from the base of the PR and between 05913c4 and fc7fa28.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/automations/automations-api.ts
  • ghost/core/core/server/services/automations/temporary-fake-database.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • ghost/core/core/server/services/automations/automations-api.ts
  • ghost/core/core/server/services/automations/temporary-fake-database.ts

Walkthrough

This PR makes two test-only changes: the temporary fake automations database is created with a Knex sqlite3 pool limited to one connection, and the automations API switches to caching the database initialization as a shared Promise (testDatabasePromise) that is awaited on subsequent calls and cleared by the reset helper.

Possibly related PRs

  • TryGhost/Ghost#28513: Introduced the Knex-based fake automations database that these pool and caching changes build upon.
  • TryGhost/Ghost#28263: Also modifies automations test/fake database initialization and caching used for automation triggers.

Suggested reviewers

  • troyciesco
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: improving test database reliability by constraining connections to one at a time.
Description check ✅ Passed The description is directly related to the changeset, referencing a CI run that motivated the reliability improvements and explaining the single-connection constraint approach.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch make-automations-test-database-more-reliable

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 11, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 05913c4

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 29s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 12m 45s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 3m 30s View ↗
nx build @tryghost/portal ✅ Succeeded <1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
Additional runs (8) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-11 21:56:55 UTC

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@ghost/core/core/server/services/automations/automations-api.ts`:
- Around line 79-82: The cached rejected promise issue: when getDatabase()
assigns testDatabasePromise =
temporaryFakeAutomationsDatabase.createTemporaryFakeAutomationsDatabase(), a
rejected promise stays cached; fix by assigning the promise to
testDatabasePromise, then await it inside a try/catch and on catch reset
testDatabasePromise = undefined before rethrowing the error. Update the
getDatabase() logic that references testDatabasePromise and
createTemporaryFakeAutomationsDatabase() so transient init failures don’t remain
sticky.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1e717e90-cf49-4b85-96b2-187d92f5c259

📥 Commits

Reviewing files that changed from the base of the PR and between 983f2e7 and 05913c4.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/automations/automations-api.ts
  • ghost/core/core/server/services/automations/temporary-fake-database.ts

Comment thread ghost/core/core/server/services/automations/automations-api.ts Outdated
ref https://github.com/TryGhost/Ghost/actions/runs/27375153163/

This database will soon be removed, but let's make it a little more
reliable in the meantime because CI is flaky. Let's ensure there's just
one connection at a time.
@EvanHahn EvanHahn force-pushed the make-automations-test-database-more-reliable branch from 05913c4 to fc7fa28 Compare June 11, 2026 21:38
@EvanHahn EvanHahn enabled auto-merge (squash) June 11, 2026 21:38
@EvanHahn EvanHahn merged commit 22812c1 into main Jun 11, 2026
81 of 94 checks passed
@EvanHahn EvanHahn deleted the make-automations-test-database-more-reliable branch June 11, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant