-
Notifications
You must be signed in to change notification settings - Fork 15
493 lines (445 loc) · 15.7 KB
/
Copy pathpr-validation.yml
File metadata and controls
493 lines (445 loc) · 15.7 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
name: Pull Request Validation
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
- converted_to_draft
- edited
paths-ignore:
- '**/*.md'
- '**/*.yml'
- '**/*.yaml'
- LICENSE
- '**/*.gitignore'
- .editorconfig
- docs/**
push:
branches:
- develop
schedule:
# Keep develop branch Turbo cache warm so PR runs can restore from it.
- cron: '0 3 * * *'
env:
APP_NAME: 'rs-compiler'
CI: true
TURBO_TELEMETRY_DISABLED: 1
DO_NOT_TRACK: 1
CHECKOUT_REF: >-
${{
github.event_name == 'schedule'
&& 'refs/heads/develop'
|| github.event.pull_request.number != null
&& format('refs/pull/{0}/merge', github.event.pull_request.number)
|| github.ref
}}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
build-public-packages:
name: Build all public packages
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
fetch-tags: false
- name: Setup environment
uses: ./.github/actions/setup
with:
rust-target: 'wasm32-wasip1'
- name: Cache turbo build setup
id: turbo-cache
uses: ./.github/actions/turbo
with:
cache-scope: build-public-packages
restore-cache-scope: build-public-packages
allow-global-fallback: 'false'
- name: Build all public packages
run: pnpm run build --filter "{./packages/*}..." --filter "{./crates/*}..." --continue
- name: Save turbo build cache
if: always()
uses: ./.github/actions/turbo-save
with:
cache-key: ${{ steps.turbo-cache.outputs.cache-key }}
basic-checks:
name: ${{ matrix.check.name }}
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
runs-on: ubuntu-24.04-arm
strategy:
matrix:
check:
- id: conventional-commits
name: Validate conventional commits
command: pnpm exec commitlint --from=$(git merge-base origin/develop HEAD)
- id: version-mismatch
name: Version mismatch check
command: ./scripts/git/version-mismatch-check.sh
- id: format-check
name: Check formatting
command: pnpm run format:check
# Disabled for now; re-enable when we want the dependency graph
# enforced on every PR. `pnpm run deps:check:typescript` still works
# locally in the meantime.
# - id: dependency-graph
# name: Dependency graph guards
# command: |
# pnpm dedupe --check
# pnpm exec syncpack lint
# pnpm run deps:check:typescript
fail-fast: false
steps:
- name: Checkout PR code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
fetch-tags: false
- name: Setup environment
uses: ./.github/actions/setup
with:
setup-rust: ${{ matrix.check.id == 'format-check' }}
- name: ${{ matrix.check.name }}
run: ${{ matrix.check.command }}
checks:
name: ${{ matrix.check.name }}
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
runs-on: ubuntu-24.04-arm
needs:
- build-public-packages
- basic-checks
strategy:
fail-fast: false
matrix:
check:
- id: lint-check
name: Lint Node.js code
command: pnpm run lint:node
- id: lint-type-aware
name: Lint Node.js code (type-aware)
command: pnpm run lint:type-aware
- id: lint-check-rust
name: Lint Rust code
command: pnpm run lint:rust
- id: typecheck
name: Typecheck code
command: pnpm run typecheck
- id: tests-nodejs
name: Tests Node.js
command:
pnpm run test --filter="{./packages/*}" --filter="{./apps/*}"
--filter="@stylexswc/rs-compiler"
- id: tests-rust
name: Tests Rust code
command: pnpm exec turbo run test:crates:workspace:regular --filter="//"
- id: tests-rust-doc
name: Tests Rust doc
command: pnpm exec turbo run test:crates:workspace:doc --filter="//"
- id: tests-coverage
name: Tests Rust coverage
command: pnpm exec turbo run test:coverage:workspace --filter="//"
- id: check-artifacts
name: Check artifacts
command: pnpm run check:artifacts --filter "{./packages/*}" --filter "{./crates/*}"
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
fetch-tags: false
- name: Setup environment
uses: ./.github/actions/setup
with:
rust-target: 'wasm32-wasip1'
- name: Install nightly Rust toolchain
if: matrix.check.id == 'tests-coverage'
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with:
toolchain: nightly
- name: Install cargo-nextest
if: matrix.check.id == 'tests-rust'
uses: taiki-e/install-action@v2.85.5
with:
tool: cargo-nextest
- name: Install cargo-llvm-cov and nightly
if: matrix.check.id == 'tests-coverage'
uses: taiki-e/install-action@v2.85.5
with:
tool: cargo-nextest,cargo-llvm-cov
- name: Cache turbo build setup
id: turbo-cache
uses: ./.github/actions/turbo
with:
cache-scope: checks-${{ matrix.check.id }}
restore-cache-scope: build-public-packages
- name: ${{ matrix.check.name }}
run: ${{ matrix.check.command }}
- name: Save turbo build cache
if: always()
uses: ./.github/actions/turbo-save
with:
cache-key: ${{ steps.turbo-cache.outputs.cache-key }}
playwright-image:
name: Resolve Playwright image
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
runs-on: ubuntu-24.04-arm
outputs:
image: ${{ steps.detect.outputs.image }}
version: ${{ steps.detect.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 1
fetch-tags: false
sparse-checkout: |
pnpm-lock.yaml
.github/actions/playwright-version
sparse-checkout-cone-mode: false
- name: Detect Playwright version
id: detect
uses: ./.github/actions/playwright-version
visual-tests:
name: Run visual comparison tests
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
runs-on: ubuntu-24.04-arm
needs:
- build-public-packages
- basic-checks
- playwright-image
container:
image: ${{ needs.playwright-image.outputs.image }}
options: --ipc=host
env:
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
fetch-tags: false
- name: Setup environment
uses: ./.github/actions/setup
with:
setup-rust: 'false'
- name: Cache turbo build setup
id: turbo-cache
uses: ./.github/actions/turbo
with:
cache-scope: visual-tests
restore-cache-scope: build-public-packages
allow-global-fallback: 'false'
- name: Verify public package build cache
env:
RESTORED_TURBO_CACHE_KEY: ${{ steps.turbo-cache.outputs.preferred-cache-matched-key }}
run: |
if [ -z "$RESTORED_TURBO_CACHE_KEY" ]; then
echo "::error::No build-public-packages Turbo cache was restored."
exit 1
fi
echo "Restored $RESTORED_TURBO_CACHE_KEY"
- name: Run visual comparison tests
run:
pnpm run test:visual --filter="./apps/*" --filter="!@stylexswc/rollup-large-example"
--continue
- name: Save turbo build cache
if: always()
uses: ./.github/actions/turbo-save
with:
cache-key: ${{ steps.turbo-cache.outputs.cache-key }}
benchmark:
name: Run benchmarks
if: >-
(github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft)
needs:
- build-public-packages
- basic-checks
runs-on: ubuntu-24.04-arm
permissions:
contents: read
env:
BENCHMARK_CACHE_KEY_PREFIX: >-
aarch64-unknown-linux-gnu-benchmark-${{
github.event.pull_request.number != null
&& format('pr-{0}', github.event.pull_request.number)
|| github.ref_name
}}
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
fetch-tags: false
- name: Setup environment
uses: ./.github/actions/setup
with:
setup-rust: 'false'
- name: Cache turbo build setup
id: turbo-cache
uses: ./.github/actions/turbo
with:
cache-scope: benchmark
restore-cache-scope: build-public-packages
- name: Download previous benchmark data
id: benchmark-cache-restore
uses: actions/cache/restore@v6
with:
path: ./cache
key: ${{ env.BENCHMARK_CACHE_KEY_PREFIX }}-${{ github.run_attempt }}
restore-keys: |
${{ env.BENCHMARK_CACHE_KEY_PREFIX }}-
aarch64-unknown-linux-gnu-benchmark-pr-
aarch64-unknown-linux-gnu-benchmark-
- name: Run benchmarks
run: pnpm run bench --filter @stylexswc/rs-compiler
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@52576c92bccf6ac60c8223ec7eb2565637cae9ba # v1.22.1
with:
tool: 'benchmarkjs'
output-file-path: 'crates/stylex-rs-compiler/benchmark/results/output.txt'
external-data-json-path: './cache/benchmark-data.json'
fail-on-alert: true
comment-on-alert: true
alert-comment-cc-users: '@Dwlad90'
summary-always: true
github-token: ${{ secrets.GITHUB_TOKEN }}
alert-threshold: '150%'
fail-threshold: '175%'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save benchmark cache
if: always()
uses: actions/cache/save@v6
with:
path: ./cache
key: ${{ env.BENCHMARK_CACHE_KEY_PREFIX }}-${{ github.run_attempt }}
- name: Save turbo build cache
if: always()
uses: ./.github/actions/turbo-save
with:
cache-key: ${{ steps.turbo-cache.outputs.cache-key }}
pr-validation:
name: PR Validation
if:
${{ always() && (github.event_name != 'schedule' || github.ref_name == 'develop') &&
(github.event.pull_request.number == null || !github.event.pull_request.draft) }}
needs:
- build-public-packages
- basic-checks
- checks
- playwright-image
- visual-tests
- benchmark
runs-on: ubuntu-24.04-arm
steps:
- name: Verify validation jobs
env:
NEEDS_JSON: ${{ toJSON(needs) }}
run: |
echo "$NEEDS_JSON" | jq .
for job in basic-checks checks build-public-packages playwright-image visual-tests benchmark; do
result=$(echo "$NEEDS_JSON" | jq -r --arg job "$job" '.[$job].result')
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
echo "::error::Validation job '$job' finished with status '$result'."
exit 1
fi
done
echo "All validation jobs passed"
dependabot:
runs-on: ubuntu-24.04-arm
needs: [pr-validation]
if:
github.event_name != 'schedule' && github.event.pull_request.number != null &&
github.event.pull_request.user.login == 'dependabot[bot]'
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Set PR information as environment variables
env:
PR_NUMBER_VALUE: ${{ github.event.pull_request.number }}
PR_URL_VALUE: ${{ github.event.pull_request.html_url }}
PR_HEAD_REF_VALUE: ${{ github.event.pull_request.head.ref }}
UPDATE_TYPE_VALUE: ${{ steps.metadata.outputs.update-type }}
DEPENDENCY_TYPE_VALUE: ${{ steps.metadata.outputs.dependency-type }}
run: |
echo "PR_NUMBER=${PR_NUMBER_VALUE}" >> $GITHUB_ENV
echo "PR_URL=${PR_URL_VALUE}" >> $GITHUB_ENV
echo "PR_HEAD_REF=${PR_HEAD_REF_VALUE}" >> $GITHUB_ENV
echo "UPDATE_TYPE=${UPDATE_TYPE_VALUE}" >> $GITHUB_ENV
echo "DEPENDENCY_TYPE=${DEPENDENCY_TYPE_VALUE}" >> $GITHUB_ENV
- name: Add labels based on dependency type
run: |
if [[ "$DEPENDENCY_TYPE" == "direct:production" ]]; then
gh pr edit "$PR_NUMBER" --add-label "production"
else
gh pr edit "$PR_NUMBER" --add-label "development"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Approve Pull Request
run: |
gh pr review "$PR_NUMBER" --approve -R ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
if: |
(steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor')
uses: ./.github/actions/gitconfig
- name: Auto-merge for safe updates
if: |
(steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor')
run: |
echo "Auto-merging PR..."
git checkout develop
git pull origin develop
git fetch origin "$PR_HEAD_REF"
git merge origin/"$PR_HEAD_REF"
git push origin develop
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment on PR if auto-merge is skipped
if: |
(steps.metadata.outputs.update-type != 'version-update:semver-patch' &&
steps.metadata.outputs.update-type != 'version-update:semver-minor')
run: |
REASON="The update type ($UPDATE_TYPE) requires manual review"
gh pr comment "$PR_NUMBER" -b "⚠️ This PR wasn't automatically merged: $REASON"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}