The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Speed up CI ~1.8x (front 2.5x, server 1.4x) (#26876)
neo77399b2f2750f46
diff --git a/.github/actions/restore-cache/action.yaml b/.github/actions/restore-cache/action.yamlindex 5b4320ae31a..351bcd073a6 100644--- a/.github/actions/restore-cache/action.yaml+++ b/.github/actions/restore-cache/action.yaml@@ -24,12 +24,15 @@ runs:REF_NAME: ${{ github.ref_name }}run: |echo "CACHE_PRIMARY_KEY_PREFIX=v4-${CACHE_KEY}-${REF_NAME}" >> "${GITHUB_OUTPUT}"+ echo "CACHE_MAIN_KEY_PREFIX=v4-${CACHE_KEY}-main" >> "${GITHUB_OUTPUT}"- name: Restore cacheuses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 (restore)id: restore-cachewith:key: ${{ steps.cache-primary-key-builder.outputs.CACHE_PRIMARY_KEY_PREFIX }}-${{ github.sha }}- restore-keys: ${{ steps.cache-primary-key-builder.outputs.CACHE_PRIMARY_KEY_PREFIX }}-+ restore-keys: |+ ${{ steps.cache-primary-key-builder.outputs.CACHE_PRIMARY_KEY_PREFIX }}-+ ${{ steps.cache-primary-key-builder.outputs.CACHE_MAIN_KEY_PREFIX }}-path: |.cache.nxdiff --git a/.github/actions/yarn-install/action.yaml b/.github/actions/yarn-install/action.yamlindex 49f0065d11b..6f08a820467 100644--- a/.github/actions/yarn-install/action.yaml+++ b/.github/actions/yarn-install/action.yaml@@ -7,17 +7,6 @@ inputs:runs:using: 'composite'steps:- - name: Free disk space for install- if: runner.os == 'Linux'- shell: bash- run: |- # Default GitHub images ship large SDKs this repo does not use; removing- # them avoids ENOSPC when restoring or linking a full Yarn node_modules.- sudo rm -rf /usr/share/dotnet- sudo rm -rf /usr/local/lib/android- sudo rm -rf /opt/ghc- sudo rm -rf /opt/hostedtoolcache/CodeQL- df -h- name: Cache primary key builderid: globalsshell: bashdiff --git a/.github/workflows/ci-cache-warm.yaml b/.github/workflows/ci-cache-warm.yamlnew file mode 100644index 00000000000..2422d2da91f--- /dev/null+++ b/.github/workflows/ci-cache-warm.yaml@@ -0,0 +1,42 @@+name: CI Cache Warm++on:+ push:+ branches: [main]++permissions:+ contents: read++concurrency:+ group: ${{ github.workflow }}+ cancel-in-progress: true++env:+ SERVER_BUILD_CACHE_KEY: server-build++jobs:+ server-build-cache:+ timeout-minutes: 30+ runs-on: ubuntu-latest+ steps:+ - name: Fetch custom Github Actions and base branch history+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1+ with:+ fetch-depth: 10+ - name: Install dependencies+ uses: ./.github/actions/yarn-install+ - name: Restore server build cache+ id: restore-server-build-cache+ uses: ./.github/actions/restore-cache+ with:+ key: ${{ env.SERVER_BUILD_CACHE_KEY }}+ - name: Build twenty-shared+ run: npx nx build twenty-shared+ - name: Server / Write .env+ run: npx nx reset:env twenty-server+ - name: Server / Build+ run: npx nx build twenty-server+ - name: Save server build cache+ uses: ./.github/actions/save-cache+ with:+ key: ${{ steps.restore-server-build-cache.outputs.cache-primary-key }}diff --git a/.github/workflows/ci-front-component-renderer.yaml b/.github/workflows/ci-front-component-renderer.yamlindex 7c7cfe3299a..4cdecdf3443 100644--- a/.github/workflows/ci-front-component-renderer.yaml+++ b/.github/workflows/ci-front-component-renderer.yaml@@ -97,7 +97,7 @@ jobs:run: |npx http-server packages/twenty-front-component-renderer/storybook-static --port 6008 --silent &timeout 30 bash -c 'until curl -sf http://localhost:6008 > /dev/null 2>&1; do sleep 1; done'- npx nx storybook:test twenty-front-component-renderer+ npx nx storybook:test:no-coverage twenty-front-component-rendererci-front-component-renderer-status-check:if: always() && !cancelled()timeout-minutes: 5diff --git a/.github/workflows/ci-front.yaml b/.github/workflows/ci-front.yamlindex bd95779ffdf..cd6bc3f504f 100644--- a/.github/workflows/ci-front.yaml+++ b/.github/workflows/ci-front.yaml@@ -17,6 +17,7 @@ env:# restore-cache action adds 'v4-' prefix and '-<branch>-<sha>' suffix to the keySTORYBOOK_BUILD_CACHE_KEY_FOR_RESTORE_ACTION: storybook-build-ubuntu-latest-8-cores-runnerSTORYBOOK_BUILD_CACHE_KEY_FOR_SAVE_ACTION: v4-storybook-build-ubuntu-latest-8-cores-runner-${{ github.ref_name }}-${{ github.sha }}+ FRONT_TEST_SHARD_COUNTER: 3jobs:changed-files-check:@@ -49,6 +50,10 @@ jobs:fetch-depth: 10- name: Install dependenciesuses: ./.github/actions/yarn-install+ - name: Restore storybook build cache+ uses: ./.github/actions/restore-cache+ with:+ key: ${{ env.STORYBOOK_BUILD_CACHE_KEY_FOR_RESTORE_ACTION }}- name: Diagnostic disk space issuerun: df -h- name: Front / Write .env@@ -68,15 +73,27 @@ jobs:front-sb-test:timeout-minutes: 30runs-on: ubuntu-latest- needs: front-sb-build- if: always() && needs.front-sb-build.result == 'success'+ needs: changed-files-check+ if: >-+ always() &&+ (github.event_name == 'push' ||+ needs.changed-files-check.outputs.any_changed == 'true')strategy:fail-fast: falsematrix:- shard: [1, 2, 3, 4]+ shard: [1, 2, 3, 4, 5, 6, 7, 8]storybook_scope: ${{ github.event_name == 'push' && fromJSON('["modules", "pages"]') || fromJSON('["modules", "pages", "performance"]') }}+ exclude:+ - { storybook_scope: pages, shard: 5 }+ - { storybook_scope: pages, shard: 6 }+ - { storybook_scope: pages, shard: 7 }+ - { storybook_scope: pages, shard: 8 }+ - { storybook_scope: performance, shard: 5 }+ - { storybook_scope: performance, shard: 6 }+ - { storybook_scope: performance, shard: 7 }+ - { storybook_scope: performance, shard: 8 }env:- SHARD_COUNTER: 4+ SHARD_COUNTER: ${{ matrix.storybook_scope == 'modules' && 8 || 4 }}REACT_APP_SERVER_BASE_URL: http://localhost:3000STORYBOOK_URL: http://localhost:6006steps:@@ -97,11 +114,6 @@ jobs:npx nx build twenty-sharednpx nx build twenty-uinpx nx build twenty-front-component-renderer- - name: Download storybook build- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0- with:- name: storybook-static- path: packages/twenty-front/storybook-static- name: Resolve Playwright versionid: playwright-versionrun: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT"@@ -118,11 +130,8 @@ jobs:npx playwright install chromium- name: Front / Write .envrun: npx nx reset:env twenty-front- - name: Serve storybook & run tests- run: |- npx http-server packages/twenty-front/storybook-static --port 6006 --silent &- timeout 30 bash -c 'until curl -sf http://localhost:6006 > /dev/null 2>&1; do sleep 1; done'- npx nx storybook:test twenty-front --configuration=${{ matrix.storybook_scope }} --shard=${{ matrix.shard }}/${{ env.SHARD_COUNTER }}+ - name: Run storybook tests+ run: npx nx storybook:test:no-coverage twenty-front --configuration=${{ matrix.storybook_scope }} --shard=${{ matrix.shard }}/${{ env.SHARD_COUNTER }}- name: Upload screenshots for visual regressionif: always() && !cancelled() && matrix.storybook_scope != 'performance'uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2@@ -198,10 +207,18 @@ jobs:runs-on: ubuntu-latestenv:NODE_OPTIONS: '--max-old-space-size=6144'- TASK_CACHE_KEY: front-task-${{ matrix.task }}+ TASK_CACHE_KEY: front-task-${{ matrix.name }}${{ matrix.shard && format('-{0}', matrix.shard) || '' }}strategy:+ fail-fast: falsematrix:- task: [lint, typecheck, test, lingui:extract, lingui:compile]+ include:+ - { name: lint, tasks: lint }+ - { name: typecheck, tasks: typecheck }+ - { name: lingui-extract, tasks: 'lingui:extract' }+ - { name: lingui-compile, tasks: 'lingui:compile' }+ - { name: test, tasks: test, shard: 1 }+ - { name: test, tasks: test, shard: 2 }+ - { name: test, tasks: test, shard: 3 }steps:- name: Fetch custom Github Actions and base branch historyuses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1@@ -209,7 +226,7 @@ jobs:fetch-depth: 10- name: Install dependenciesuses: ./.github/actions/yarn-install- - name: Restore ${{ matrix.task }} cache+ - name: Restore ${{ matrix.name }} cacheid: restore-task-cacheuses: ./.github/actions/restore-cachewith:@@ -219,13 +236,14 @@ jobs:with:tag: scope:frontendtasks: reset:env- - name: Run ${{ matrix.task }} task+ - name: Run ${{ matrix.tasks }} taskid: run-taskuses: ./.github/actions/nx-affectedwith:tag: scope:frontend- tasks: ${{ matrix.task }}- - name: Save ${{ matrix.task }} cache+ tasks: ${{ matrix.tasks }}+ args: ${{ matrix.shard && format('--shard={0}/{1}', matrix.shard, env.FRONT_TEST_SHARD_COUNTER) || '' }}+ - name: Save ${{ matrix.name }} cacheuses: ./.github/actions/save-cachewith:key: ${{ steps.restore-task-cache.outputs.cache-primary-key }}diff --git a/.github/workflows/ci-server.yaml b/.github/workflows/ci-server.yamlindex df2ea13696a..f3c5acf5b09 100644--- a/.github/workflows/ci-server.yaml+++ b/.github/workflows/ci-server.yaml@@ -13,6 +13,7 @@ concurrency:env:SERVER_BUILD_CACHE_KEY: server-build+ NODE_COMPILE_CACHE: ${{ github.workspace }}/.cache/node-compilejobs:changed-files-check:@@ -259,13 +260,27 @@ jobs:key: ${{ env.SERVER_BUILD_CACHE_KEY }}- name: Build twenty-sharedrun: npx nx build twenty-shared+ - name: Restore jest transform cache+ id: restore-jest-cache+ uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 (restore)+ with:+ key: v4-jest-server-unit-${{ matrix.shard }}-${{ github.ref_name }}-${{ github.sha }}+ restore-keys: v4-jest-server-unit-${{ matrix.shard }}-${{ github.ref_name }}-+ path: .cache/jest/packages/twenty-server- name: Server / Run Tests (shard ${{ matrix.shard }}/4)run: npx nx run twenty-server:test:ci --shard=${{ matrix.shard }}/4+ - name: Save jest transform cache+ if: always() && steps.restore-jest-cache.outputs.cache-hit != 'true' && format('{0}', github.event.pull_request.head.repo.fork) != 'true'+ uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 (save)+ with:+ key: ${{ steps.restore-jest-cache.outputs.cache-primary-key }}+ path: .cache/jest/packages/twenty-serverserver-integration-test:+ needs: changed-files-check+ if: needs.changed-files-check.outputs.any_changed == 'true'timeout-minutes: 30runs-on: ubuntu-latest- needs: server-buildstrategy:fail-fast: falsematrix:@@ -306,6 +321,7 @@ jobs:CLICKHOUSE_URL: "http://default:clickhousePassword@localhost:8123/twenty"CLICKHOUSE_PASSWORD: clickhousePasswordSHARD_COUNTER: 16+ INTEGRATION_TEST_DB_RESET_STATUS_FILE: ${{ github.workspace }}/.cache/integration-db-reset-statussteps:- name: Fetch custom Github Actions and base branch historyuses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1@@ -327,23 +343,37 @@ jobs:key: ${{ env.SERVER_BUILD_CACHE_KEY }}- name: Server / Buildrun: npx nx build twenty-server- - name: Build dependencies- run: |- npx nx build twenty-shared- npx nx build twenty-emails- name: Server / Create Test DBrun: |PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "test";'- name: Run ClickHouse migrationsrun: npx nx clickhouse:migrate twenty-server- - name: Run ClickHouse seeds- run: npx nx clickhouse:seed twenty-server+ - name: Server / Reset Test DB in background+ env:+ RESET_LOG_FILE: ${{ github.workspace }}/.cache/integration-db-reset.log+ NODE_OPTIONS: --max-old-space-size=12288+ run: |+ mkdir -p "$(dirname "$INTEGRATION_TEST_DB_RESET_STATUS_FILE")"+ {+ if npx nx database:reset twenty-server --excludeTaskDependencies > "$RESET_LOG_FILE" 2>&1; then+ echo ready > "$INTEGRATION_TEST_DB_RESET_STATUS_FILE.tmp"+ else+ echo failed > "$INTEGRATION_TEST_DB_RESET_STATUS_FILE.tmp"+ fi+ mv "$INTEGRATION_TEST_DB_RESET_STATUS_FILE.tmp" "$INTEGRATION_TEST_DB_RESET_STATUS_FILE"+ } &+ - name: Restore jest transform cache+ id: restore-jest-cache+ uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 (restore)+ with:+ key: v4-jest-server-integration-${{ github.ref_name }}-${{ github.sha }}+ restore-keys: v4-jest-server-integration-${{ github.ref_name }}-+ path: .cache/jest/packages/twenty-server-integration- name: Server / Run Integration Testsuses: ./.github/actions/nx-affectedwith:tag: scope:backendtasks: 'test:integration'- configuration: 'with-db-reset'args: ${{ format('--shard={0}/{1}', matrix.shard, env.SHARD_COUNTER) }}# The secure-deployment suite boots the app as a production https# deployment (SERVER_URL is env-only, forced by its jest config), so it@@ -355,6 +385,15 @@ jobs:with:tag: scope:backendtasks: 'test:integration:secure'+ - name: Print Test DB reset log+ if: failure()+ run: cat "${{ github.workspace }}/.cache/integration-db-reset.log" || true+ - name: Save jest transform cache+ if: always() && matrix.shard == 1 && steps.restore-jest-cache.outputs.cache-hit != 'true' && format('{0}', github.event.pull_request.head.repo.fork) != 'true'+ uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 (save)+ with:+ key: ${{ steps.restore-jest-cache.outputs.cache-primary-key }}+ path: .cache/jest/packages/twenty-server-integrationcross-version-upgrade:needs: [upgrade-changed-files-check, server-build]diff --git a/.github/workflows/ci-ui.yaml b/.github/workflows/ci-ui.yamlindex 5181a752be5..4a79bc37f23 100644--- a/.github/workflows/ci-ui.yaml+++ b/.github/workflows/ci-ui.yaml@@ -71,8 +71,11 @@ jobs:ui-sb-test:timeout-minutes: 30runs-on: ubuntu-latest- needs: ui-sb-build- if: always() && needs.ui-sb-build.result == 'success'+ needs: changed-files-check+ if: >-+ always() &&+ (github.event_name == 'push' ||+ needs.changed-files-check.outputs.any_changed == 'true')steps:- name: Fetch custom Github Actions and base branch historyuses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1@@ -82,17 +85,22 @@ jobs:uses: ./.github/actions/yarn-install- name: Build dependenciesrun: npx nx build twenty-shared- - name: Download storybook build- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0+ - name: Resolve Playwright version+ id: playwright-version+ run: echo "version=$(node -p "require('@playwright/test/package.json').version")" >> "$GITHUB_OUTPUT"+ - name: Cache Playwright browsers+ id: playwright-cache+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0with:- name: storybook-twenty-ui- path: packages/twenty-ui/storybook-static+ path: ~/.cache/ms-playwright+ key: v4-playwright-browsers-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}- name: Install Playwright+ if: steps.playwright-cache.outputs.cache-hit != 'true'run: |cd packages/twenty-ui- npx playwright install+ npx playwright install chromium- name: Run storybook tests- run: npx nx storybook:test twenty-ui+ run: npx nx storybook:test:no-coverage twenty-ui- name: Upload screenshots for visual regressionif: always() && !cancelled()uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2diff --git a/nx.json b/nx.jsonindex 42cb70b91a3..4d4e0095204 100644--- a/nx.json+++ b/nx.json@@ -199,6 +199,7 @@},"storybook:test:no-coverage": {"executor": "nx:run-commands",+ "cache": true,"inputs": ["^default", "excludeTests"],"options": {"cwd": "{projectRoot}",diff --git a/packages/twenty-front/jest.config.mjs b/packages/twenty-front/jest.config.mjsindex 9d19fd31562..64ce8020da6 100644--- a/packages/twenty-front/jest.config.mjs+++ b/packages/twenty-front/jest.config.mjs@@ -62,13 +62,6 @@ const jestConfig = {},moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],extensionsToTreatAsEsm: ['.ts', '.tsx'],- coverageThreshold: {- global: {- statements: 47.3,- lines: 45.9,- functions: 39.5,- },- },collectCoverageFrom: ['<rootDir>/src/**/*.ts'],coveragePathIgnorePatterns: ['states/.+State.ts$',diff --git a/packages/twenty-front/project.json b/packages/twenty-front/project.jsonindex 8780a7dc5b4..ac8c95af33c 100644--- a/packages/twenty-front/project.json+++ b/packages/twenty-front/project.json@@ -106,7 +106,14 @@"fix": {}}},- "test": {},+ "test": {+ "configurations": {+ "ci": {+ "maxWorkers": 3,+ "coverage": false+ }+ }+ },"storybook:build": {"options": {"env": {diff --git a/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx b/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsxindex a6fd8f6a567..f123549694f 100644--- a/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx+++ b/packages/twenty-front/src/pages/object-record/__tests__/RecordIndexPage.surface.test.tsx@@ -116,6 +116,10 @@ jest.mock('@/ui/utilities/page-title/components/PageTitle', () => ({}));describe('RecordIndexPage workspace surface composition', () => {+ beforeAll(async () => {+ await import('~/pages/object-core/WorkflowCoreIndexPage');+ });+beforeEach(() => {mockIsCoreWorkflowsIndexEnabled.mockReturnValue(false);mockObjectNamePlural = 'people';diff --git a/packages/twenty-server/jest-integration.config.ts b/packages/twenty-server/jest-integration.config.tsindex 6fbb386bd8a..40d56f564b0 100644--- a/packages/twenty-server/jest-integration.config.ts+++ b/packages/twenty-server/jest-integration.config.ts@@ -25,6 +25,8 @@ const jestConfig: JestConfigWithTsJest = {moduleFileExtensions: ['js', 'mjs', 'json', 'ts'],rootDir: '.',testEnvironment: 'node',+ cacheDirectory:+ '<rootDir>/../../.cache/jest/packages/twenty-server-integration',testPathIgnorePatterns: [...(isBillingEnabled ? [] : ['<rootDir>/test/integration/billing']),...(isClickhouseEnabled ? [] : ['<rootDir>/test/integration/audit']),diff --git a/packages/twenty-server/project.json b/packages/twenty-server/project.jsonindex 0c055d39049..fbe428e3f49 100644--- a/packages/twenty-server/project.json+++ b/packages/twenty-server/project.json@@ -51,7 +51,7 @@"dependsOn": ["^build"],"options": {"cwd": "packages/twenty-server",- "command": "jest --config ./jest.config.mjs --ci --runInBand"+ "command": "jest --config ./jest.config.mjs --ci --maxWorkers=3 --workerIdleMemoryLimit=1GB --cacheDirectory=../../.cache/jest/packages/twenty-server"}},"build:packageJson": {diff --git a/packages/twenty-server/src/database/scripts/setup-db-utils.ts b/packages/twenty-server/src/database/scripts/setup-db-utils.tsindex 0de5ee0b023..35e83438c9d 100644--- a/packages/twenty-server/src/database/scripts/setup-db-utils.ts+++ b/packages/twenty-server/src/database/scripts/setup-db-utils.ts@@ -25,6 +25,7 @@ export const performQuery = async <T = unknown>(message = `Performed '${consoleDescription}' successfully`;} else {message = `Failed to perform '${consoleDescription}': ${err}`;+ process.exitCode = 1;}if (withLog) {// oxlint-disable-next-line no-consolediff --git a/packages/twenty-server/src/database/scripts/setup-db.ts b/packages/twenty-server/src/database/scripts/setup-db.tsindex f29ca2cec8f..f4ad1bcba97 100644--- a/packages/twenty-server/src/database/scripts/setup-db.ts+++ b/packages/twenty-server/src/database/scripts/setup-db.ts@@ -2,7 +2,7 @@ import { rawDataSource } from 'src/database/typeorm/raw/raw.datasource';import { camelToSnakeCase, performQuery } from './setup-db-utils';-rawDataSource+void rawDataSource.initialize().then(async () => {await performQuery(@@ -89,6 +89,12 @@ $$;`,.catch((err) => {// oxlint-disable-next-line no-consoleconsole.error('Error during Data Source initialization:', err);+ process.exitCode = 1;+ })+ .then(async () => {+ if (rawDataSource.isInitialized) {+ await rawDataSource.destroy();+ }});async function checkForeignDataWrapperExists(diff --git a/packages/twenty-server/src/database/scripts/truncate-db.ts b/packages/twenty-server/src/database/scripts/truncate-db.tsindex 002f87f4a0d..4522574d274 100644--- a/packages/twenty-server/src/database/scripts/truncate-db.ts+++ b/packages/twenty-server/src/database/scripts/truncate-db.ts@@ -37,6 +37,11 @@ async function dropSchemasSequentially() {} catch (err) {// oxlint-disable-next-line no-consoleconsole.error('Error during schema dropping:', err);+ process.exitCode = 1;+ } finally {+ if (rawDataSource.isInitialized) {+ await rawDataSource.destroy();+ }}}diff --git a/packages/twenty-server/test/integration/utils/setup-test.ts b/packages/twenty-server/test/integration/utils/setup-test.tsindex 114c517824d..1643dd80502 100644--- a/packages/twenty-server/test/integration/utils/setup-test.ts+++ b/packages/twenty-server/test/integration/utils/setup-test.ts@@ -6,12 +6,15 @@ import { rawDataSource } from 'src/database/typeorm/raw/raw.datasource';import { createApp } from './create-app';import { createWorkflowTestServices } from './create-workflow-test-services';+import { waitForTestDatabaseReset } from './wait-for-test-database-reset.util';export default async (_: unknown, projectConfig: JestConfigWithTsJest) => {// node-fetch rides node:http, which msw patches; native undici fetch// escapes interception.globalThis.fetch = nodeFetch as unknown as typeof globalThis.fetch;+ await waitForTestDatabaseReset();+const app = await createApp({});if (!projectConfig.globals) {diff --git a/packages/twenty-server/test/integration/utils/wait-for-test-database-reset.util.ts b/packages/twenty-server/test/integration/utils/wait-for-test-database-reset.util.tsnew file mode 100644index 00000000000..f4463293fa6--- /dev/null+++ b/packages/twenty-server/test/integration/utils/wait-for-test-database-reset.util.ts@@ -0,0 +1,35 @@+import { existsSync, readFileSync } from 'fs';++import { isDefined } from 'twenty-shared/utils';++const POLL_INTERVAL_MS = 250;+const RESET_TIMEOUT_MS = 10 * 60 * 1000;+const RESET_SUCCEEDED_STATUS = 'ready';++export const waitForTestDatabaseReset = async (): Promise<void> => {+ const resetStatusFile = process.env.INTEGRATION_TEST_DB_RESET_STATUS_FILE;++ if (!isDefined(resetStatusFile)) {+ return;+ }++ const deadline = Date.now() + RESET_TIMEOUT_MS;++ while (!existsSync(resetStatusFile)) {+ if (Date.now() > deadline) {+ throw new Error(+ `Test database reset did not report a status within ${RESET_TIMEOUT_MS / 1000}s (${resetStatusFile})`,+ );+ }++ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));+ }++ const resetStatus = readFileSync(resetStatusFile, 'utf8').trim();++ if (resetStatus !== RESET_SUCCEEDED_STATUS) {+ throw new Error(+ `Test database reset did not succeed (status: ${resetStatus})`,+ );+ }+};