Skip to content

Commit

Permalink
fix: merge NG_API_URL and BASE_URL_IBF_SERVICE into API_SERVICE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Oct 1, 2024
1 parent 5425539 commit 9c1d2bb
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 89 deletions.
155 changes: 77 additions & 78 deletions .github/actions/e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand Down
3 changes: 1 addition & 2 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -69,4 +69,3 @@ TWILIO_WHATSAPP_NUMBER=+
# Playwright configuration
AZURE_DEV_URL=
AZURE_DEVOPS_TOKEN=
BASE_URL_IBF_SERVICE=http://localhost:3000/api
2 changes: 1 addition & 1 deletion handover.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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: <DASHBOARD_URL>/api
NG_API_URL=
API_SERVICE_URL=
# Fill in as: <DASHBOAR_URL>/geoserver/ibf-system/wms
NG_GEOSERVER_URL=

Expand Down
4 changes: 2 additions & 2 deletions interfaces/IBF-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}`;
Expand Down
2 changes: 1 addition & 1 deletion services/API-service/test/helpers/utility.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9c1d2bb

Please sign in to comment.