From de3eca2fd9e6af2267139b8763ea0837e216cb4a Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:16:36 +0100 Subject: [PATCH] Use host network in github action --- .github/workflows/preview-service-acceptance.yml | 2 +- packages/preview-service/tests/acceptance/acceptance.spec.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview-service-acceptance.yml b/.github/workflows/preview-service-acceptance.yml index 611cba0453..4137011531 100644 --- a/.github/workflows/preview-service-acceptance.yml +++ b/.github/workflows/preview-service-acceptance.yml @@ -72,7 +72,7 @@ jobs: OUTPUT_FILE_PATH: /tmp/preview-service-output.png NODE_ENV: test PG_CONNECTION_STRING: postgres://preview_service_test:preview_service_test@localhost:5432/preview_service_test - DOCKER_PG_CONNECTION_STRING: postgres://preview_service_test:preview_service_test@postgres:5432/preview_service_test + IS_HOST_NETWORK: 'true' - uses: actions/upload-artifact@v4 name: Upload the output from the preview-service diff --git a/packages/preview-service/tests/acceptance/acceptance.spec.ts b/packages/preview-service/tests/acceptance/acceptance.spec.ts index 4de8da50de..7b6cb23f9e 100644 --- a/packages/preview-service/tests/acceptance/acceptance.spec.ts +++ b/packages/preview-service/tests/acceptance/acceptance.spec.ts @@ -13,11 +13,13 @@ describe.sequential('Acceptance', () => { beforeEach(() => { const dbName = inject('dbName') const pgConnString = - process.env.DOCKER_PG_CONNECTION_STRING || + process.env.PG_CONNECTION_STRING || `postgres://preview_service_test:preview_service_test@host.docker.internal:5432/${dbName}` + const isHostNetwork = process.env.IS_HOST_NETWORK === 'true' //purposefully running in the background without waiting void runProcess('docker', [ 'run', + isHostNetwork ? '--network="host"' : '', '--env', `PG_CONNECTION_STRING=${pgConnString}`, '--rm',