-
Notifications
You must be signed in to change notification settings - Fork 0
472 lines (401 loc) · 18.5 KB
/
Copy pathdevelopment.yml
File metadata and controls
472 lines (401 loc) · 18.5 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
name: development
on:
push:
branches:
- development
workflow_dispatch:
permissions:
contents: read
concurrency:
group: development-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
environment: development
outputs:
version: ${{ steps.version.outputs.version }}
env:
VIEWER_TEST_ENV: development
steps:
- name: Create GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
client-id: ${{ secrets.BOT_APP_CLIENT_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
persist-credentials: false
token: ${{ steps.app-token.outputs.token }}
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.3.0
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 24.12.0
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Pin npm
run: npm i -g npm@11.6.2
- name: Show tool versions
run: |
node -v
npm -v
pnpm -v
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck workflow scripts
run: npm run check:scripts
- name: Configure git user
shell: bash
run: |
APP_SLUG="${{ steps.app-token.outputs.app-slug }}"
USER_ID="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
git config user.name "${APP_SLUG}[bot]"
git config user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Compute dev version
id: version
shell: bash
run: |
export RELEASE_PRERELEASE_COUNTER="${{ github.run_number }}"
VERSION_JSON=$(npx ts-node -T scripts/release/compute-version.ts --channel dev --yes)
VERSION=$(node -e 'console.log(JSON.parse(process.argv[1]).version)' "$VERSION_JSON")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Computed version: $VERSION"
- name: Notify Slack deployment started
continue-on-error: true
shell: bash
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
WORKFLOW: ${{ github.workflow }}
BRANCH: ${{ github.ref_name }}
SHA: ${{ github.sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if [[ -z "${SLACK_WEBHOOK_URL}" ]]; then
echo "SLACK_WEBHOOK_URL not configured; skipping Slack notification."
exit 0
fi
SHORT_SHA="${SHA:0:7}"
PAYLOAD="$(jq -cn \
--arg workflow "$WORKFLOW" \
--arg version "$VERSION" \
--arg branch "$BRANCH" \
--arg commitUrl "$COMMIT_URL" \
--arg shortSha "$SHORT_SHA" \
--arg runUrl "$RUN_URL" \
'{attachments:[{color:"#1d9bf0",blocks:[{type:"section",text:{type:"mrkdwn",text:":rocket: *Deployment started*"}},{type:"section",fields:[{type:"mrkdwn",text:"*Status:*\nIn progress"},{type:"mrkdwn",text:("*Workflow:*\n" + $workflow)},{type:"mrkdwn",text:("*Version:*\n`" + $version + "`")},{type:"mrkdwn",text:("*Branch:*\n`" + $branch + "`")},{type:"mrkdwn",text:("*Commit:*\n<" + $commitUrl + "|`" + $shortSha + "`>")} ]},{type:"actions",elements:[{type:"button",text:{type:"plain_text",text:"View Run"},url:$runUrl,style:"primary"}]}]}]}')"
curl -sS --max-time 15 -X POST -H "Content-type: application/json" --data "$PAYLOAD" "$SLACK_WEBHOOK_URL" >/dev/null || echo "Slack notification failed."
- name: Version packages
run: npx ts-node -T scripts/release/version-packages.ts --version "${{ steps.version.outputs.version }}" --channel dev --yes
- name: Generate build data
shell: bash
run: |
BUILD_VERSION="${{ steps.version.outputs.version }}" \
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
GITHUB_SHA="$(git rev-parse HEAD)" \
GITHUB_REF_NAME="development" \
npx ts-node -T scripts/release/generate-build-data.ts
- name: Build packages
run: pnpm build
- name: Build test assets
run: pnpm build-tests
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708 # v5.1.1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Deploy test assets to development
run: npm run deploy-tests
env:
VIEWER_TEST_ENV: development
- name: Install Playwright browser
run: npm run test-install
- name: Smoke test deployed development test-cdn
run: npm run test:smoke-cdn
env:
VIEWER_TEST_ENV: development
- name: Collect prepare failure artifacts
if: failure()
shell: bash
run: |
rm -rf .github-artifacts/failure
mkdir -p .github-artifacts/failure/tests
if [[ -f lerna-debug.log ]]; then
cp lerna-debug.log .github-artifacts/failure/
fi
if [[ -d tests/playwright-report ]]; then
cp -R tests/playwright-report .github-artifacts/failure/tests/
fi
if [[ -d tests/test-results ]]; then
cp -R tests/test-results .github-artifacts/failure/tests/
fi
- name: Upload prepare failure artifacts
if: failure()
timeout-minutes: 5
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: development-prepare-failure-artifacts
if-no-files-found: ignore
compression-level: 0
path: .github-artifacts/failure/
playwright:
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: true
matrix:
include:
- shard: 1/4
shard_name: 1-of-4
- shard: 2/4
shard_name: 2-of-4
- shard: 3/4
shard_name: 3-of-4
- shard: 4/4
shard_name: 4-of-4
env:
VIEWER_TEST_ENV: development
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.3.0
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 24.12.0
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Pin npm
run: npm i -g npm@11.6.2
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install Playwright browser
run: npm run test-install
- name: Run sample Playwright shard ${{ matrix.shard }} against development
run: npm run test-samples-only -- --shard=${{ matrix.shard }}
env:
VIEWER_TEST_ENV: development
- name: Collect shard failure artifacts
if: failure()
shell: bash
run: |
rm -rf .github-artifacts/failure
mkdir -p .github-artifacts/failure/tests
if [[ -d tests/playwright-report ]]; then
cp -R tests/playwright-report .github-artifacts/failure/tests/
fi
if [[ -d tests/test-results ]]; then
cp -R tests/test-results .github-artifacts/failure/tests/
fi
- name: Upload shard failure artifacts
if: failure()
timeout-minutes: 5
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: development-playwright-shard-${{ matrix.shard_name }}-failure-artifacts
if-no-files-found: ignore
compression-level: 0
path: .github-artifacts/failure/
finalize:
needs:
- prepare
- playwright
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
VIEWER_TEST_ENV: development
steps:
- name: Create GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
client-id: ${{ secrets.BOT_APP_CLIENT_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
permission-contents: write
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
persist-credentials: false
token: ${{ steps.app-token.outputs.token }}
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5
with:
version: 11.3.0
- name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 24.12.0
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Pin npm
run: npm i -g npm@11.6.2
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Typecheck workflow scripts
run: npm run check:scripts
- name: Configure git user
shell: bash
run: |
APP_SLUG="${{ steps.app-token.outputs.app-slug }}"
USER_ID="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
git config user.name "${APP_SLUG}[bot]"
git config user.email "${USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Version packages
run: npx ts-node -T scripts/release/version-packages.ts --version "${{ needs.prepare.outputs.version }}" --channel dev --yes
- name: Generate build data
shell: bash
run: |
BUILD_VERSION="${{ needs.prepare.outputs.version }}" \
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
GITHUB_SHA="$(git rev-parse HEAD)" \
GITHUB_REF_NAME="development" \
npx ts-node -T scripts/release/generate-build-data.ts
- name: Build packages
run: pnpm build
- name: Commit and push version bump
shell: bash
env:
PUSH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
if [[ -n "$(git status --porcelain)" ]]; then
git add -A
git commit -m "chore(release): bump dev version to ${{ needs.prepare.outputs.version }} [skip ci]"
git push "https://x-access-token:${PUSH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:development
else
echo "No version changes to commit."
fi
- name: Setup Node.js for GitHub Packages publish
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 24.12.0
scope: "@shapediver"
registry-url: https://npm.pkg.github.com
- name: Publish GitHub Packages (dev)
run: npx ts-node -T scripts/publish/publish-github.ts --tag dev --yes
env:
NODE_AUTH_TOKEN: ${{ github.token }}
- name: Collect finalize failure artifacts
if: failure()
shell: bash
run: |
rm -rf .github-artifacts/failure
mkdir -p .github-artifacts/failure/tests
if [[ -f lerna-debug.log ]]; then
cp lerna-debug.log .github-artifacts/failure/
fi
if [[ -d tests/playwright-report ]]; then
cp -R tests/playwright-report .github-artifacts/failure/tests/
fi
if [[ -d tests/test-results ]]; then
cp -R tests/test-results .github-artifacts/failure/tests/
fi
- name: Upload finalize failure artifacts
if: failure()
timeout-minutes: 5
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: development-finalize-failure-artifacts
if-no-files-found: ignore
compression-level: 0
path: .github-artifacts/failure/
notify:
needs:
- prepare
- playwright
- finalize
if: >-
always() &&
(github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]'))
runs-on: ubuntu-latest
permissions:
contents: read
environment: development
steps:
- name: Notify Slack
if: always()
continue-on-error: true
shell: bash
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
PREPARE_RESULT: ${{ needs.prepare.result }}
PLAYWRIGHT_RESULT: ${{ needs.playwright.result }}
FINALIZE_RESULT: ${{ needs.finalize.result }}
WORKFLOW: ${{ github.workflow }}
BRANCH: ${{ github.ref_name }}
SHA: ${{ github.sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
run: |
if [[ -z "${SLACK_WEBHOOK_URL}" ]]; then
echo "SLACK_WEBHOOK_URL not configured; skipping Slack notification."
exit 0
fi
if [[ "${PREPARE_RESULT}" == "success" && "${PLAYWRIGHT_RESULT}" == "success" && "${FINALIZE_RESULT}" == "success" ]]; then
STATUS="success"
elif [[ "${PREPARE_RESULT}" == "cancelled" || "${PLAYWRIGHT_RESULT}" == "cancelled" || "${FINALIZE_RESULT}" == "cancelled" ]]; then
STATUS="cancelled"
else
STATUS="failure"
fi
case "$STATUS" in
success)
COLOR="#36a64f"
EMOJI=":white_check_mark:"
STATUS_LABEL="Succeeded"
;;
failure)
COLOR="#cc0000"
EMOJI=":x:"
STATUS_LABEL="Failed"
;;
cancelled)
COLOR="#808080"
EMOJI=":warning:"
STATUS_LABEL="Cancelled"
;;
*)
COLOR="#808080"
EMOJI=":warning:"
STATUS_LABEL="$STATUS"
;;
esac
SHORT_SHA="${SHA:0:7}"
PAYLOAD="$(jq -cn \
--arg color "$COLOR" \
--arg emoji "$EMOJI" \
--arg statusLabel "$STATUS_LABEL" \
--arg workflow "$WORKFLOW" \
--arg branch "$BRANCH" \
--arg commitUrl "$COMMIT_URL" \
--arg shortSha "$SHORT_SHA" \
--arg runUrl "$RUN_URL" \
'{attachments:[{color:$color,blocks:[{type:"section",text:{type:"mrkdwn",text:($emoji + " *Deployment finished*")}},{type:"section",fields:[{type:"mrkdwn",text:("*Status:*\n" + $statusLabel)},{type:"mrkdwn",text:("*Workflow:*\n" + $workflow)},{type:"mrkdwn",text:("*Branch:*\n`" + $branch + "`")},{type:"mrkdwn",text:("*Commit:*\n<" + $commitUrl + "|`" + $shortSha + "`>")} ]},{type:"actions",elements:[{type:"button",text:{type:"plain_text",text:"View Run"},url:$runUrl}]}]}]}')"
curl -sS --max-time 15 -X POST -H "Content-type: application/json" --data "$PAYLOAD" "$SLACK_WEBHOOK_URL" >/dev/null || echo "Slack notification failed."