Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

ci(backend): run the e2e suite through the shared make target

Calvin252f2305dd63
diff --git a/.github/workflows/run-backend-tests.yml b/.github/workflows/run-backend-tests.yml
index d8760e9044..f53c6ec386 100644
--- a/.github/workflows/run-backend-tests.yml
+++ b/.github/workflows/run-backend-tests.yml
@@ -57,8 +57,6 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
working-directory: backend
- - name: Start postgres and redis
- run: touch .env && docker compose -f docker-compose.dev.yml up -d db redis
- name: Start Secret Rotation testing databases
run: docker compose -f docker-compose.e2e-dbs.yml up -d
- name: Run unit test
@@ -71,7 +69,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- - name: Build FIPS test image
+ - name: Resolve FIPS toolchain image
run: |
set -euo pipefail
# Lowercased: GHCR rejects uppercase repository names and the owner is "Infisical".
@@ -91,34 +89,26 @@ jobs:
-t "$TOOLCHAIN" \
backend
fi
- docker build \
- -f backend/Dockerfile.dev.fips \
- --build-arg "TOOLCHAIN_IMAGE=$TOOLCHAIN" \
- -t infisical-backend-fips:latest \
- backend
+ # Carried to the next step, which builds the app image through compose so the build
+ # arguments and image name live in docker-compose.test.yml rather than here.
+ echo "TOOLCHAIN_IMAGE=$TOOLCHAIN" >> "$GITHUB_ENV"
- name: Report disk space
if: always()
run: df -h /
- name: Wait for Secret Rotation testing databases
run: docker compose -f docker-compose.e2e-dbs.yml up -d --wait --wait-timeout 300
+ # Same entry point a developer uses. The override adds host networking, which the
+ # rotation specs need to reach the databases above and which only behaves this way on
+ # Linux. Connection strings, mounts and the image build all live in the compose files.
- name: Run integration test
- run: |
- docker run --rm --network host \
- -e DB_CONNECTION_URI="postgres://infisical:infisical@localhost:5432/infisical?sslmode=disable" \
- -e REDIS_URL="redis://localhost:6379" \
- -e AUTH_SECRET="something-random" \
- -e ENCRYPTION_KEY="p5e5k2j3+HIErjm02dzSrlhXc1xhdgoWvC6pox410rE=" \
- -e NODE_ENV="test" \
- -e NODE_OPTIONS="--force-fips" \
- -e TELEMETRY_ENABLED="false" \
- -e E2E_TEST_ORACLE_DB_19_HOST="${{ secrets.E2E_TEST_ORACLE_DB_19_HOST }}" \
- -e E2E_TEST_ORACLE_DB_19_USERNAME="${{ secrets.E2E_TEST_ORACLE_DB_19_USERNAME }}" \
- -e E2E_TEST_ORACLE_DB_19_PASSWORD="${{ secrets.E2E_TEST_ORACLE_DB_19_PASSWORD }}" \
- -e E2E_TEST_ORACLE_DB_19_DATABASE="${{ secrets.E2E_TEST_ORACLE_DB_19_DATABASE }}" \
- infisical-backend-fips:latest \
- npm run test:e2e
+ run: make test-api-e2e TEST_SUITE_COMPOSE_OVERRIDE="-f docker-compose.test.ci.yml"
+ env:
+ E2E_TEST_ORACLE_DB_19_HOST: ${{ secrets.E2E_TEST_ORACLE_DB_19_HOST }}
+ E2E_TEST_ORACLE_DB_19_USERNAME: ${{ secrets.E2E_TEST_ORACLE_DB_19_USERNAME }}
+ E2E_TEST_ORACLE_DB_19_PASSWORD: ${{ secrets.E2E_TEST_ORACLE_DB_19_PASSWORD }}
+ E2E_TEST_ORACLE_DB_19_DATABASE: ${{ secrets.E2E_TEST_ORACLE_DB_19_DATABASE }}
- name: cleanup
if: always()
run: |
- docker compose -f "docker-compose.dev.yml" down
+ make down-test-suite-containers TEST_SUITE_COMPOSE_OVERRIDE="-f docker-compose.test.ci.yml"
docker compose -f "docker-compose.e2e-dbs.yml" down
diff --git a/Makefile b/Makefile
index 7c1ad83479..e1fd2cb78d 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,10 @@ reviewable: reviewable-ui reviewable-api
# That is not a preference: the e2e harness runs `DROP SCHEMA public CASCADE` on whatever
# database it is pointed at, so aiming it at the dev database takes your data with it.
# Everything else (image, environment, mounts, service dependencies) is declared there.
-TEST_SUITE_COMPOSE = docker compose -f docker-compose.test.yml --profile runner
+# CI adds -f docker-compose.test.ci.yml here, which is the only difference between how CI and a
+# developer run the suites. Everything else is shared.
+TEST_SUITE_COMPOSE_OVERRIDE ?=
+TEST_SUITE_COMPOSE = docker compose -f docker-compose.test.yml $(TEST_SUITE_COMPOSE_OVERRIDE) --profile runner
build-test-suite-image:
$(TEST_SUITE_COMPOSE) build api-tests
diff --git a/docker-compose.test.ci.yml b/docker-compose.test.ci.yml
new file mode 100644
index 0000000000..321ea46911
--- /dev/null
+++ b/docker-compose.test.ci.yml
@@ -0,0 +1,17 @@
+# CI-only override for docker-compose.test.yml.
+#
+# The secret rotation specs address their databases as 127.0.0.1 on published ports
+# (backend/e2e-test/routes/v3/secret-rotations.spec.ts), so the suite has to share the host's
+# network namespace to reach the docker-compose.e2e-dbs.yml stack. Host networking only behaves
+# this way on Linux, so it stays out of the base file, which has to work on Docker Desktop too.
+#
+# Sharing the host namespace means Postgres and Redis are no longer reachable by service name,
+# so those two connection strings move to the ports the base file publishes.
+name: infisical-test
+
+services:
+ api-tests:
+ network_mode: host
+ environment:
+ DB_CONNECTION_URI: postgres://infisical:infisical@localhost:5436/infisical-test?sslmode=disable
+ REDIS_URL: redis://localhost:6380