-
Notifications
You must be signed in to change notification settings - Fork 140
220 lines (218 loc) · 8.11 KB
/
test.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
name: Run test suites
run-name: >-
${{ (github.event.inputs.runId && format('Run test suites - run id {0}', github.event.inputs.runId))
|| (github.event.inputs.linuxBuildFile && format('Run test suites - linux build {0}', github.event.inputs.linuxBuildFile))
|| '' }}
on:
pull_request:
workflow_dispatch:
inputs:
linuxBuildFile:
description: "Linux Chromium Build File (.tar.xz)"
runId:
description: "Test Run ID, chosen by workflow dispatcher, to make it possible to find the correct run from the api"
push:
branches:
- main
env:
RECORD_REPLAY_API_KEY: rwk_yaEG8jo6gcisGHHoMj8SNoOMIHSbT7REuU5E1QnKCiL
RECORD_REPLAY_METADATA_TEST_RUN_TITLE: E2E Tests
RECORD_REPLAY_DISABLE_FEATURES: '["no-dependency-graph"]'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
download-browser:
name: Download Replay browser
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Download
run: wget https://static.replay.io/downloads/macOS-replay-playwright.tar.xz
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: macOS-replay-playwright
path: macOS-replay-playwright.tar.xz
preview-branch:
name: Wait for Vercel Preview Branch
runs-on: ubuntu-latest
steps:
- name: Waiting for 200 from the Vercel Preview
uses: patrickedqvist/wait-for-vercel-preview@v1.3.1
id: waitFor200
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 960
check_interval: 60
environment: ${{ fromJSON('["", "production"]')[github.ref == 'refs/heads/main'] }}
outputs:
url: ${{ steps.waitFor200.outputs.url }}
generate-test-run-id:
name: Generate Test Run ID
runs-on: ubuntu-latest
steps:
- run: yarn add uuid
shell: sh
- uses: actions/github-script@v6
id: uuid
with:
result-encoding: string
script: return require("uuid").v4()
outputs:
testRunId: ${{ steps.uuid.outputs.result }}
e2etest:
name: End-to-end tests (${{ matrix.shard }})
runs-on: ubuntu-latest
needs: [preview-branch, generate-test-run-id]
strategy:
# GH cancels other matrixed jobs by default if one fails. We want all E2E jobs to complete.
fail-fast: false
matrix:
shard: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "16"
# Get the yarn cache path.
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "{dir}={$(yarn config get cacheFolder)}" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
restore-keys: "yarn-cache-folder-"
# Actually install packages with Yarn
- name: Install packages
run: yarn install
env:
YARN_CHECKSUM_BEHAVIOR: "update"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- name: Install Replay Chromium
run: npx replayio install
env:
RECORD_REPLAY_CHROMIUM_DOWNLOAD_FILE: ${{ github.event.inputs.linuxBuildFile }}
- name: Run Playwright
run: npx playwright test --shard ${{ matrix.shard }}/10 tests/*.ts --project replay-chromium
working-directory: ./packages/e2e-tests
env:
RECORD_REPLAY_TEST_RUN_ID: ${{ needs.generate-test-run-id.outputs.testRunId }}
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.preview-branch.outputs.url }}
INPUT_STRIPE: ${{ matrix.shard }}/10
SHARD_NUMBER: ${{ matrix.shard }}
RECORD_REPLAY_WEBHOOK_URL: ${{ secrets.RECORD_REPLAY_WEBHOOK_URL }}
RECORD_REPLAY_TEST_METRICS: 1
AUTOMATED_TEST_SECRET: ${{ secrets.AUTOMATED_TEST_SECRET }}
AUTHENTICATED_TESTS_WORKSPACE_API_KEY: ${{ secrets.AUTHENTICATED_TESTS_WORKSPACE_API_KEY }}
GOLDEN_TEST_RUN_WORKSPACE_API_KEY: ${{ secrets.GOLDEN_TEST_RUN_WORKSPACE_API_KEY }}
- name: Archive Playwright report results with code coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: all-code-coverage-reports_${{ matrix.shard }}
path: packages/e2e-tests/test-results
retention-days: 3
- uses: replayio/action-upload@v0.5.1
if: always()
with:
api-key: ${{ env.RECORD_REPLAY_API_KEY }}
public: true
authenticated-e2etest:
name: Authenticated end-to-end tests (${{ matrix.shard }})
runs-on: ubuntu-latest
needs: [preview-branch, generate-test-run-id]
strategy:
# GH cancels other matrixed jobs by default if one fails. We want all E2E jobs to complete.
fail-fast: false
matrix:
shard: ["1"]
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "16"
# Get the yarn cache path.
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "{dir}={$(yarn config get cacheFolder)}" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
restore-keys: "yarn-cache-folder-"
# Actually install packages with Yarn
- name: Install packages
run: yarn install
env:
YARN_CHECKSUM_BEHAVIOR: "update"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- name: Install Replay Chromium
run: npx replayio install
- name: Run Playwright
run: npx playwright test --shard ${{ matrix.shard }}/1 authenticated/ test-suite-dashboard/ --project replay-chromium
working-directory: ./packages/e2e-tests
env:
RECORD_REPLAY_TEST_RUN_ID: ${{ needs.generate-test-run-id.outputs.testRunId }}
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.preview-branch.outputs.url }}
INPUT_STRIPE: ${{ matrix.shard }}/1
RECORD_REPLAY_WEBHOOK_URL: ${{ secrets.RECORD_REPLAY_WEBHOOK_URL }}
RECORD_REPLAY_TEST_METRICS: 1
AUTOMATED_TEST_SECRET: ${{ secrets.AUTOMATED_TEST_SECRET }}
AUTHENTICATED_TESTS_WORKSPACE_API_KEY: ${{ secrets.AUTHENTICATED_TESTS_WORKSPACE_API_KEY }}
GOLDEN_TEST_RUN_WORKSPACE_API_KEY: ${{ secrets.GOLDEN_TEST_RUN_WORKSPACE_API_KEY }}
- name: Archive Playwright report results with code coverage
uses: actions/upload-artifact@v4
if: always()
with:
name: all-code-coverage-reports_auth
path: packages/e2e-tests/test-results
retention-days: 3
- uses: replayio/action-upload@v0.5.1
if: always()
with:
api-key: ${{ env.RECORD_REPLAY_API_KEY }}
public: true
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "16"
# Get the yarn cache path.
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "{dir}={$(yarn config get cacheFolder)}" >> $GITHUB_OUTPUT
- name: Restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }}
restore-keys: "yarn-cache-folder-"
# Actually install packages with Yarn
- name: Install packages
run: yarn install
env:
YARN_CHECKSUM_BEHAVIOR: "update"
- name: Run tests
run: yarn test