From ffda9a05677db00229edfc54d819c371dfebda21 Mon Sep 17 00:00:00 2001 From: JimmFly <447268514@qq.com> Date: Sun, 3 Mar 2024 12:00:10 +0000 Subject: [PATCH] feat(core): separate runtimeConfig for e2e tests and deployment (#5976) Prior to modification, it will function for both `deploy` and `e2e-test`. Consequently, `allowLocalWorkspace` is also set to `true` in the production environment. https://github.com/toeverything/AFFiNE/actions/runs/8093473180/job/22116199541#step:5:120 --- .github/workflows/build-test.yml | 2 ++ packages/frontend/core/.webpack/runtime-config.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index b3c6d2146..dc66c88f6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -118,6 +118,7 @@ jobs: runs-on: ubuntu-latest env: DISTRIBUTION: browser + IN_CI_TEST: true strategy: fail-fast: false matrix: @@ -370,6 +371,7 @@ jobs: env: DISTRIBUTION: browser DATABASE_URL: postgresql://affine:affine@localhost:5432/affine + IN_CI_TEST: true strategy: fail-fast: false matrix: diff --git a/packages/frontend/core/.webpack/runtime-config.ts b/packages/frontend/core/.webpack/runtime-config.ts index a712f409d..5e43f8f11 100644 --- a/packages/frontend/core/.webpack/runtime-config.ts +++ b/packages/frontend/core/.webpack/runtime-config.ts @@ -147,6 +147,10 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig { : currentBuildPreset.allowLocalWorkspace, }; + const testEnvironmentPreset = { + allowLocalWorkspace: true, + }; + if (buildFlags.mode === 'development') { currentBuildPreset.serverUrlPrefix = 'http://localhost:8080'; } @@ -156,6 +160,10 @@ export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig { // environment preset will overwrite current build preset // this environment variable is for debug proposes only // do not put them into CI - ...(process.env.CI ? { allowLocalWorkspace: true } : environmentPreset), + ...(process.env.CI ? {} : environmentPreset), + + // test environment preset will overwrite current build preset + // this environment variable is for github workflow e2e-test only + ...(process.env.IN_CI_TEST ? testEnvironmentPreset : {}), }; }