fix(ci): isola bundle e2e do servidor de desenvolvimento

This commit is contained in:
Francisco Solla 2026-08-16 01:25:06 -03:00
parent b6be493cdf
commit 7ca0efc95c
6 changed files with 22 additions and 11 deletions

1
.gitignore vendored
View file

@ -21,6 +21,7 @@
# next.js
/.next/
/.next-e2e/
/out/
# production

View file

@ -154,12 +154,9 @@ export default defineConfig({
* e2e states stay deterministic (see `googleCalendarTestKey.ts`).
*/
[GOOGLE_CALENDAR_SERVICE_ACCOUNT_KEY_ENV_NAME]: GOOGLE_CALENDAR_TEST_KEY,
// Fixed dist dir: Next dev appends `<distDir>/types/**/*.ts` to
// tsconfig.json's include with an EXACT-string check, so per-process
// names polluted tsconfig with one entry per run. A prior Playwright
// process tearing down late can, rarely, delete files of the next run's
// server — if a boot flakes, rerun (dev-only trade-off).
NEXT_DIST_DIR: '.next/e2e',
// Keep e2e artifacts outside `.next`: a concurrent development server
// owns that entire directory and may clear nested production bundles.
NEXT_DIST_DIR: process.env.NEXT_DIST_DIR ?? '.next-e2e',
PAYLOAD_SECRET: process.env.PAYLOAD_SECRET ?? 'test-only-secret-not-used-in-production',
NEXT_PUBLIC_SITE_URL: process.env.NEXT_PUBLIC_SITE_URL ?? baseURL,
},

View file

@ -149,9 +149,9 @@ const main = async () => {
run('playwright install chromium', 'pnpm', ['exec', 'playwright', 'install', 'chromium'])
run('e2e migrate', 'pnpm', ['migrate'], dbEnv)
run('e2e seed:minimal', 'pnpm', ['db:seed:minimal'], dbEnv)
run('e2e build', 'pnpm', ['build'], { ...dbEnv, NEXT_DIST_DIR: '.next/e2e' })
run('e2e build', 'pnpm', ['build'], { ...dbEnv, NEXT_DIST_DIR: '.next-e2e' })
const e2eEnv = { ...dbEnv, E2E_PROD: '1', CI: '1', NEXT_DIST_DIR: '.next/e2e' }
const e2eEnv = { ...dbEnv, E2E_PROD: '1', CI: '1', NEXT_DIST_DIR: '.next-e2e' }
if (scope.e2e.mode === 'full') {
run('test:e2e (full)', 'pnpm', ['test:e2e'], e2eEnv)
} else {

View file

@ -3,7 +3,7 @@
* run-e2e-affected — local mirror of the CI (PR) e2e job:
* 1. `e2e-affected.mjs` picks full vs manifest-selected vs skip (same base ref).
* 2. migrate + db:seed:minimal when anything would run.
* 3. optional production build into `.next/e2e` when `E2E_PROD=1`.
* 3. optional production build into `.next-e2e` when `E2E_PROD=1`.
* 4. `pnpm test:e2e` (set `CI=1` and `E2E_PROD=1` together for prod mode).
*
* Extra Playwright args after `--` are forwarded (e.g. a single spec while debugging).
@ -48,7 +48,7 @@ const run = (command, args, env = {}) => {
run('pnpm', ['migrate'])
run('pnpm', ['db:seed:minimal'])
if (process.env.E2E_PROD === '1') {
run('pnpm', ['build'], { NEXT_DIST_DIR: '.next/e2e' })
run('pnpm', ['build'], { NEXT_DIST_DIR: '.next-e2e' })
}
const playwrightArgs = ['test:e2e']

View file

@ -75,6 +75,19 @@ describe('ciSkipInvariants', () => {
expect(CANONICAL_E2E_SPEC_SUFFIX).toBe('.e2e.spec.ts')
})
it('keeps local e2e build artifacts outside the development dist directory', () => {
for (const file of [
'playwright.config.ts',
'scripts/gate-ci.mjs',
'scripts/run-e2e-affected.mjs',
'tsconfig.json',
]) {
const source = readFileSync(join(repoRoot, file), 'utf8')
expect(source, file).not.toContain('.next/e2e')
expect(source, file).toContain('.next-e2e')
}
})
it('skip classifiers and invariant specs are high-risk (force full suite)', () => {
for (const path of [
'scripts/lib/test-affected-core.mjs',

View file

@ -30,7 +30,7 @@
"next-env.d.ts",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
".next/e2e/types/**/*.ts"
".next-e2e/types/**/*.ts"
],
"exclude": ["node_modules"]
}