-
Notifications
You must be signed in to change notification settings - Fork 399
530 lines (459 loc) · 19.2 KB
/
ci.yml
File metadata and controls
530 lines (459 loc) · 19.2 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
name: 🚀 CI
on:
pull_request:
push:
branches:
- main
jobs:
check-node-version:
name: 🔧 Node version sync
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Validate .nvmrc matches dev.yml
run: |
NVMRC_VERSION=$(tr -d 'v\n' < .nvmrc)
# Expects dev.yml format:
# - node:
# version: vXX.YY.ZZ
DEV_YML_RAW=$(grep -A3 '^\s*- node:' dev.yml | grep 'version:' | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+' | head -1)
DEV_YML_VERSION=$(echo "$DEV_YML_RAW" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
if [ -z "$NVMRC_VERSION" ]; then
echo "::error::Could not parse version from .nvmrc"
echo " .nvmrc contents: '$(cat .nvmrc)'"
echo " dev.yml raw: '$DEV_YML_RAW'"
exit 1
fi
if [ -z "$DEV_YML_RAW" ]; then
echo "::error::Could not find node version in dev.yml"
echo " .nvmrc version: '$NVMRC_VERSION'"
echo " Searched for: '- node:' followed by 'version:' line in dev.yml"
echo " Relevant dev.yml lines:"
grep -A3 'node:' dev.yml | sed 's/^/ /'
exit 1
fi
if [ -z "$DEV_YML_VERSION" ]; then
echo "::error::dev.yml must specify a FULL Node version (X.Y.Z format)"
echo ""
echo "Found: '$DEV_YML_RAW'"
echo ".nvmrc version: '$NVMRC_VERSION'"
echo "Expected format: 'vX.Y.Z' (e.g., 'v20.19.5')"
echo ""
echo "The Shopify 'dev' tool requires a specific installable version,"
echo "not just a major version like 'v20'. Nix needs the exact version"
echo "to fetch from its package cache."
exit 1
fi
NVMRC_MAJOR=$(echo "$NVMRC_VERSION" | cut -d. -f1)
DEV_YML_MAJOR=$(echo "$DEV_YML_VERSION" | cut -d. -f1)
if [ "$NVMRC_MAJOR" != "$DEV_YML_MAJOR" ]; then
echo "::error::Node version mismatch between .nvmrc and dev.yml"
echo ""
echo "┌─────────────────────────────────────────────────────────────────┐"
echo "│ IMPORTANT: This is NOT a configuration oversight! │"
echo "│ │"
echo "│ The Shopify 'dev' tool CANNOT read from .nvmrc - it requires │"
echo "│ an explicit version. These files serve different tools: │"
echo "│ • .nvmrc → used by nvm (flexible major version like 'v20') │"
echo "│ • dev.yml → used by dev tool (needs exact version 'v20.x.x') │"
echo "│ │"
echo "│ Both files MUST be updated TOGETHER when changing Node version.│"
echo "└─────────────────────────────────────────────────────────────────┘"
echo ""
echo "Current state:"
echo " .nvmrc major version: v$NVMRC_MAJOR"
echo " dev.yml major version: v$DEV_YML_MAJOR"
echo ""
echo "To fix: Update both files to use the same Node major version."
exit 1
fi
echo "✅ Node versions in sync (major version: v$NVMRC_MAJOR)"
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: ci-lint-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
- name: 🔬 Lint
run: pnpm run lint
format:
name: ⬣ Prettier
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: ci-format-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
- name: 🔬 Check Formatting
run: pnpm run format:check
typecheck:
name: Typescript
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: ci-typecheck-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
# Enabling the turbo cache causes deployments to fail intermittently.
# The build step fails with dependency issues. More investigation needed.
# - name: 💾 Turbo cache
# id: turbo-cache
# uses: actions/cache@v3
# with:
# path: |
# node_modules/.cache/turbo
# **/.turbo
# key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
# restore-keys: |
# turbo-${{ github.job }}-${{ github.ref_name }}-
- name: 📦 Build packages and templates
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run build:all
- name: ✅ Typecheck
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run typecheck
- name: 🧑💻 CLI manifest check
run: 'test -z "$(git status --porcelain "packages/cli/oclif.manifest.json" )" || { echo -e "Run pnpm --dir packages/cli run generate:manifest before pushing new commands or flags. Diff here:\n\n$(git diff)" ; exit 1; }'
test_e2e:
name: ⬣ E2E tests
runs-on: ubuntu-latest
timeout-minutes: 20
concurrency:
group: ci-e2e-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
- name: 📦 Build packages and templates
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run build:all
- name: 🎭 Install Playwright Chromium
run: pnpm exec playwright install chromium --with-deps
- name: 🔐 Install ejson
run: |
sudo apt-get update
sudo apt-get install -y golang-go
go install github.com/Shopify/ejson/cmd/ejson@latest
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: 🧪 Run E2E tests
# Customer Account tests are run separately in a different job
# because they require a static redirect URL so we have a different CI
# job to test Customer Account specific features.
# The @customer-account tag is defined in e2e/specs/skeleton/customerAccount.spec.ts
run: pnpm exec playwright test --grep-invert "@customer-account"
env:
EJSON_PRIVATE_KEY: ${{ secrets.EJSON_PRIVATE_KEY }}
- name: 📤 Upload Playwright Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ always() && !cancelled() }}
with:
name: playwright-report
path: playwright-report/
if-no-files-found: warn
retention-days: 30
test_scaffolding:
name: ⬣ Scaffolding tests (${{ matrix.os }} / ${{ matrix.pm }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
concurrency:
group: ci-scaffolding-${{ matrix.os }}-${{ matrix.pm }}-${{ github.ref }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
include:
# Full package manager matrix on Linux
- os: ubuntu-latest
pm: npm
lockfile: package-lock.json
- os: ubuntu-latest
pm: pnpm
lockfile: pnpm-lock.yaml
- os: ubuntu-latest
pm: yarn
lockfile: yarn.lock
# TODO: Re-enable bun once @shopify/cli releases with @shopify/cli-hydrogen that supports bun.lock
# - os: ubuntu-latest
# pm: bun
# lockfile: bun.lock
# setup: npm i -g bun
# Smoke test on macOS (npm only)
- os: macos-latest
pm: npm
lockfile: package-lock.json
# Smoke test on Windows (npm only)
- os: windows-latest
pm: npm
lockfile: package-lock.json
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# Explicit version required because pnpm/action-setup doesn't auto-detect
# from packageManager field in this context. The version must match
# engines.pnpm in package.json (>=10.16.1)
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
version: 10.16.1
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📦 Setup ${{ matrix.pm }}
if: matrix.setup
run: ${{ matrix.setup }}
shell: bash
- name: 📥 Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
- name: 📦 Build packages
run: pnpm run build:pkg
env:
SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK: 'false'
shell: bash
- name: 🧪 Scaffold with ${{ matrix.pm }}
run: |
node packages/create-hydrogen/dist/create-app.js \
--path "${{ runner.temp }}/h2-test-${{ matrix.pm }}" \
--language ts \
--mock-shop \
--install-deps \
--no-git \
--package-manager ${{ matrix.pm }} \
--no-shortcut \
--markets none \
--styling none
shell: bash
- name: ✅ Verify lockfile
run: |
if [ ! -f "${{ runner.temp }}/h2-test-${{ matrix.pm }}/${{ matrix.lockfile }}" ]; then
echo "Error: Lockfile not found at ${{ runner.temp }}/h2-test-${{ matrix.pm }}/${{ matrix.lockfile }}"
exit 1
fi
echo "✓ Lockfile verified: ${{ matrix.lockfile }}"
shell: bash
- name: ✅ Verify app builds
run: |
cd "${{ runner.temp }}/h2-test-${{ matrix.pm }}"
${{ matrix.pm }} run build
shell: bash
test_e2e_customer_account:
name: ⬣ E2E Customer Account tests
runs-on: ubuntu-latest
timeout-minutes: 25
concurrency:
# Serialized because all runs deploy to the same Oxygen storefront URL —
# concurrent deploys would overwrite each other and cause test flakes.
group: oxygen-deploy-customer-account-e2e
cancel-in-progress: false
# Required secrets:
# OXYGEN_DEPLOYMENT_TOKEN_1000108386 — deploy token for the benchmark shop's Oxygen storefront
# EJSON_PRIVATE_KEY — decrypts secrets.ejson to provide customer_account_email and loadtest_header
# These correspond to the benchmark shop (drru00-at.myshopify.com / storefront 1000108386).
# Update both if the test shop changes.
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: pnpm install --frozen-lockfile
- name: 📦 Build packages
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run build:pkg
#! oxygen_storefront_id: 1000108386
- name: 🚀 Deploy skeleton to Oxygen
id: deploy
working-directory: templates/skeleton
run: pnpm exec shopify hydrogen deploy --no-lockfile-check --force --auth-bypass-token --env-file ../../e2e/envs/.env.customerAccount
env:
SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN: ${{ secrets.OXYGEN_DEPLOYMENT_TOKEN_1000108386 }}
- name: 📋 Extract deployment URL
id: deployment_info
working-directory: templates/skeleton
run: |
URL="$(jq -r '.url' h2_deploy_log.json)"
TOKEN="$(jq -r '.authBypassToken // empty' h2_deploy_log.json)"
if [ -z "$URL" ] || [ "$URL" = "null" ]; then
echo "::error::Deployment URL is empty — h2_deploy_log.json may be missing or malformed"
exit 1
fi
if [ -z "$TOKEN" ]; then
echo "::error::Auth bypass token is empty — deploy may not have generated one"
exit 1
fi
echo "::add-mask::$TOKEN"
echo "url=$URL" >> "$GITHUB_OUTPUT"
echo "auth_bypass_token=$TOKEN" >> "$GITHUB_OUTPUT"
- name: 🩺 Wait for deployment to be healthy
env:
DEPLOYMENT_URL: ${{ steps.deployment_info.outputs.url }}
AUTH_BYPASS_TOKEN: ${{ steps.deployment_info.outputs.auth_bypass_token }}
run: |
# Poll the deployment until it returns 200 (not 302 redirect).
# Oxygen deployments can take a few seconds to propagate after
# the deploy command reports success.
MAX_ATTEMPTS=30
POLL_INTERVAL_IN_SECONDS=3
for i in $(seq 1 $MAX_ATTEMPTS); do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-H "oxygen-auth-bypass-token: $AUTH_BYPASS_TOKEN" \
"$DEPLOYMENT_URL")
if [ "$STATUS" = "200" ]; then
echo "Deployment is healthy (HTTP $STATUS) after $((i * POLL_INTERVAL_IN_SECONDS))s"
exit 0
fi
echo "Attempt $i/$MAX_ATTEMPTS: HTTP $STATUS — waiting ${POLL_INTERVAL_IN_SECONDS}s..."
sleep $POLL_INTERVAL_IN_SECONDS
done
echo "::error::Deployment did not become healthy within $((MAX_ATTEMPTS * POLL_INTERVAL_IN_SECONDS))s (last status: $STATUS)"
exit 1
- name: 🎭 Install Playwright Chromium
run: pnpm exec playwright install chromium --with-deps
- name: 🔐 Install ejson
run: |
sudo apt-get update
sudo apt-get install -y golang-go
go install github.com/Shopify/ejson/cmd/ejson@latest
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: 🧪 Run Customer Account E2E tests
run: pnpm exec playwright test --project=skeleton e2e/specs/skeleton/customerAccount.spec.ts
env:
CUSTOMER_ACCOUNT_URL: ${{ steps.deployment_info.outputs.url }}
OXYGEN_AUTH_BYPASS_TOKEN: ${{ steps.deployment_info.outputs.auth_bypass_token }}
EJSON_PRIVATE_KEY: ${{ secrets.EJSON_PRIVATE_KEY }}
- name: 📤 Upload Playwright Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ always() && !cancelled() }}
with:
name: playwright-report-customer-account
path: playwright-report/
if-no-files-found: warn
retention-days: 30
test_unit:
name: ⬣ Unit tests
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: ci-test-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
- name: 📦 Build packages and templates
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run build:all
- name: 🔬 Test
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run test
validate_recipes:
name: ⬣ Validate Recipes
runs-on: ubuntu-latest
timeout-minutes: 15
concurrency:
group: ci-validate-recipes-${{ github.ref }}
cancel-in-progress: true
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 📦 Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320
with:
run_install: false
- name: ⎔ Setup node
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
- name: 📥 Install dependencies
run: |
pnpm install --frozen-lockfile
- name: 📦 Build packages
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run build:pkg
- name: 📝 Validate schema
working-directory: cookbook
run: pnpm run cookbook -- schema && git diff --exit-code recipe.schema.json
- name: 🧐 Validate Recipes
working-directory: cookbook
run: SHOPIFY_HYDROGEN_FLAG_LOCKFILE_CHECK=false pnpm run cookbook -- validate