Skip to content

Commit 3b78ca8

Browse files
committed
Add openmrs e2e tests to test both LIME demo
1 parent 55b0af1 commit 3b78ca8

File tree

4 files changed

+173
-7
lines changed

4 files changed

+173
-7
lines changed

.github/workflows/run-e2e-tests.yml

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Run E2E Tests on Release PRs
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
patient_management_ref: ${{steps.refs.outputs.patient_management}}
14+
patient_chart_ref: ${{steps.refs.outputs.patient_chart}}
15+
esm_core_ref: ${{steps.refs.outputs.esm_core}}
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Build and Run Containers
23+
run: docker-compose -f distro/e2e_test_support_files/docker-compose-build.yml up -d
24+
25+
- name: Wait for the backend to start
26+
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/openmrs/login.htm)" != "200" ]]; do sleep 10; done
27+
28+
- name: Commit and export Containers
29+
run: sh distro/e2e_test_support_files/commit_and_export_images.sh
30+
31+
- name: Upload artifact
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: e2e_release_env_images
35+
path: e2e_release_env_images.tar.gz
36+
retention-days: 1
37+
38+
run-patient-management-e2e-tests:
39+
runs-on: ubuntu-latest
40+
needs: build
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Create Temporary Directory to Download Docker Images
45+
id: tempdir
46+
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
47+
48+
- name: Download Docker Images
49+
uses: actions/download-artifact@v3
50+
with:
51+
name: e2e_release_env_images
52+
path: ${{ steps.tempdir.outputs.tmpdir }}
53+
54+
- name: Load Docker Images
55+
run: |
56+
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
57+
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
58+
docker image ls -a
59+
60+
- name: Spin up an OpenMRS Instance
61+
run: docker-compose up -d
62+
working-directory: distro/e2e_test_support_files
63+
64+
- name: Checkout to the Repo's Tag
65+
uses: actions/checkout@v4
66+
with:
67+
repository: openmrs/openmrs-esm-patient-management
68+
ref: ${{ needs.build.outputs.patient_management_ref }}
69+
path: e2e_repo
70+
71+
- name: Copy test environment variables
72+
run: cp example.env .env
73+
working-directory: e2e_repo
74+
75+
- name: Install dependencies
76+
if: steps.cache.outputs.cache-hit != 'true'
77+
run: yarn install --immutable
78+
working-directory: e2e_repo
79+
80+
- name: Install Playwright Browsers
81+
run: npx playwright install chromium --with-deps
82+
working-directory: e2e_repo
83+
84+
- name: Wait for the OpenMRS instance to start
85+
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done
86+
87+
- name: Run E2E tests
88+
run: yarn playwright test
89+
working-directory: e2e_repo
90+
91+
- name: Upload Report
92+
uses: actions/upload-artifact@v3
93+
if: always()
94+
with:
95+
name: report-patient-management
96+
path: e2e_repo/playwright-report/
97+
retention-days: 30
98+
99+
run-patient-chart-e2e-tests:
100+
runs-on: ubuntu-latest
101+
needs: build
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Create Temporary Directory to Download Docker Images
106+
id: tempdir
107+
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
108+
109+
- name: Download Docker Images
110+
uses: actions/download-artifact@v3
111+
with:
112+
name: e2e_release_env_images
113+
path: ${{ steps.tempdir.outputs.tmpdir }}
114+
115+
- name: Load Docker Images
116+
run: |
117+
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
118+
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
119+
docker image ls -a
120+
121+
- name: Spin up an OpenMRS Instance
122+
run: docker-compose up -d
123+
working-directory: distro/e2e_test_support_files
124+
125+
- name: Checkout to the Repo's Tag
126+
uses: actions/checkout@v4
127+
with:
128+
repository: openmrs/openmrs-esm-patient-chart
129+
ref: ${{ needs.build.outputs.patient_chart_ref }}
130+
path: e2e_repo
131+
132+
- name: Copy test environment variables
133+
run: cp example.env .env
134+
working-directory: e2e_repo
135+
136+
- name: Install dependencies
137+
if: steps.cache.outputs.cache-hit != 'true'
138+
run: yarn install --immutable
139+
working-directory: e2e_repo
140+
141+
- name: Install Playwright Browsers
142+
run: npx playwright install chromium --with-deps
143+
working-directory: e2e_repo
144+
145+
- name: Wait for the OpenMRS instance to start
146+
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done
147+
148+
- name: Run E2E tests
149+
run: yarn playwright test
150+
working-directory: e2e_repo
151+
152+
- name: Upload Report
153+
uses: actions/upload-artifact@v3
154+
if: always()
155+
with:
156+
name: report-patient-chart
157+
path: e2e_repo/playwright-report/
158+
retention-days: 30

distro/e2e_test_support_files/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ component. It then downloads Docker images from a previous "build" job, loads th
4848

4949
The workflow checks out a specific tagged version of the component's repository, the tag is imported from the previous "
5050
build" job. This is necessary because the goal is to perform end-to-end tests on the codebase that corresponds to a
51-
particular release version, rather than the code at the head of the repository.
51+
particular release version, rather than the code at the head of the repository. In case of using pre-releases, it checkouts
52+
to the main branch as we don't create tags for pre-releases.

distro/e2e_test_support_files/docker-compose-build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3.7"
33
services:
44
gateway:
55
build:
6-
context: ../gateway
6+
context: ../../gateway
77
container_name: gateway
88
restart: "unless-stopped"
99
depends_on:
@@ -14,7 +14,7 @@ services:
1414

1515
frontend:
1616
build:
17-
context: ../frontend
17+
context: ../../frontend
1818
container_name: frontend
1919
restart: "unless-stopped"
2020
environment:
@@ -30,7 +30,7 @@ services:
3030

3131
backend:
3232
build:
33-
context: ../
33+
context: ../../
3434
container_name: backend
3535
depends_on:
3636
- db

distro/e2e_test_support_files/extract_tag_numbers.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ get_repository_tag() {
55
local file="$1"
66
local repo_name="$2"
77
local app="$3"
8-
local value
9-
value=$(awk -F'"' -v app="$app" '$0 ~ app {print $4}' "$file")
10-
echo "$repo_name=$value"
8+
9+
local version=$(awk -F'"' -v app="$app" '$0 ~ app {print $4}' "$file")
10+
local ref="refs/tags/v$version"
11+
12+
# Check if the version number contains "pre" and modify the ref to main branch
13+
if [[ $version == *"pre"* ]]; then
14+
ref="main"
15+
fi
16+
17+
echo "$repo_name=$ref"
1118
}
1219

1320
file_path="frontend/spa-build-config.json"

0 commit comments

Comments
 (0)