From bfd1c4986feda016b90dee14694d20be732e7114 Mon Sep 17 00:00:00 2001 From: Jordan Ramos Date: Tue, 26 May 2026 11:26:44 -0600 Subject: [PATCH] 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. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c7c9b9..f39a7d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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