Fix env sourcing for CI test runner
GitLab CI runs each script line in a separate shell context, so sourcing .env on one line doesn't carry to the next. Use export $(grep ...) on the same line as jest to ensure DATABASE_URL is in the process environment.
This commit is contained in:
@@ -105,8 +105,8 @@ test-backend:
|
||||
- npm ci --prefer-offline
|
||||
# Source backend .env from the production install so DATABASE_URL is available
|
||||
# for integration tests. Safe because the runner is on the same machine as the DB.
|
||||
- set -a && source /home/cve-dashboard/backend/.env && set +a
|
||||
- ./node_modules/.bin/jest --ci --forceExit backend/__tests__/
|
||||
# Must be on same line as jest because each script line is a separate shell context.
|
||||
- export $(grep -v '^#' /home/cve-dashboard/backend/.env | xargs) && ./node_modules/.bin/jest --ci --forceExit backend/__tests__/
|
||||
timeout: 5 minutes
|
||||
needs:
|
||||
- install-backend
|
||||
|
||||
Reference in New Issue
Block a user