-
Notifications
You must be signed in to change notification settings - Fork 213
208 lines (170 loc) · 6.23 KB
/
e2e.yml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: E2E Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
TURBO_API: 'http://127.0.0.1:9080'
TURBO_TOKEN: 'turbo-token'
TURBO_TEAM: ${{ github.repository_owner }}
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
test-changes: ${{ steps.changes.outputs.test-sources }}
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4
- name: 🔍 Check if any source code has changed
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
test-sources:
- 'packages/**/src/**/*!(.test).ts'
- 'packages/**/src/**/*!(.test).tsx'
- 'packages/**/src/**/*!(.test).js'
- 'packages/**/src/**/*!(.test).jsx'
- 'packages/**/src/**/*.scss'
- 'packages/**/src/routes.json'
- 'package.json'
- 'playwright.config.ts'
- 'e2e/**/*.ts'
- 'e2e/**/*.js'
- 'e2e/support/github/**/*.*'
- 'example.env'
- '.github/workflows/e2e.yml'
run-e2e-on-esm-core:
needs: changes
if: ${{ needs.changes.outputs.test-changes == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: 📥 Checkout repo
uses: actions/checkout@v4
- name: 📄 Copy test environment variables
run: cp example.env .env
- name: 🛠️ Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- name: 💾 Cache dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: 📦 Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: 🚀 Setup local cache server for Turborepo
uses: felixmosh/turborepo-gh-artifacts@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- name: 🏗️ Build apps
run: yarn turbo run build --color --concurrency=5
- name: 🖥️ Run dev server
run: bash e2e/support/github/run-e2e-docker-env.sh
- name: 📄 Copy test environment variables
run: cp example.env .env
- name: 💾 Cache Playwright Browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/yarn.lock') }}
- name: 🎭 Install Playwright Browsers
run: npx playwright install chromium --with-deps
- 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
- name: 📤 Upload Report
uses: actions/upload-artifact@v4
if: always()
with:
name: report-esm-core
path: playwright-report/
retention-days: 30
run-e2e-on-other-repos:
needs: changes
if: ${{ needs.changes.outputs.test-changes == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
repo:
- openmrs-esm-patient-management
- openmrs-esm-patient-chart
- openmrs-esm-form-builder
steps:
- name: 📥 Checkout esm-core repo
uses: actions/checkout@v4
- name: 🛠️ Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- name: 💾 Cache dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: 📦 Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo
- name: 🚀 Setup local cache server for Turborepo
uses: felixmosh/turborepo-gh-artifacts@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
server-token: ${{ env.TURBO_TOKEN }}
- name: 🏗️ Build apps
run: yarn turbo run build --color --concurrency=5
- name: 🖥️ Run dev server
run: bash e2e/support/github/run-e2e-docker-env.sh
- name: 📥 Checkout to the ${{ matrix.repo }} main branch
uses: actions/checkout@v4
with:
repository: openmrs/${{ matrix.repo }}
ref: main
path: e2e_repo
- name: 📄 Copy test environment variables for ${{ matrix.repo }}
run: cp example.env .env
working-directory: e2e_repo
- name: 💾 Cache dependencies for ${{ matrix.repo }}
id: cache-other-repo-dependencies
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('e2e_repo/**/yarn.lock') }}
- name: 📦 Install dependencies for ${{ matrix.repo }}
if: steps.cache-other-repo-dependencies.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: e2e_repo
- name: 💾 Cache Playwright Browsers for ${{ matrix.repo }}
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('e2e_repo/**/yarn.lock') }}
- name: 🎭 Install Playwright Browsers for ${{ matrix.repo }}
run: yarn playwright install --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 for ${{ matrix.repo }}
run: yarn playwright test
working-directory: e2e_repo
- name: 📤 Upload Report for ${{ matrix.repo }}
uses: actions/upload-artifact@v4
if: always()
with:
name: report-${{ matrix.repo }}
path: e2e_repo/playwright-report/
retention-days: 30