Skip to content

Commit

Permalink
(chore) O3-2516: Add docker setup to run E2E on Bamboo (#67)
Browse files Browse the repository at this point in the history
Add docker setup to run E2E on Bamboo
  • Loading branch information
jayasanka-sack authored Oct 21, 2023
1 parent c29793d commit 37d660d
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dist/

# Intellij integration
*.iml
.idea/*

# ignores for Yarn v3 w/o PNP
.pnp.*
Expand Down
56 changes: 56 additions & 0 deletions e2e/support/bamboo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This docker compose file is used to create a dockerized environment when running E2E tests on Bamboo.
version: "3.7"

services:
playwright:
build:
context: .
dockerfile: playwright.Dockerfile
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
container_name: cohort-builder-e2e-tests-container
working_dir: /app
command: sh /app/e2e/support/bamboo/e2e-test-runner.sh
volumes:
- ../../../:/app
networks:
- test

gateway:
image: openmrs/openmrs-reference-application-3-gateway:${TAG:-nightly}
depends_on:
- frontend
- backend
ports:
- "80:80"
networks:
- test

frontend:
image: openmrs/openmrs-reference-application-3-frontend:${TAG:-nightly}
environment:
SPA_PATH: /openmrs/spa
API_URL: /openmrs
SPA_CONFIG_URLS:
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost/" ]
timeout: 5s
depends_on:
- backend
networks:
- test

backend:
image: openmrs/openmrs-reference-application-3-backend:nightly-with-data
depends_on:
- db
networks:
- test
db:
image: openmrs/openmrs-reference-application-3-db:nightly-with-data
networks:
- test

networks:
test:
13 changes: 13 additions & 0 deletions e2e/support/bamboo/e2e-test-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

export E2E_BASE_URL=http://gateway/openmrs
export CI=true

while [ "$(curl -s -o /dev/null -w ''%{http_code}'' http://gateway/openmrs/login.htm)" != "200" ]; do
echo "Waiting for the backend to be up..."
sleep 10
done

cp example.env .env

yarn test-e2e
12 changes: 12 additions & 0 deletions e2e/support/bamboo/playwright.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/playwright:v1.39.0-jammy

ARG USER_ID
ARG GROUP_ID

RUN if ! getent group $GROUP_ID > /dev/null; then \
groupadd -g $GROUP_ID myusergroup; \
fi

RUN useradd -u $USER_ID -g $GROUP_ID -m playwrightuser

USER playwrightuser
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@openmrs/esm-framework": "next",
"@openmrs/esm-patient-common-lib": "next",
"@openmrs/esm-styleguide": "next",
"@playwright/test": "1.34.0",
"@playwright/test": "1.39.0",
"@swc/cli": "^0.1.61",
"@swc/core": "^1.3.34",
"@swc/jest": "^0.2.24",
Expand Down
10 changes: 3 additions & 7 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ const config: PlaywrightTestConfig = {
expect: {
timeout: 40 * 1000,
},
fullyParallel: true,
outputDir: "../test-results/results",
workers: 1,
forbidOnly: !!process.env.CI,
retries: 0,
reporter: process.env.CI
? [
["junit", { outputFile: "results.xml" }],
["html", { outputFolder: "../test-results/report" }],
]
: [["html", { outputFolder: "../test-results/report" }]],
? [["junit", { outputFile: "results.xml" }], ["html"]]
: [["html"]],
globalSetup: require.resolve("./e2e/core/global-setup"),
use: {
baseURL: `${process.env.E2E_BASE_URL}/spa/`,
Expand Down
42 changes: 27 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ __metadata:
"@openmrs/esm-framework": next
"@openmrs/esm-patient-common-lib": next
"@openmrs/esm-styleguide": next
"@playwright/test": 1.34.0
"@playwright/test": 1.39.0
"@swc/cli": ^0.1.61
"@swc/core": ^1.3.34
"@swc/jest": ^0.2.24
Expand Down Expand Up @@ -3293,19 +3293,14 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:1.34.0":
version: 1.34.0
resolution: "@playwright/test@npm:1.34.0"
"@playwright/test@npm:1.39.0":
version: 1.39.0
resolution: "@playwright/test@npm:1.39.0"
dependencies:
"@types/node": "*"
fsevents: 2.3.2
playwright-core: 1.34.0
dependenciesMeta:
fsevents:
optional: true
playwright: 1.39.0
bin:
playwright: cli.js
checksum: 269074a9b58370633575b99d95135edcd8b5351c19f82b88392f9fc6b0f2dc3687e631d59864aa0cffa382534dd83163069569e67972b4fc63d1bef3fb7372d8
checksum: e93e58fc1af4239f239b890374f066c9a758e2492d25e2c1a532f3f00782ab8e7706956a07540fd14882c74e75f5de36273621adce9b79afb8e36e6c15f1d539
languageName: node
linkType: hard

Expand Down Expand Up @@ -12719,10 +12714,27 @@ __metadata:
languageName: node
linkType: hard

"playwright-core@npm:1.34.0":
version: 1.34.0
resolution: "playwright-core@npm:1.34.0"
checksum: 1821ab254b3c756e52c144c26cae7250dd5a1c779277cdd583bd289501d45cceaea40a8185ebf7eaa56b8291e4a042e3eef65f511da2306349c275794c9a582d
"playwright-core@npm:1.39.0":
version: 1.39.0
resolution: "playwright-core@npm:1.39.0"
bin:
playwright-core: cli.js
checksum: 556e78dee4f9890facf2af8249972e0d6e01a5ae98737b0f6b0166c660a95ffee4cb79350335b1ef96430a0ef01d3669daae9099fa46c8d403d11c623988238b
languageName: node
linkType: hard

"playwright@npm:1.39.0":
version: 1.39.0
resolution: "playwright@npm:1.39.0"
dependencies:
fsevents: 2.3.2
playwright-core: 1.39.0
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: 96d8ca5aa25465c1c5d554d0d6071981d55e22477800ff8f5d47a53ca75193d60ece2df538a01b7165b3277dd5493c67603a5acda713029df7fbd95ce2417bc9
languageName: node
linkType: hard

Expand Down

0 comments on commit 37d660d

Please sign in to comment.