-
Notifications
You must be signed in to change notification settings - Fork 2
265 lines (230 loc) · 9.05 KB
/
main.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Main
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
versions:
name: Get Versions 📜
uses: CrisisCleanup/crisiscleanup-4-web/.github/workflows/get-versions.yml@master
lint:
name: Lint 💅
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [versions]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- name: Install
run: pnpm install
- name: Lint
run: pnpm run lint
type-check:
name: Type Check 📝
runs-on: ubuntu-latest
timeout-minutes: 30
# disabled till we fix the type errors
if: false
needs: [versions]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- name: Install
run: pnpm install
- name: Type check
run: pnpm run typecheck
build:
name: Build 🏗️
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [versions]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- name: Install
run: pnpm install
- name: Build app
run: pnpm run build:app
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
test:
name: Test 🧪
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [versions]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- run: pnpm install
- run: pnpm run test
- name: 📊 Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: unitTests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
test-e2e:
name: 🧪 E2E Tests (${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) | ${{ matrix.project }}
timeout-minutes: 60
runs-on: ${{ matrix.os }}
needs: [versions]
# TODO: testing on PRs doesnt make sense like this.
# Could setup feature branch deployments though.
if: ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'pull_request')
continue-on-error: true
strategy:
fail-fast: false
matrix:
project: [chromium, firefox]
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
include:
- project: chromium
os: ubuntu-latest
cache_dir: ~/.cache/ms-playwright
- project: firefox
os: ubuntu-latest
cache_dir: ~/.cache/ms-playwright
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- name: 🔧 Setup Env Vars
run: |
#####################
# STAGING ENV VARS
#####################
# echo 'NODE_ENV=development' >> $GITHUB_ENV
# echo 'VITE_APP_STAGE=staging' >> $GITHUB_ENV
# echo 'VITE_APP_BASE_URL=http://localhost:8080' >> $GITHUB_ENV
# echo 'VITE_APP_API_BASE_URL=https://api.staging.crisiscleanup.io' >> $GITHUB_ENV
# echo 'VITE_APP_WS_URL=wss://socket.staging.crisiscleanup.io' >> $GITHUB_ENV
# echo 'VITE_APP_AWS_CCP_URL=https://ccustaging.awsapps.com/connect/ccp-v2/' >> $GITHUB_ENV
# echo 'VITE_APP_CCP_INSTANCE=414df788-cd99-4580-ad07-f8af22246ce5' >> $GITHUB_ENV
# echo 'VITE_APP_PORTAL_KEY=crisiscleanup_staging' >> $GITHUB_ENV
# echo 'VITE_APP_PHONE_DEFAULT_USERNAME=english' >> $GITHUB_ENV
# echo 'VITE_APP_PHONE_DEFAULT_PASSWORD=volunteer' >> $GITHUB_ENV
# echo 'VITE_APP_ENGLISH_PHONE_GATEWAY=124906' >> $GITHUB_ENV
# echo 'VITE_APP_SPANISH_PHONE_GATEWAY=124906' >> $GITHUB_ENV
# echo 'VITE_APP_DEFAULT_CALLER_ID=2722003211' >> $GITHUB_ENV
# echo 'VITE_APP_PHONE_DOCTOR_NUMBER=2722003211' >> $GITHUB_ENV
# echo 'VITE_APP_CRISISCLEANUP_WEB_CLIENT_ID=QOHomvSiigXtzUwl0P91LaAgnjo7zFJ72Brchddn' >> $GITHUB_ENV
# echo 'TEST_APP_EMAIL=${{ secrets.TEST_APP_EMAIL_PROD }}' >> $GITHUB_ENV
# echo 'TEST_APP_PASSWORD=${{ secrets.TEST_APP_PASSWORD_PROD }}' >> $GITHUB_ENV
# echo 'TEST_APP_ADMIN_EMAIL=${{ secrets.TEST_APP_ADMIN_EMAIL_PROD }}' >> $GITHUB_ENV
# echo 'TEST_APP_ADMIN_PASSWORD=${{ secrets.TEST_APP_ADMIN_PASSWORD_PROD }}' >> $GITHUB_ENV
#####################
# DEVELOPMENT ENV VARS
#####################
echo 'NODE_ENV=development' >> $GITHUB_ENV
echo 'VITE_APP_STAGE=development' >> $GITHUB_ENV
echo 'VITE_APP_BASE_URL=http://localhost:8080' >> $GITHUB_ENV
echo 'VITE_APP_API_BASE_URL=https://api.dev.crisiscleanup.io' >> $GITHUB_ENV
echo 'VITE_APP_WS_URL=wss://socket.dev.crisiscleanup.io' >> $GITHUB_ENV
echo 'VITE_APP_AWS_CCP_URL=https://ccudev.awsapps.com/connect/ccp-v2/' >> $GITHUB_ENV
echo 'VITE_APP_CCP_INSTANCE=87fbcad4-9f58-4153-84e8-d5b7202693e8' >> $GITHUB_ENV
echo 'VITE_APP_CRISISCLEANUP_WEB_CLIENT_ID=PAz48HT2nBNSkuvKWLLJ8gq7ewG5yJvHyoDdGy5v' >> $GITHUB_ENV
echo 'TEST_APP_EMAIL=${{ secrets.TEST_APP_EMAIL_DEV }}' >> $GITHUB_ENV
echo 'TEST_APP_PASSWORD=${{ secrets.TEST_APP_PASSWORD_DEV }}' >> $GITHUB_ENV
echo 'TEST_APP_ADMIN_EMAIL=${{ secrets.TEST_APP_ADMIN_EMAIL_DEV }}' >> $GITHUB_ENV
echo 'TEST_APP_ADMIN_PASSWORD=${{ secrets.TEST_APP_ADMIN_PASSWORD_DEV }}' >> $GITHUB_ENV
- name: 📥 Install dependencies
run: pnpm install
- name: 🔧 Set Playwright Version
run: pnpm exec playwright --version > .github/.playwright-version
- name: ⚡️ Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: ${{ matrix.cache_dir }}
key: ${{ runner.os }}-${{ matrix.project }}-pw-${{ hashFiles('**/.playwright-version') }}
- name: 📥 Install ${{ matrix.project }} with Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps ${{ matrix.project }}
- name: 🏗️ Build App
run: pnpm run build:app
- name: 🎭 Playwright tests
run: pnpm run test:e2e:primary --project=${{ matrix.project }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
# env:
# DEBUG: pw:api,pw:browser*
- name: 📤 Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: all-blob-reports
path: blob-report
retention-days: 1
merge-e2e-reports:
# Merge reports after playwright-tests, even if some shards have failed
name: 🔄 Merge Playwright Reports
needs: [versions, test-e2e]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: ${{ needs.versions.outputs.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ needs.versions.outputs.NODE_VERSION }}
cache: pnpm
- name: 📥 Install dependencies
run: pnpm install
- name: 📥 Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: all-blob-reports
- name: 🔄 Merge all blob reports
env:
PLAYWRIGHT_JSON_OUTPUT_NAME: e2e-results.json
run: pnpm exec playwright merge-reports --reporter html,json,github,markdown ./all-blob-reports
- name: 🛠️ Generate PR Comment
uses: daun/playwright-report-summary@v3
with:
report-file: 'e2e-results.json'
- name: 🛠️ Generate Job Summary
run: |
echo "# 🧪 E2E Summary 🧪" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat report.md >> $GITHUB_STEP_SUMMARY # report.md is generated from markdown reporter
- name: 📤 Upload HTML report
uses: actions/upload-artifact@v3
with:
name: e2e-report-${{ github.run_id }}-attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 7