diff --git a/.github/workflows/curriculum-i18n-submodule.yml b/.github/workflows/curriculum-i18n-submodule.yml index b713ac1794a..37221afac65 100644 --- a/.github/workflows/curriculum-i18n-submodule.yml +++ b/.github/workflows/curriculum-i18n-submodule.yml @@ -52,7 +52,7 @@ jobs: - name: Set Environment variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV - name: Install node_modules run: pnpm install diff --git a/.github/workflows/e2e-playwright.yml b/.github/workflows/e2e-playwright.yml index 9461eb898ab..1480592af1c 100644 --- a/.github/workflows/e2e-playwright.yml +++ b/.github/workflows/e2e-playwright.yml @@ -54,7 +54,7 @@ jobs: - name: Set freeCodeCamp Environment Variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV - name: Install and Build run: | @@ -153,7 +153,8 @@ jobs: - name: Set freeCodeCamp Environment Variables (needed by api) run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV + cp sample.env .env # for docker compose - name: Install playwright dependencies run: npx playwright install --with-deps diff --git a/.github/workflows/i18n-validate-builds.yml b/.github/workflows/i18n-validate-builds.yml index c565eeb7d98..68c3ce40f80 100644 --- a/.github/workflows/i18n-validate-builds.yml +++ b/.github/workflows/i18n-validate-builds.yml @@ -41,7 +41,7 @@ jobs: - name: Set freeCodeCamp Environment Variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV - name: Install Dependencies run: pnpm install diff --git a/.github/workflows/i18n-validate-prs.yml b/.github/workflows/i18n-validate-prs.yml index e8c01d969be..efe090acdb9 100644 --- a/.github/workflows/i18n-validate-prs.yml +++ b/.github/workflows/i18n-validate-prs.yml @@ -37,7 +37,7 @@ jobs: - name: Set freeCodeCamp Environment Variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV - name: Install Dependencies run: pnpm install diff --git a/.github/workflows/node.js-tests.yml b/.github/workflows/node.js-tests.yml index 5a2a25a5936..dddb228c0e6 100644 --- a/.github/workflows/node.js-tests.yml +++ b/.github/workflows/node.js-tests.yml @@ -45,6 +45,9 @@ jobs: exit 1 fi + - name: Check format of sample.env + run: docker run --rm -v `pwd`:/app -w /app dotenvlinter/dotenv-linter check --ignore-checks UnorderedKey sample.env + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 with: @@ -64,8 +67,8 @@ jobs: - name: Set Environment variables run: | - cp sample.env .env - cat .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV + cat sample.env - name: Install node_modules run: pnpm install @@ -116,7 +119,7 @@ jobs: - name: Set freeCodeCamp Environment Variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV - name: Install and Build run: | @@ -158,8 +161,8 @@ jobs: - name: Set Environment variables run: | - cp sample.env .env - cat .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV + cat sample.env - name: Start MongoDB run: docker compose -f docker/docker-compose.yml up -d @@ -210,9 +213,9 @@ jobs: - name: Set Environment variables run: | - cp sample.env .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV echo 'SHOW_UPCOMING_CHANGES=true' >> .env - cat .env + cat sample.env - name: Start MongoDB run: docker compose -f docker/docker-compose.yml up -d @@ -265,8 +268,8 @@ jobs: - name: Set Environment variables run: | - cp sample.env .env - cat .env + sed '/^[[:space:]]*#/d; /^$/d' sample.env >> $GITHUB_ENV + cat sample.env - name: Start MongoDB uses: supercharge/mongodb-github-action@315db7fe45ac2880b7758f1933e6e5d59afd5e94 # 1.12.1 diff --git a/api/src/utils/env.ts b/api/src/utils/env.ts index 06d51611839..f38d3e3389a 100644 --- a/api/src/utils/env.ts +++ b/api/src/utils/env.ts @@ -8,7 +8,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const envPath = path.resolve(__dirname, '../../../.env'); const { error } = config({ path: envPath }); -if (error && process.env.FREECODECAMP_NODE_ENV !== 'production') { +if ( + error && + process.env.FREECODECAMP_NODE_ENV == 'production' && + process.env.NODE_ENV !== 'test' +) { console.warn(` ---------------------------------------------------- Warning: .env file not found. diff --git a/api/turbo.json b/api/turbo.json index 8107abf4d92..53c6b09b814 100644 --- a/api/turbo.json +++ b/api/turbo.json @@ -39,7 +39,41 @@ ] }, "test": { - "passThroughEnv": ["VITEST_WORKER_ID"] + "passThroughEnv": ["VITEST_WORKER_ID"], + "env": [ + "API_LOCATION", + "AUTH0_CLIENT_ID", + "AUTH0_CLIENT_SECRET", + "AUTH0_DOMAIN", + "COOKIE_DOMAIN", + "COOKIE_SECRET", + "DEPLOYMENT_ENV", + "DEPLOYMENT_VERSION", + "EMAIL_PROVIDER", + "FCC_API_LOG_LEVEL", + "FCC_API_LOG_TRANSPORT", + "FCC_ENABLE_DEV_LOGIN_MODE", + "FCC_ENABLE_SENTRY_ROUTES", + "FCC_ENABLE_SHADOW_CAPTURE", + "FCC_ENABLE_SWAGGER_UI", + "FCC_ENABLE_TEST_LOGGING", + "FREECODECAMP_NODE_ENV", + "GROWTHBOOK_FASTIFY_API_HOST", + "GROWTHBOOK_FASTIFY_CLIENT_KEY", + "HOME_LOCATION", + "HOST", + "JWT_SECRET", + "MAILPIT_HOST", + "NODE_ENV", + "PORT", + "SENTRY_DSN", + "SENTRY_ENVIRONMENT", + "SES_ID", + "SES_REGION", + "SES_SECRET", + "SHOW_UPCOMING_CHANGES", + "STRIPE_SECRET_KEY" + ] } } } diff --git a/curriculum/src/config.ts b/curriculum/src/config.ts index 208f5841b0a..20cd146e828 100644 --- a/curriculum/src/config.ts +++ b/curriculum/src/config.ts @@ -17,7 +17,7 @@ export function testedLang() { Before the site can be built, this language needs to be manually approved`); } } else { - throw Error('LOCALE must be set for testing'); + throw Error('CURRICULUM_LOCALE must be set for testing'); } } diff --git a/curriculum/turbo.json b/curriculum/turbo.json index 30755fb01ca..001594ba58b 100644 --- a/curriculum/turbo.json +++ b/curriculum/turbo.json @@ -13,6 +13,9 @@ "test-content": { "passThroughEnv": ["VITEST_POOL_ID", "PUPPETEER_WS_ENDPOINT"], "env": ["FCC_*", "CURRICULUM_LOCALE", "SHOW_UPCOMING_CHANGES"] + }, + "lint": { + "env": ["CURRICULUM_LOCALE"] } } }