-
Notifications
You must be signed in to change notification settings - Fork 453
328 lines (291 loc) · 11.9 KB
/
Copy pathorgBrowserE2E.yml
File metadata and controls
328 lines (291 loc) · 11.9 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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: OrgBrowser E2E (Playwright)
on:
workflow_dispatch:
inputs:
vscode_version:
description: 'VS Code version for E2E (e.g. 1.116.0). Empty uses repo variable
PLAYWRIGHT_VSCODE_VERSION.'
required: false
type: string
default: ''
workflow_call:
inputs:
vscode_version:
description: 'VS Code version for E2E (e.g. 1.116.0). Empty uses repo variable
PLAYWRIGHT_VSCODE_VERSION.'
required: false
type: string
default: ''
push:
branches-ignore: [ main, develop ]
paths-ignore:
- '.claude/**'
- '.cursor/**'
- 'contributing/**'
- 'CONTRIBUTING.md'
- 'docs/**'
- '**/README*'
- 'SECURITY*'
- 'CODE_OF_CONDUCT*'
- 'CHANGELOG*'
- '**/CHANGELOG*'
concurrency:
group: ci-${{ github.ref }}-orgBrowserE2E
cancel-in-progress: true
jobs:
e2e-web:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
SFDX_AUTH_URL: ${{ secrets.SFDX_AUTH_URL_E2E }}
# sf CLI hides authFields from `sf org create scratch --json` output by default; tests need them.
SF_TEMP_SHOW_SECRETS: true
PLAYWRIGHT_VSCODE_VERSION: ${{ github.event_name != 'push' &&
inputs.vscode_version != '' && inputs.vscode_version ||
vars.PLAYWRIGHT_VSCODE_VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.22.3'
cache: 'npm'
- uses: google/wireit@setup-github-actions-caching/v2
- name: Install dependencies
uses: salesforcecli/github-workflows/.github/actions/npmInstallWithRetries@main
# Try E2E tests first. When wireit cache hits, it skips the command and exits 0—we never need CLI, orgs, or Playwright.
# When cache misses, tests fail on missing org/chromium. E2E_NO_RETRIES=1 disables Playwright retries in config
# so failures are fast (env var doesn't affect wireit cache key since it's not part of the npm command).
- name: Try E2E tests
id: try-run
continue-on-error: true
timeout-minutes: 5
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
E2E_NO_RETRIES: 1
run: |
npm run test:web -w salesforcedx-vscode-org-browser -- --reporter=html
# Only run expensive setup when try-run failed (cache miss). On cache hit we never reach these steps.
- uses: ./.github/actions/cache-vscode-web
if: steps.try-run.outcome == 'failure'
with:
vscode-version: ${{ env.PLAYWRIGHT_VSCODE_VERSION }}
- name: Install Salesforce CLI
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: npm i -g @salesforce/cli
retry_wait_seconds: 30
- name: Clone dreamhouse
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: git clone --depth=1 https://github.com/trailheadapps/dreamhouse-lwc
dreamhouse-lwc
retry_wait_seconds: 60
- name: Auth to dev hub (global)
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: bash -c 'echo "$SFDX_AUTH_URL" | sf org login sfdx-url
--set-default-dev-hub --alias hub --sfdx-url-stdin'
retry_wait_seconds: 30
- name: Install Playwright browsers and OS deps
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: npx playwright install chromium --with-deps
retry_wait_seconds: 60
- name: create scratch org and set up dreamhouse
if: steps.try-run.outcome == 'failure'
# the tests expect a scratch org with dreamhouse at a certain alias but don't use the directory directly
shell: bash
run: |
sf org create scratch -y 1 -d -f config/project-scratch-def.json -a "$DREAMHOUSE_ORG_ALIAS" --json --wait 30
sf project deploy start
sf org assign permset -n dreamhouse
working-directory: dreamhouse-lwc
- name: Run Org Browser E2E tests (parallel)
if: steps.try-run.outcome == 'failure'
id: parallel-run
continue-on-error: true
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
run: |
npm run test:web -w salesforcedx-vscode-org-browser -- --reporter=html
- name: Retry failed tests (sequential)
if: steps.try-run.outcome == 'failure' && steps.parallel-run.outcome ==
'failure'
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
PLAYWRIGHT_WORKERS: 1
run: |
npm run test:web -w salesforcedx-vscode-org-browser -- --last-failed --reporter=html
- name: Copy span files to test-results
if: always()
shell: bash
run: |
mkdir -p packages/salesforcedx-vscode-org-browser/test-results/spans
cp -r ~/.sf/vscode-spans/. packages/salesforcedx-vscode-org-browser/test-results/spans/ 2>/dev/null || true
- name: Upload Playwright HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: packages/salesforcedx-vscode-org-browser/playwright-report
if-no-files-found: ignore
- name: Cleanup scratch org
if: always() && steps.try-run.outcome == 'failure'
continue-on-error: true
run: |
sf org delete scratch -o "$DREAMHOUSE_ORG_ALIAS" --no-prompt || true
e2e-desktop:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
include:
- os: ubuntu-latest
test_runner_prefix: 'xvfb-run -a '
fail-fast: false
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
SFDX_AUTH_URL: ${{ secrets.SFDX_AUTH_URL_E2E }}
# sf CLI hides authFields from `sf org create scratch --json` output by default; tests need them.
SF_TEMP_SHOW_SECRETS: true
PLAYWRIGHT_VSCODE_VERSION: ${{ github.event_name != 'push' &&
inputs.vscode_version != '' && inputs.vscode_version ||
vars.PLAYWRIGHT_VSCODE_VERSION }}
E2E_FROM_VSIX: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Log desktop VS Code version
shell: bash
run: echo "::notice::VS Code version=${PLAYWRIGHT_VSCODE_VERSION}"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.22.3'
cache: 'npm'
- uses: google/wireit@setup-github-actions-caching/v2
- name: Install dependencies
uses: salesforcecli/github-workflows/.github/actions/npmInstallWithRetries@main
# Try E2E tests first. When wireit cache hits, it skips the command and exits 0—we never need CLI, orgs, or Playwright.
# When cache misses, tests fail on missing org. E2E_NO_RETRIES=1 disables Playwright retries in config
# so failures are fast (env var doesn't affect wireit cache key since it's not part of the npm command).
- name: Try E2E tests
id: try-run
continue-on-error: true
timeout-minutes: 5
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
VSCODE_DESKTOP: 1
E2E_NO_RETRIES: 1
run: ${{ matrix.test_runner_prefix }}npm run test:desktop -w
salesforcedx-vscode-org-browser -- --reporter=html
# Only run expensive setup when try-run failed (cache miss). On cache hit we never reach these steps.
- uses: ./.github/actions/cache-vscode-desktop
if: steps.try-run.outcome == 'failure'
with:
vscode-version: ${{ env.PLAYWRIGHT_VSCODE_VERSION }}
- name: Install Salesforce CLI
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: npm i -g @salesforce/cli
retry_wait_seconds: 30
- name: Install Playwright browsers and OS deps
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: npx playwright install chromium --with-deps
retry_wait_seconds: 60
- name: Clone dreamhouse
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: git clone --depth=1 https://github.com/trailheadapps/dreamhouse-lwc
dreamhouse-lwc
retry_wait_seconds: 60
- name: Auth to dev hub (global)
if: steps.try-run.outcome == 'failure'
uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 3
command: bash -c 'echo "$SFDX_AUTH_URL" | sf org login sfdx-url
--set-default-dev-hub --alias hub --sfdx-url-stdin'
retry_wait_seconds: 30
- name: create scratch org and set up dreamhouse
if: steps.try-run.outcome == 'failure'
# the tests expect a scratch org with dreamhouse at a certain alias but don't use the directory directly
shell: bash
run: |
sf org create scratch -y 1 -d -f config/project-scratch-def.json -a "$DREAMHOUSE_ORG_ALIAS" --json --wait 30
sf project deploy start
sf org assign permset -n dreamhouse
working-directory: dreamhouse-lwc
- name: Run Org Browser E2E tests (parallel)
if: steps.try-run.outcome == 'failure'
id: parallel-run
continue-on-error: true
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
VSCODE_DESKTOP: 1
run: ${{ matrix.test_runner_prefix }}npm run test:desktop -w
salesforcedx-vscode-org-browser -- --reporter=html
- name: Retry failed tests (sequential)
if: steps.try-run.outcome == 'failure' && steps.parallel-run.outcome ==
'failure'
env:
DREAMHOUSE_ORG_ALIAS: orgBrowserDreamhouseTestOrg
CI: 1
VSCODE_DESKTOP: 1
PLAYWRIGHT_WORKERS: 1
run: ${{ matrix.test_runner_prefix }}npm run test:desktop -w
salesforcedx-vscode-org-browser -- --last-failed --reporter=html
- name: Copy span files to test-results
if: always()
shell: bash
run: |
mkdir -p packages/salesforcedx-vscode-org-browser/test-results/spans
cp -r ~/.sf/vscode-spans/. packages/salesforcedx-vscode-org-browser/test-results/spans/ 2>/dev/null || true
- name: Upload Playwright HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-desktop-${{ matrix.os }}
path: packages/salesforcedx-vscode-org-browser/playwright-report
if-no-files-found: ignore
- name: Upload Playwright Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-test-results-desktop-${{ matrix.os }}
path: packages/salesforcedx-vscode-org-browser/test-results
if-no-files-found: ignore
- name: Cleanup scratch org
if: always() && steps.try-run.outcome == 'failure'
continue-on-error: true
shell: bash
run: |
sf org delete scratch -o "$DREAMHOUSE_ORG_ALIAS" --no-prompt || true