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:
Jordan Ramos
2026-05-26 11:26:44 -06:00
parent 7f6f458949
commit bfd1c4986f

View File

@@ -105,8 +105,8 @@ test-backend:
- npm ci --prefer-offline - npm ci --prefer-offline
# Source backend .env from the production install so DATABASE_URL is available # 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. # 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 # Must be on same line as jest because each script line is a separate shell context.
- ./node_modules/.bin/jest --ci --forceExit backend/__tests__/ - export $(grep -v '^#' /home/cve-dashboard/backend/.env | xargs) && ./node_modules/.bin/jest --ci --forceExit backend/__tests__/
timeout: 5 minutes timeout: 5 minutes
needs: needs:
- install-backend - install-backend