-
Notifications
You must be signed in to change notification settings - Fork 556
143 lines (119 loc) · 4.04 KB
/
e2e-tests-on-commit.yml
File metadata and controls
143 lines (119 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Run E2E Tests on PRs and Commits
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v6
- name: Build and Run Containers
run: docker compose -f ./tests/e2e/docker-compose-build.yml up -d
- name: Wait for the backend to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/openmrs/login.htm)" != "200" ]]; do sleep 10; done
- name: Commit and export Containers
run: bash ./tests/e2e/commit_and_export_images.sh
shell: bash
- name: Verify artifact was created
run: |
echo "Workspace: $GITHUB_WORKSPACE"
ls -la .
if [[ ! -f e2e_release_env_images.tar.gz ]]; then
echo "ERROR: e2e_release_env_images.tar.gz not found"
exit 1
fi
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: e2e_release_env_images
path: e2e_release_env_images.tar.gz
retention-days: 1
if-no-files-found: error
- name: 📝 Capture Server Logs
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: "./logs"
- name: 📤 Upload Logs as Artifact
uses: actions/upload-artifact@v5
if: failure()
with:
name: server-logs-build-backend
path: "./logs"
overwrite: true
run-e2e-tests:
runs-on: ubuntu-latest
needs: build
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
repo:
- openmrs-esm-patient-management
- openmrs-esm-patient-chart
- openmrs-esm-form-builder
- openmrs-esm-core
- openmrs-esm-dispensing-app
- openmrs-esm-billing-app
steps:
- uses: actions/checkout@v6
- name: Create Temporary Directory to Download Docker Images
id: tempdir
run: echo "tmpdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
- name: Download Docker Images
uses: actions/download-artifact@v6
with:
name: e2e_release_env_images
path: ${{ steps.tempdir.outputs.tmpdir }}
- name: Load Docker Images
run: |
gzip -d ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar.gz
docker load --input ${{ steps.tempdir.outputs.tmpdir }}/e2e_release_env_images.tar
docker image ls -a
- name: Spin up an OpenMRS Instance
run: docker compose up -d
working-directory: ./tests/e2e/
- name: Checkout to the repo's main branch
uses: actions/checkout@v6
with:
repository: openmrs/${{ matrix.repo }}
ref: main
path: e2e_repo
- name: Copy test environment variables
run: cp example.env .env
working-directory: e2e_repo
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo
- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
working-directory: e2e_repo
- name: Wait for the OpenMRS instance to start
run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done
- name: Run E2E tests
run: yarn playwright test
working-directory: e2e_repo
- name: Upload Report
uses: actions/upload-artifact@v5
if: failure()
with:
name: report-${{ matrix.repo }}
path: e2e_repo/playwright-report/
retention-days: 30
- name: 📝 Capture Server Logs
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: "./logs"
- name: 📤 Upload Logs as Artifact
uses: actions/upload-artifact@v5
if: failure()
with:
name: server-logs-${{ matrix.repo }}
path: "./logs"
overwrite: true