-
Notifications
You must be signed in to change notification settings - Fork 274
397 lines (382 loc) · 15.4 KB
/
Copy pathtests-pr.yml
File metadata and controls
397 lines (382 loc) · 15.4 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: PR
on:
pull_request:
merge_group:
concurrency:
group: shopify-cli-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DEBUG: '1'
SHOPIFY_CLI_ENV: development
SHOPIFY_CONFIG: debug
PNPM_VERSION: '10.11.1'
BUNDLE_WITHOUT: 'test:development'
GH_TOKEN: ${{ secrets.SHOPIFY_GH_READ_CONTENT_TOKEN }}
GH_TOKEN_SHOP: ${{ secrets.SHOP_GH_READ_CONTENT_TOKEN }}
DEFAULT_NODE_VERSION: '26.1.0'
PLAYWRIGHT_NODE_VERSION: '24.1.0'
jobs:
type-check:
name: 'Type check'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Type check
run: pnpm nx run-many --all --target=type-check --output-style=stream
lint:
name: 'Lint'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Lint
run: pnpm nx run-many --all --target=lint --output-style=stream
bundle:
name: 'Bundle'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: 'Build'
run: pnpm nx run-many --all --target=build --output-style=stream
- name: 'Bundle'
run: pnpm nx run-many --all --target=bundle --output-style=stream
knip:
name: 'Knip (unused code check)'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Run knip
run: node bin/run-knip-ci.js
graphql-schema:
# Skip on dependabot PRs (no access to required secrets) and on PRs opened
# from forks (also no access to secrets), but always run on merge_group
# events since merge queue runs from the base repo.
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' && (github.event_name == 'merge_group' || github.event.pull_request.head.repo.full_name == github.repository) }}
name: 'Check graphql-codegen has been run'
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Get schemas for codegen
run: pnpm graphql-codegen:get-graphql-schemas
- name: Run graphql-codegen
run: pnpm graphql-codegen
- name: Run git diff
run: git diff
- name: Fail if any changes were made
run: 'test -z "$(git status --porcelain)" || { echo -e "Run pnpm graphql-codegen when queries are changed, committing any fixes and generated files" ; exit 1; }'
oclif-checks:
name: 'Check OCLIF manifests & readme & docs'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Build
run: pnpm build --output-style=stream
- name: Refresh manifests
run: pnpm refresh-manifests
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "**/oclif.manifest.json" )" || { echo -e "Run pnpm refresh-manifests before pushing new commands or flags. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Refresh readme
run: pnpm refresh-readme
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "packages/cli/README.md" )" || { echo -e "Run pnpm refresh-readme before pushing new commands or flags. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Refresh code documentation
run: pnpm refresh-code-documentation
- name: Check if there are changes
run: 'test -z "$(git status --porcelain)" || { echo -e "Run pnpm refresh-code-documentation when you update functions with autogenerated examples. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Build shopify.dev docs
run: pnpm build-dev-docs
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "docs-shopify.dev/generated/*.json" )" || { echo -e "Run (pnpm build-dev-docs) before pushing new commands or flags." ; exit 1; }'
unit-tests:
name: "Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}${{ matrix.shard != '' && format(' (shard {0})', matrix.shard) || '' }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
node: [ '22.12.0', '24.1.0', '26.1.0' ]
shard: [ '' ]
include:
# Add sharding for Windows jobs to reduce wall-clock time
- os: windows-latest
node: '22.12.0'
shard: '1/2'
- os: windows-latest
node: '22.12.0'
shard: '2/2'
- os: windows-latest
node: '24.1.0'
shard: '1/2'
- os: windows-latest
node: '24.1.0'
shard: '2/2'
- os: windows-latest
node: '26.1.0'
shard: '1/2'
- os: windows-latest
node: '26.1.0'
shard: '2/2'
exclude:
# Exclude the non-sharded Windows entries (replaced by sharded ones above)
- os: windows-latest
node: '22.12.0'
shard: ''
- os: windows-latest
node: '24.1.0'
shard: ''
- os: windows-latest
node: '26.1.0'
shard: ''
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ matrix.node }}
- name: Unit tests
run: pnpm vitest run ${{ env.POOL_OPTIONS }} ${{ env.SHARD_OPTIONS }}
env:
POOL_OPTIONS: ${{ matrix.os == 'macos-latest' && '--pool forks' || '' }}
SHARD_OPTIONS: ${{ matrix.shard && format('--shard {0}', matrix.shard) || '' }}
VITEST_MIN_THREADS: "1"
VITEST_MAX_THREADS: "4"
unit-tests-gate:
name: "Unit tests"
needs: unit-tests
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Verify all unit tests passed
if: needs.unit-tests.result != 'success'
run: exit 1
e2e-tests:
name: "E2E tests (shard ${{ matrix.shard }})"
if: github.event_name == 'merge_group' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 20
continue-on-error: true
strategy:
fail-fast: false
matrix:
shard: ['1/2', '2/2']
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.PLAYWRIGHT_NODE_VERSION }}
- name: Build
run: pnpm nx run-many --all --target=build --output-style=stream
- name: Install Playwright Chromium
run: pnpm exec playwright install chromium
working-directory: packages/e2e
- name: Rebuild node-pty
run: pnpm rebuild node-pty
- name: Run E2E tests
working-directory: packages/e2e
env:
E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }}
E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }}
E2E_STORE_FQDN: ${{ secrets.E2E_STORE_FQDN }}
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }}
run: pnpm exec playwright test --shard ${{ matrix.shard }}
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ strategy.job-index }}
# Playwright traces contain request headers and must not expose E2E_LOADTEST_HEADER.
path: |
packages/e2e/playwright-report/
!packages/e2e/playwright-report/**/*.zip
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-results-${{ strategy.job-index }}
path: |
packages/e2e/test-results/
!packages/e2e/test-results/**/trace.zip
retention-days: 14
e2e-cleanup:
name: 'Cleanup current-run E2E resources'
needs: e2e-tests
if: ${{ always() && needs.e2e-tests.result != 'skipped' }}
runs-on: ubuntu-latest
timeout-minutes: 20
continue-on-error: true
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.PLAYWRIGHT_NODE_VERSION }}
- name: Install Playwright Chromium
run: pnpm exec playwright install chromium
working-directory: packages/e2e
- name: Build CLI for cleanup auth
run: pnpm nx run cli:build
- name: Prime cleanup auth state
continue-on-error: true
env:
E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }}
E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }}
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }}
run: pnpm --filter e2e exec tsx scripts/prime-browser-auth.ts
- name: Cleanup current-run E2E apps
if: ${{ always() }}
continue-on-error: true
env:
E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }}
E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }}
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }}
run: |
RUN_TOKEN=$(node -e "process.stdout.write(BigInt(process.env.GITHUB_RUN_ID).toString(36))")
pnpm --filter e2e exec tsx scripts/cleanup-apps.ts --pattern "r${RUN_TOKEN}"
- name: Cleanup current-run E2E stores
if: ${{ always() }}
continue-on-error: true
env:
E2E_ACCOUNT_EMAIL: ${{ secrets.E2E_ACCOUNT_EMAIL }}
E2E_ACCOUNT_PASSWORD: ${{ secrets.E2E_ACCOUNT_PASSWORD }}
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
E2E_LOADTEST_HEADER: ${{ secrets.E2E_LOADTEST_HEADER }}
run: |
RUN_TOKEN=$(node -e "process.stdout.write(BigInt(process.env.GITHUB_RUN_ID).toString(36))")
pnpm --filter e2e exec tsx scripts/cleanup-stores.ts --pattern "r${RUN_TOKEN}"
type-diff:
if: github.event.pull_request.head.repo.full_name == github.repository
name: 'Type-diff'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
name: Checkout [main]
with:
fetch-depth: 1
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Build
run: pnpm nx run-many --all --target=build --output-style=stream
- name: Type-diff
working-directory: workspace
id: type-diff
run: pnpm nx run type-diff
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
if: steps.type-diff.outputs.report != ''
with:
header: Type-diff
message: ${{ steps.type-diff.outputs.report }}
recreate: true
major-change-check:
if: github.event.pull_request.head.repo.full_name == github.repository
name: 'Breaking change detection'
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
has_breaking_changes: ${{ steps.check.outputs.has_breaking_changes }}
steps:
- uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
# Full history so `git merge-base origin/<base> HEAD` (used by
# major-change-check.js) can reach the divergence point.
fetch-depth: 0
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Build
run: pnpm nx run-many --all --target=build --output-style=stream
- name: Check for breaking changes
id: check
run: node workspace/src/major-change-check.js
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
if: steps.check.outputs.has_breaking_changes == 'true'
with:
header: Breaking-change-detection
message: ${{ steps.check.outputs.report }}
recreate: true
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
if: steps.check.outputs.has_breaking_changes != 'true'
with:
header: Breaking-change-detection
delete: true
- name: Fail if breaking changes detected
if: steps.check.outputs.has_breaking_changes == 'true'
run: |
echo '::error::Breaking changes detected. See the sticky comment on the PR for details.'
exit 1