forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
664 lines (543 loc) · 20.1 KB
/
ci.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
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
name: Qwik CI
on:
pull_request:
push:
branches:
- main
- next
workflow_dispatch:
inputs:
disttag:
description: 'Publish "@builder.io/qwik" to NPM using this dist-tag, push the git-tag to the repo and create a GitHub release. The "latest" and "next" dist-tags will use the version number already committed in package.json.'
required: true
type: choice
default: 'dev'
options:
- dev
- next
- latest
env:
# Disable incremental build, speeds up CI
CARGO_INCREMENTAL: 0
jobs:
changes:
name: Setup
runs-on: ubuntu-latest
outputs:
fullbuild: ${{ steps.filter.outputs.fullbuild == 'true' || github.event.inputs.disttag != '' }}
steps:
- name: Branch
run: echo "${{ github.ref }}"
- name: NPM Dist Tag
run: echo "${{ github.event.inputs.disttag }}"
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
fullbuild:
- 'packages/qwik/src/**/*.ts'
- 'packages/qwik/src/**/*.tsx'
- 'packages/qwik/src/**/*.rs'
- 'packages/qwik-city/**/*.ts'
- 'packages/qwik-city/**/*.tsx'
- 'packages/eslint-plugin-qwik/**/*.ts'
- 'starters/apps/**/*.ts'
- 'starters/apps/**/*.tsx'
- 'starters/e2e/**/*.ts'
- 'tsconfig.json'
- 'pnpm-lock.yaml'
- 'Cargo.yaml'
- '.github/workflows/*.yaml'
- 'scripts/*.ts'
- name: Print fullbuild output
run: echo ${{ steps.filter.outputs.fullbuild == 'true' || github.event.inputs.disttag != '' }}
############ BUILD PACKAGE ############
build-package:
name: Build Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/[email protected]
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: pnpm install --frozen-lockfile
- name: Build Package
run: pnpm tsm scripts/index.ts --tsc --build --cli --api --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: Print Qwik Dist Build
run: tree packages/qwik/dist/
- name: Upload Qwik Build Artifacts
uses: actions/upload-artifact@master
with:
name: dist-dev-builder-io-qwik
path: packages/qwik/dist/
if-no-files-found: error
- name: Print Create Qwik CLI Dist Build
run: tree packages/create-qwik/dist/
- name: Upload Create Qwik CLI Build Artifacts
uses: actions/upload-artifact@master
with:
name: dist-dev-create-qwik
path: packages/create-qwik/dist/
if-no-files-found: error
- name: Build Eslint rules
run: pnpm tsm scripts/index.ts --eslint
- name: Print Eslint rules Dist Build
run: tree packages/eslint-plugin-qwik/dist/
- name: Upload Eslint rules Build Artifacts
uses: actions/upload-artifact@master
with:
name: dist-dev-eslint-plugin-qwik
path: packages/eslint-plugin-qwik/dist/
if-no-files-found: error
############ BUILD WASM ############
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
needs: changes
steps:
- name: Print fullbuild output
run: echo ${{ needs.changes.outputs.fullbuild }}
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/checkout@v3
- uses: pnpm/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
- name: Cache cargo dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-deps-wasm-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache cargo build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: packages/qwik/src/wasm/target
key: cargo-build-wasm-${{ runner.os }}-${{ hashFiles('./packages/qwik/src/wasm/Cargo.lock') }}
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm install --frozen-lockfile
- uses: jetli/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 'v0.10.3'
- name: Build WASM
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --wasm --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: Print WASM Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik/dist/bindings/
- name: Upload WASM Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/upload-artifact@master
with:
name: dist-bindings-wasm
path: packages/qwik/dist/bindings/*
if-no-files-found: error
############ BUILD PLATFORM BINDINGS ############
build-bindings:
strategy:
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: pnpm tsm scripts/index.ts --platform-binding
- host: macos-latest
target: aarch64-apple-darwin
build: |
export SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)
export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)
pnpm tsm scripts/index.ts --platform-binding --platform-target=aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
build: pnpm tsm scripts/index.ts --platform-binding
name: Build ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
needs: changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/checkout@v3
- uses: pnpm/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
shell: bash
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.settings.target }}
- name: Pull Latest Image
if: ${{ needs.changes.outputs.fullbuild == 'true' && matrix.settings.docker }}
run: ${{ matrix.settings.docker }}
env:
DOCKER_REGISTRY_URL: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Cache cargo dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-deps-${{ matrix.settings.target }}-${{ hashFiles('Cargo.lock') }}
- name: Cache cargo build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: target
key: cargo-build-${{ matrix.settings.target }}-${{ hashFiles('Cargo.lock') }}
- name: Setup Toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' && matrix.settings.setup }}
run: ${{ matrix.settings.setup }}
shell: bash
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm install --frozen-lockfile
- name: Build Platform Binding
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload Platform Binding Artifact
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/upload-artifact@v2
with:
name: dist-bindings-${{ matrix.settings.target }}
path: packages/qwik/dist/bindings/*.node
if-no-files-found: error
############ BUILD DISTRIBUTION ############
build-distribution:
name: Build Distribution
runs-on: ubuntu-latest
needs:
- build-package
- build-wasm
- build-bindings
- test-unit
- validate-rust
- changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/checkout@v3
- uses: pnpm/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm install --frozen-lockfile
- name: Create packages/qwik/dist/ directory
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
mkdir -p packages/qwik/dist/bindings/
- name: Download Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/download-artifact@v2
- name: Print Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree dist-dev-builder-io-qwik/
- name: Move Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: mv dist-dev-builder-io-qwik/* packages/qwik/dist/
- name: Print Bindings Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree dist-bindings-*/
- name: Move Binding Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: mv dist-bindings-*/* packages/qwik/dist/bindings/
- name: Print Packages Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik/dist/
- name: Upload Qwik Distribution Artifact
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/upload-artifact@master
with:
name: builderio-qwik-distribution
path: packages/qwik/dist/*
if-no-files-found: error
- name: Build QwikCity
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --tsc --qwikcity --api
- name: Print QwikCity Lib Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik-city/lib/
- name: Upload QwikCity Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/upload-artifact@master
with:
name: builderio-qwikcity-distribution
path: packages/qwik-city/lib/
if-no-files-found: error
- name: Commit Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' && github.event_name == 'push' }}
env:
QWIK_API_TOKEN_GITHUB: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
run: pnpm run qwik-save-artifacts
############ RELEASE ############
release:
name: Release
runs-on: ubuntu-latest
needs:
- build-distribution
- test-e2e
- changes
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/[email protected]
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Download Build Artifacts
uses: actions/download-artifact@v2
- name: Print Distribution Artifacts
run: tree builderio-qwik-distribution/
- name: Print Create Qwik CLI Artifacts
run: tree dist-dev-create-qwik/
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv builderio-qwik-distribution/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv builderio-qwikcity-distribution/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-dev-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-dev-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
- name: Install NPM Dependencies
run: pnpm install --frozen-lockfile
- name: Dry-Run Publish @builder.io/qwik
if: ${{ github.event_name != 'workflow_dispatch' }}
run: pnpm tsm scripts/index.ts --set-dist-tag="${{ github.event.inputs.disttag }}" --release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @builder.io/qwik
if: ${{ github.event_name == 'workflow_dispatch' }}
run: pnpm tsm scripts/index.ts --set-dist-tag="${{ github.event.inputs.disttag }}" --release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
############ TRIGGER QWIKCITY E2E Test ############
trigger-qwikcity-e2e:
name: Trigger Qwik City E2E
runs-on: ubuntu-latest
needs:
- release
if: ${{ needs.changes.outputs.fullbuild == 'true' && github.ref_name == 'main' }}
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
repository: builderIO/qwik-city-e2e
event-type: main-updated
############ E2E TEST ############
test-e2e:
name: E2E Tests
needs:
- build-distribution
- changes
strategy:
matrix:
settings:
- host: ubuntu-latest
browser: chromium
node: 16.x
- host: macos-latest
browser: webkit
node: 16.x
runs-on: ${{ matrix.settings.host }}
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/checkout@v3
- uses: pnpm/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node ${{ matrix.settings.node }}
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.settings.node }}
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
shell: bash
- name: Download Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/download-artifact@v2
- name: Move Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
mkdir -p packages/qwik/dist/
mv builderio-qwik-distribution/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv builderio-qwikcity-distribution/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-dev-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-dev-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm install --frozen-lockfile
- name: Install Playwright
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: npx playwright install ${{ matrix.settings.browser }} --with-deps
- name: Playwright E2E Tests
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm run test.e2e.${{ matrix.settings.browser }}
- name: Validate Create Qwik Cli
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm cli.validate
############ UNIT TEST ############
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
needs:
- changes
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/[email protected]
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: pnpm install --frozen-lockfile
- name: Unit Tests
run: pnpm run test.unit
########### VALIDATE RUST ############
validate-rust:
name: Validate Rust
runs-on: ubuntu-latest
needs: changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/checkout@v3
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt, clippy
- name: Cache cargo dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache cargo build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v3
with:
path: target
key: cargo-build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Format check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Build check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
- name: Clippy check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features
- name: Unit tests
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
########### LINT PACKAGE ############
lint-package:
name: Lint Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/[email protected]
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: pnpm install --frozen-lockfile
- name: Prettier Check
if: ${{ always() }}
run: pnpm run lint.prettier
- name: ESLint Check
if: ${{ always() }}
run: pnpm run lint.eslint