From 9c1d2bb0de5a3fa68ae5d192299dbb495deb1815 Mon Sep 17 00:00:00 2001 From: jannisvisser Date: Tue, 1 Oct 2024 15:06:04 +0200 Subject: [PATCH] fix: merge NG_API_URL and BASE_URL_IBF_SERVICE into API_SERVICE_URL --- .github/actions/e2e/action.yml | 155 +++++++++--------- docker-compose.yml | 6 +- example.env | 3 +- handover.example.env | 2 +- interfaces/IBF-dashboard/Dockerfile | 4 +- .../src/environments/environment.template.ts | 2 +- .../api/notification/helpers/mjml.helper.ts | 2 +- .../test/helpers/utility.helper.ts | 2 +- 8 files changed, 87 insertions(+), 89 deletions(-) diff --git a/.github/actions/e2e/action.yml b/.github/actions/e2e/action.yml index 6389ceac05..adc30637d2 100644 --- a/.github/actions/e2e/action.yml +++ b/.github/actions/e2e/action.yml @@ -7,81 +7,80 @@ inputs: required: true runs: - using: composite - - steps: - - name: Set up Node.js version - uses: actions/setup-node@v4 - with: - node-version-file: './e2e/.node-version' - cache: 'npm' - cache-dependency-path: './e2e/package-lock.json' - - - name: Install e2e code-dependencies - shell: bash - working-directory: ./e2e - run: npm ci --omit=optional --no-fund --no-audit - - - name: Lint e2e code - shell: bash - working-directory: ./e2e - run: npm run lint - - - name: Setup environment variables - shell: bash - run: cp example.env .env - - - name: Install IBF API-service code-dependencies - shell: bash - working-directory: ./services/API-service - run: npm ci --omit=optional --no-fund --no-audit - - - name: Run IBF API-service - shell: bash - env: - MC_API: ${{ inputs.mailchimp-api-key }} - run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d ibf-api-service - - - name: Start IBF dashboard - shell: bash - working-directory: 'interfaces/IBF-dashboard' - env: - NG_API_URL: http://localhost:3000/api - NG_CONFIGURATION: production - run: | - npm install - npm run start:prod > dashboard-logs.txt 2>&1 & - - - name: Install runtime dependencies - shell: bash - working-directory: ./e2e - run: npx playwright install chromium --with-deps - - - name: Wait for IBF API-service to be running - shell: bash - run: timeout 60s sh -c 'until curl http://localhost:3000/api -I; do echo "Waiting for the IBF API-service to be running..."; sleep 1; done' - - - name: Wait for IBF dashboard to be running - shell: bash - run: timeout 60s sh -c 'until curl http://localhost:4200 -I; do echo "Waiting for the IBF dashboard to be running..."; sleep 1; done' - - - name: Run end-to-end tests - shell: bash - working-directory: ./e2e - env: - DASHBOARD_URL: http://localhost:4200 - run: npm test - - - uses: actions/upload-artifact@v4 - if: always() - with: - name: test-result-artifacts - path: | - ./e2e/test-results/ - ./interfaces/IBF-dashboard/dashboard-logs.txt - retention-days: 30 - - - name: Docker logs - if: always() - uses: jwalton/gh-docker-logs@v2 - + using: composite + + steps: + - name: Set up Node.js version + uses: actions/setup-node@v4 + with: + node-version-file: './e2e/.node-version' + cache: 'npm' + cache-dependency-path: './e2e/package-lock.json' + + - name: Install e2e code-dependencies + shell: bash + working-directory: ./e2e + run: npm ci --omit=optional --no-fund --no-audit + + - name: Lint e2e code + shell: bash + working-directory: ./e2e + run: npm run lint + + - name: Setup environment variables + shell: bash + run: cp example.env .env + + - name: Install IBF API-service code-dependencies + shell: bash + working-directory: ./services/API-service + run: npm ci --omit=optional --no-fund --no-audit + + - name: Run IBF API-service + shell: bash + env: + MC_API: ${{ inputs.mailchimp-api-key }} + run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d ibf-api-service + + - name: Start IBF dashboard + shell: bash + working-directory: 'interfaces/IBF-dashboard' + env: + API_SERVICE_URL: http://localhost:3000/api + NG_CONFIGURATION: production + run: | + npm install + npm run start:prod > dashboard-logs.txt 2>&1 & + + - name: Install runtime dependencies + shell: bash + working-directory: ./e2e + run: npx playwright install chromium --with-deps + + - name: Wait for IBF API-service to be running + shell: bash + run: timeout 60s sh -c 'until curl http://localhost:3000/api -I; do echo "Waiting for the IBF API-service to be running..."; sleep 1; done' + + - name: Wait for IBF dashboard to be running + shell: bash + run: timeout 60s sh -c 'until curl http://localhost:4200 -I; do echo "Waiting for the IBF dashboard to be running..."; sleep 1; done' + + - name: Run end-to-end tests + shell: bash + working-directory: ./e2e + env: + DASHBOARD_URL: http://localhost:4200 + run: npm test + + - uses: actions/upload-artifact@v4 + if: always() + with: + name: test-result-artifacts + path: | + ./e2e/test-results/ + ./interfaces/IBF-dashboard/dashboard-logs.txt + retention-days: 30 + + - name: Docker logs + if: always() + uses: jwalton/gh-docker-logs@v2 diff --git a/docker-compose.yml b/docker-compose.yml index 0e02d5f95a..d8b2860b33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,7 +46,7 @@ services: - TWILIO_MESSAGING_SID=${TWILIO_MESSAGING_SID} - EXTERNAL_API_SERVICE_URL=${EXTERNAL_API_SERVICE_URL} - TWILIO_WHATSAPP_NUMBER=${TWILIO_WHATSAPP_NUMBER} - - NG_API_URL=${NG_API_URL} + - API_SERVICE_URL=${API_SERVICE_URL} volumes: - 'api_service_node_modules:/home/ibf/api-service/node_modules' - ./services/API-service:/home/ibf/api-service @@ -60,7 +60,7 @@ services: context: ./interfaces/IBF-dashboard args: - NG_CONFIGURATION=${NG_CONFIGURATION} - - NG_API_URL=${NG_API_URL} + - API_SERVICE_URL=${API_SERVICE_URL} - NG_USE_SERVICE_WORKER=${NG_USE_SERVICE_WORKER} - NG_GEOSERVER_URL=${NG_GEOSERVER_URL} - NG_IBF_SYSTEM_VERSION=${NG_IBF_SYSTEM_VERSION} @@ -72,7 +72,7 @@ services: - WHATS_NEW_URL=${WHATS_NEW_URL} environment: - NG_CONFIGURATION=${NG_CONFIGURATION} - - NG_API_URL=${NG_API_URL} + - API_SERVICE_URL=${API_SERVICE_URL} - NG_USE_SERVICE_WORKER=${NG_USE_SERVICE_WORKER} - NG_GEOSERVER_URL=${NG_GEOSERVER_URL} - NG_IBF_SYSTEM_VERSION=${NG_IBF_SYSTEM_VERSION} diff --git a/example.env b/example.env index 928630cd78..7f41933174 100644 --- a/example.env +++ b/example.env @@ -12,6 +12,7 @@ SECRET=secret RESET_SECRET=fill_in_secret NODE_ENV=development LOCAL_PORT_IBF_SERVICE=3000 # If you do not specify a port, the default port is 3000. this only applies to the override docker-compose file +API_SERVICE_URL=http://localhost:3000/api # URL should not end with trailing slash # Token used to acces the water point data at https://data.waterpointdata.org/profile/edit/developer_settings WATERPOINTDATA_TOKEN= @@ -28,7 +29,6 @@ GEOSERVER_ADMIN_PASSWORD= # interfaces/IBF-dashboard NG_CONFIGURATION= -NG_API_URL=http://localhost:3000/api # URL should not end with trailing slash NG_USE_SERVICE_WORKER= NG_GEOSERVER_URL= NG_IBF_SYSTEM_VERSION= @@ -69,4 +69,3 @@ TWILIO_WHATSAPP_NUMBER=+ # Playwright configuration AZURE_DEV_URL= AZURE_DEVOPS_TOKEN= -BASE_URL_IBF_SERVICE=http://localhost:3000/api diff --git a/handover.example.env b/handover.example.env index 65f1071efa..468c134c26 100644 --- a/handover.example.env +++ b/handover.example.env @@ -40,7 +40,7 @@ FQDN= # Fill in the URL pointing to the dashboard including https: e.g. https://ibf.510.global DASHBOARD_URL= # Fill in as: /api -NG_API_URL= +API_SERVICE_URL= # Fill in as: /geoserver/ibf-system/wms NG_GEOSERVER_URL= diff --git a/interfaces/IBF-dashboard/Dockerfile b/interfaces/IBF-dashboard/Dockerfile index 43a7f3da0a..fbfc4ef106 100644 --- a/interfaces/IBF-dashboard/Dockerfile +++ b/interfaces/IBF-dashboard/Dockerfile @@ -19,8 +19,8 @@ EXPOSE 4200 ARG NG_CONFIGURATION ENV NG_CONFIGURATION=$NG_CONFIGURATION -ARG NG_API_URL -ENV NG_API_URL=$NG_API_URL +ARG API_SERVICE_URL +ENV API_SERVICE_URL=$API_SERVICE_URL ARG NG_USE_SERVICE_WORKER ENV NG_USE_SERVICE_WORKER=$NG_USE_SERVICE_WORKER diff --git a/interfaces/IBF-dashboard/src/environments/environment.template.ts b/interfaces/IBF-dashboard/src/environments/environment.template.ts index 10b5719eb6..e6d1ffc0d4 100644 --- a/interfaces/IBF-dashboard/src/environments/environment.template.ts +++ b/interfaces/IBF-dashboard/src/environments/environment.template.ts @@ -4,7 +4,7 @@ module.exports = `// export const environment = { configuration: '${process.env.NG_CONFIGURATION || 'production'}', - apiUrl: '${process.env.NG_API_URL}', // API + apiUrl: '${process.env.API_SERVICE_URL}', // API useServiceWorker: ${ process.env.NG_USE_SERVICE_WORKER === 'true' }, // feature-flags diff --git a/services/API-service/src/api/notification/helpers/mjml.helper.ts b/services/API-service/src/api/notification/helpers/mjml.helper.ts index 3a7a630f14..8103ba607e 100644 --- a/services/API-service/src/api/notification/helpers/mjml.helper.ts +++ b/services/API-service/src/api/notification/helpers/mjml.helper.ts @@ -252,7 +252,7 @@ export const getMapImgSrc = ( eventName: string, ): string => { return `${ - process.env.NG_API_URL + process.env.API_SERVICE_URL }/event/event-map-image/${countryCodeISO3}/${disasterType}/${ eventName || 'no-name' }`; diff --git a/services/API-service/test/helpers/utility.helper.ts b/services/API-service/test/helpers/utility.helper.ts index 5269a90d5d..52ebef3a01 100644 --- a/services/API-service/test/helpers/utility.helper.ts +++ b/services/API-service/test/helpers/utility.helper.ts @@ -29,7 +29,7 @@ export function loginApi( } export function getHostname(): string { - return process.env.BASE_URL_IBF_SERVICE || 'http://localhost:3000/api'; + return process.env.API_SERVICE_URL || 'http://localhost:3000/api'; } export function getEventTitle(disasterType: string, eventName: string) {