Skip to content

Conversation

@AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Dec 19, 2025

This PR brings over most of the test suite improvements I made here to our payload monorepo.

  • Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (test: migrate to vitest #14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db.
  • Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs mongot, which unlocks support for vector search. This means we could add vector storage/search tests similar to the ones we have for postgres
  • Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local)
  • Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps
  • Simplified db setup handling locally in CI. In CI, everything is scoped to .github/actions/start-database/action.yml. Locally, everything is scoped to test/helpers/db. Each database adapter now shares the same username, password and db name
  • Use consistent db connection string env variables, all ending with _URL
  • Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2025

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@AlessioGr AlessioGr changed the title test: simplify db test setup Dec 19, 2025
@AlessioGr AlessioGr marked this pull request as ready for review December 19, 2025 08:44
@AlessioGr AlessioGr requested a review from denolfe as a code owner December 19, 2025 08:44
- name: Cache Docker images
uses: ScribeMD/docker-cache@0.5.0
# Use AndreKurait/docker-cache@0.6.0 instead of ScribeMD/docker-cache@0.5.0 to fix the following issue: https://github.com/ScribeMD/docker-cache/issues/837 ("Warning: Failed to restore: Cache service responded with 400")
uses: AndreKurait/docker-cache@0.6.0
Copy link
Member Author

@AlessioGr AlessioGr Dec 19, 2025

Choose a reason for hiding this comment

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

The caching was completely broken before.

I'm not adding it to the start-database action, as it seems to break health checks. Need to investigate further, but not in this PR

@@ -1,6 +1,5 @@
# Sample creds for working locally with docker-compose

MONGODB_URI=mongodb://localhost/payload-plugin-cloud-storage
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't know why we had this - this won't work anymore. It should use the default URL or whatever env variable the CI action sets

await runInit(testSuiteArg, true)

if (shouldStartMemoryDB) {
await startMemoryDB()
Copy link
Member Author

Choose a reason for hiding this comment

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

goodbye!

testMatch: ['<rootDir>/**/*int.spec.ts'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],

globalSetup: path.resolve(dirname, './helpers/startMemoryDB.ts'),
Copy link
Member Author

Choose a reason for hiding this comment

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

The vitest equivalent of this is what breaks debugging. Breakpoints are simply ignored.

Payload is structured as a Monorepo, encompassing not only the core Payload platform but also various plugins and packages. To install all required dependencies, you have to run `pnpm install` once in the root directory. **PNPM IS REQUIRED!** Yarn or npm will not work - you will have to use pnpm to develop in the core repository. In most systems, the easiest way to install pnpm is to run `corepack enable` in your terminal.
Payload is structured as a Monorepo, encompassing not only the core Payload platform but also various plugins and packages. To install all required dependencies, you have to run `pnpm install` once in the root directory. **PNPM IS REQUIRED!** Yarn or npm will not work - you will have to use pnpm to develop in the core repository. In most systems, the easiest way to install pnpm is to run `npm add -g pnpm` in your terminal.

If you're coming from a very outdated version of payload, it is recommended to nuke the node_modules folder before running pnpm install. On UNIX systems, you can easily do that using the `pnpm clean:unix` command, which will delete all node_modules folders and build artefacts.
Copy link
Member Author

Choose a reason for hiding this comment

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

The clean:unix script does not exist anymore and has been replaced with a cross-platform reinstall script long ago.

If you're coming from a very outdated version of payload, it is recommended to nuke the node_modules folder before running pnpm install. On UNIX systems, you can easily do that using the `pnpm clean:unix` command, which will delete all node_modules folders and build artefacts.
If you're coming from a very outdated version of payload, it is recommended to perform a clean install, which nukes the node_modules folder and reinstalls all dependencies. You can easily do that using the `pnpm reinstall` command.

It is also recommended to use at least Node v18 or higher. You can check your current node version by typing `node --version` in your terminal. The easiest way to switch between different node versions is to use [nvm](https://github.com/nvm-sh/nvm#intro).
Copy link
Member Author

Choose a reason for hiding this comment

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

23.11.0 is what we have defined in our .node-version file

4. Add a `DOCS_DIR` environment variable to the `.env` file which points to the absolute path of your modified docs folder. For example `DOCS_DIR=/Users/yourname/Documents/GitHub/payload/docs`
5. Run `pnpm fetchDocs:local`. If this was successful, you should see no error messages and the following output: _Docs successfully written to /.../website/src/app/docs.json_. There could be error messages if you have incorrect markdown in your local docs folder. In this case, it will tell you how you can fix it
6. You're done! Now you can start the website locally using `pnpm dev` and preview the docs under [http://localhost:3000/docs/local](http://localhost:3000/docs/local)
3. Follow the instructions in the [README of the website repository](https://github.com/payloadcms/website/blob/main/README.md#documentation) to preview the docs locally.
Copy link
Member Author

Choose a reason for hiding this comment

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

The docs here were outdated. No need to maintain this documentation in two places, just read the website readme which is kept up-to-date

@AlessioGr AlessioGr enabled auto-merge (squash) December 19, 2025 08:52
Copy link
Member

@denolfe denolfe left a comment

Choose a reason for hiding this comment

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

Very well done, glad we're finally making this change. Thank you for the narration comments on the PR as well, very helpful.

@AlessioGr AlessioGr merged commit e3c512a into main Dec 19, 2025
102 checks passed
@AlessioGr AlessioGr deleted the test/dbs branch December 19, 2025 15:07
@github-actions
Copy link
Contributor

🚀 This is included in version v3.69.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment