Repository navigation
976 lines (915 loc) · 49 KB
/
Copy pathplaywright-postgresql-e2e.yml
File metadata and controls
976 lines (915 loc) · 49 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
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
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
# Copyright 2021 Collate
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Dispatcher for the postgresql Playwright E2E PR gate.
#
# The heavy lifting (gate → build → shard) lives in
# `playwright-e2e-reusable.yml`; this file adds two top-level jobs that
# MUST stay in the caller so branch protection can find them by their
# UN-PREFIXED check names:
#
# * `playwright-summary` — the required PR check + PR-comment
# payload uploader (comment forwarding lives
# in playwright-postgresql-pr-comment.yml).
# * `refresh-timing-baseline` — full workflow_dispatch on main; direct commit
# that keeps `.github/playwright/timing-baseline.json`
# fresh from that run (merge groups upload no
# timing metrics, so they cannot feed it)
# (materiality-gated; see the job comment).
#
# Reusable jobs are reported as `<caller-job> / <sub-job>` — GH always
# prefixes — so a required check named `playwright-summary` could never
# be satisfied from inside the reusable. Keeping these two jobs at the
# caller top level lets branch protection match the exact name.
#
# Release-branch dry-runs live in `playwright-postgresql-nightly.yml`;
# any change to shard planning, caching, gate rules, or the shadow-gate
# ledger still belongs in the reusable so both callers stay aligned.
name: Postgresql PR Playwright E2E Tests
on:
merge_group:
# Daily full run on main. Merge groups upload no timing metrics, so this (plus manual
# full dispatches) is what feeds ci/playwright-timing and the full-suite timing
# artifacts PR planning downloads.
schedule:
- cron: '30 2 * * *'
workflow_dispatch:
inputs:
full_suite:
description: Run the complete duration-balanced suite
required: true
type: boolean
default: true
protocol:
description: Application protocol used by Playwright
required: true
type: choice
options:
- http
- h2
default: http
coarse_bundle:
description: Build the CI-only coarse Vite bundle
required: true
type: boolean
default: true
# Playwright runs only in the merge queue. PRs still trigger the workflow
# because `playwright-summary` is a required check: every job is skipped by
# its `if:` (no runner starts), and GitHub counts a skipped required check
# as passing. With no PR trigger the check would hang at "Expected — waiting".
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
permissions:
actions: read
contents: read
pull-requests: read
jobs:
playwright:
if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/playwright-e2e-reusable.yml
# secrets: inherit passes the full TEST_* / GITHUB_TOKEN set into the
# reusable without re-listing each one; the reusable only reads what it
# needs.
secrets: inherit
permissions:
actions: read
contents: read
pull-requests: read
checks: read
with:
database: postgresql
profile: postgresql-pr
workflow_filename: playwright-postgresql-e2e.yml
# Defaults inline what workflow_dispatch collects; non-dispatch events
# fall back to the reusable's own defaults (full_suite=true, http,
# coarse_bundle=true). `a && b || c` falls through to c when b is
# false, so a dispatched `false` must not be written that way.
full_suite: ${{ github.event_name != 'workflow_dispatch' || inputs.full_suite }}
protocol: ${{ github.event_name == 'workflow_dispatch' && inputs.protocol || 'http' }}
coarse_bundle: ${{ github.event_name != 'workflow_dispatch' || inputs.coarse_bundle }}
# One retry everywhere while the first-attempt signal is collected: the
# main-health job alerts Slack on every failure and flaky pass so each can
# be fixed.
retries: 1
playwright-summary:
name: playwright-summary
if: ${{ always() && !cancelled() && github.event_name != 'pull_request' }}
needs: [playwright]
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
actions: read
# Reads shard annotations for the merge-queue flaky alert.
checks: read
contents: read
# For the budget-breach tracked issue (Signal Playwright budget
# breaches step below).
issues: write
steps:
- name: Gate verified merge-group shards
if: ${{ github.event_name == 'merge_group' }}
env:
GATE_RESULT: ${{ needs.playwright.outputs.gate_result }}
SHOULD_RUN: ${{ needs.playwright.outputs.gate_should_run }}
PLAN_RESULT: ${{ needs.playwright.outputs.plan_playwright_result }}
SHARD_RESULT: ${{ needs.playwright.outputs.playwright_ci_result }}
EXPECTED_MATRIX: ${{ needs.playwright.outputs.plan_playwright_matrix }}
run: |
node <<'NODE'
const checks = {
authorization: process.env.GATE_RESULT === 'success',
selected: process.env.SHOULD_RUN === 'true',
planning: process.env.PLAN_RESULT === 'success',
shards: process.env.SHARD_RESULT === 'success',
};
const matrix = JSON.parse(process.env.EXPECTED_MATRIX || '{}').include;
checks.nonemptyPlan = Array.isArray(matrix) && matrix.length > 0 &&
matrix.every(shard => typeof shard.shardId === 'string' && shard.shardId.length > 0) &&
new Set(matrix.map(shard => shard.shardId)).size === matrix.length;
const failed = Object.entries(checks).filter(([, passed]) => !passed).map(([name]) => name);
if (failed.length) {
console.error(`Merge-group validation failed: ${failed.join(', ')}`);
process.exit(1);
}
console.log(`${matrix.length} shards passed tests and local coverage verification.`);
NODE
# Merge-queue failures are not posted from here: a failed run does not
# always dequeue its PR (when an entry ahead leaves, GitHub rebuilds the
# group and lets the old run finish). This leaves the failed tests as one
# annotation on this check instead, and merge-queue-dequeue-report.yml adds
# them to its single #ci-cleanup alert, which fires only on a real dequeue.
# Inline because this runs before Checkout; queue runs upload results JSON
# only on failure.
- name: Download failed merge-queue shard results
if: ${{ failure() && github.event_name == 'merge_group' }}
continue-on-error: true
uses: actions/download-artifact@v7
with:
# Current attempt only: artifacts belong to the run, so a re-run would
# otherwise report tests that failed only in an earlier attempt.
pattern: playwright-results-json-*-a${{ github.run_attempt }}*
path: queue-results
merge-multiple: false
- name: Annotate the failed merge-queue tests
if: ${{ failure() && github.event_name == 'merge_group' }}
continue-on-error: true
run: |
set -uo pipefail
# shellcheck disable=SC2016 # \(...) is jq interpolation, not shell
tests=$(find queue-results -name results.json -type f -print0 2>/dev/null |
xargs -0 -r jq -r '[.. | objects | select(has("tests") and has("title")) | . as $s | .tests[] | select(.status == "unexpected") | "\($s.file) › \($s.title)"] | .[]' 2>/dev/null |
sort -u | head -n 15 || true)
if [[ -z "$tests" ]]; then
echo "No failed tests in the results; the dequeue report lists the failed jobs."
exit 0
fi
# One annotation for the whole list; the dequeue report reads it by title.
# Workflow-command escaping: % -> %25, newline -> %0A.
encoded=${tests//'%'/'%25'}
encoded=${encoded//$'\n'/'%0A'}
echo "::error title=Merge queue failed tests::$encoded"
# Queue flakes go to #pw-health with the daily main-run flakes. Each shard
# leaves one "Retry pass in merge queue" annotation listing its retry
# passes (one per line), so this reads those instead of uploading reports;
# inline for the same reason as the failed-test annotation above.
# success() posts once per queue run, from the attempt whose shards all
# passed: a failed attempt gets re-run and would post the same flakes
# again, and its failures go to the dequeue report instead. A re-run
# attempt lists the shard jobs it carried over, so their flakes are kept.
- name: Build the merge-queue flaky message
id: queue-flaky
if: ${{ success() && github.event_name == 'merge_group' }}
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
HEAD_REF: ${{ github.event.merge_group.head_ref }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
set -uo pipefail
prs=$(grep -oE 'pr-[0-9]+' <<< "$HEAD_REF" | sed 's/pr-//' | sort -u | tr '\n' ' ')
flaky=$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT/jobs" \
--jq '.jobs[] | select(.name | contains("playwright-ci")) | .id' 2>/dev/null |
while read -r job; do
gh api --paginate "repos/$GITHUB_REPOSITORY/check-runs/$job/annotations" \
--jq '.[] | select(.title == "Retry pass in merge queue") | .message' 2>/dev/null
done | sed '/^$/d' | sort -u)
if [[ -z "$flaky" ]]; then
echo "No retry passes in this queue run."
exit 0
fi
# shellcheck disable=SC2016 # \(...) is jq interpolation, not shell
jq -n --arg channel C0C008ZAK0V --arg prs "$prs" --arg flaky "$flaky" \
--arg run "$RUN_URL" --arg repo "$REPO_URL" '
def lines($s): $s | split("\n") | map(select(length > 0));
(lines($flaky)) as $tests |
{channel: $channel, text: ([
":large_yellow_circle: *Merge queue: \($tests | length) test(s) passed only on retry*" +
(if ($prs | length) > 0 then " for " + ([$prs | split(" ")[] | select(length > 0) | "<\($repo)/pull/\(.)|#\(.)>"] | join(", ")) else "" end)
] + [$tests[:15][] | "• FLAKY `\(.)`"]
+ (if ($tests | length) > 15 then ["…and \(($tests | length) - 15) more (see the run)"] else [] end)
+ ["<\($run)|run>"] | join("\n"))}' > "$RUNNER_TEMP/queue-flaky.json"
echo "posted=true" >> "$GITHUB_OUTPUT"
- name: Post merge-queue flaky tests to Slack (pw-health)
if: ${{ success() && github.event_name == 'merge_group' && steps.queue-flaky.outputs.posted == 'true' }}
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: chat.postMessage
token: ${{ secrets.COLLATE_BOT_SLACK_TOKEN }}
errors: true
payload-file-path: ${{ runner.temp }}/queue-flaky.json
# SECURITY: this job runs `require('./.github/scripts/render_playwright_summary.cjs')`
# via `actions/github-script` with GITHUB_TOKEN in scope, so whichever tree we
# check out here becomes trusted code executing with token access. It never runs
# on PR events, so github.sha is always a merge-group commit (approved PRs) or a
# scheduled / dispatched ref. Merge groups use the inline gate and alert above;
# they check out only to merge the HTML report so queue failures and retry passes
# keep their traces.
- name: Checkout
id: checkout
# always(): a failed merge-group gate must not skip the trace report.
if: always()
continue-on-error: true
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download blob reports
id: download-blobs
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
uses: actions/download-artifact@v7
continue-on-error: true
with:
pattern: playwright-blob-*
path: ${{ runner.temp }}/playwright-blobs
merge-multiple: true
- name: Download timing metrics
id: download-timings
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
uses: actions/download-artifact@v7
continue-on-error: true
with:
pattern: playwright-timings-*
path: ${{ runner.temp }}/playwright-timings
- name: Download shard plans
id: download-plans
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/download-artifact@v7
with:
name: playwright-shard-plans
path: ${{ runner.temp }}/playwright-plans
- name: Download all results JSON
id: download-results
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
uses: actions/download-artifact@v7
continue-on-error: true
with:
# Every attempt: a "Re-run failed jobs" attempt only re-uploads the
# shards it re-ran, so the shards that passed earlier exist only
# under their earlier `-a<attempt>` suffix. The next step drops
# superseded attempts so a stale ci-status.json cannot outrank a
# green re-run (runs 35650435023, 36268674020).
pattern: playwright-results-json-*
path: results
# Pin the per-artifact subdirectory layout the renderer expects
# (results/playwright-results-json-<shardId>/results.json). When
# only one artifact matches the pattern — typical for spec-only
# single-shard PR runs — some download-artifact configurations
# flatten the contents directly into `path:`, which breaks the
# readdirSync-based shard discovery in render_playwright_summary.cjs
# and reports the shard as "did not upload a usable Playwright
# results artifact". Explicitly locking merge-multiple=false keeps
# the layout consistent across single-shard and multi-shard runs.
# See run 30088248354 for the failure this addresses.
merge-multiple: false
- name: Keep only the newest attempt per shard
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
run: python3 .github/scripts/keep_latest_playwright_attempt.py results
# Diagnostic: log the actual on-disk layout the renderer sees. The
# explicit merge-multiple pin above matches the documented default,
# so if single-shard runs still fail the same way we need this
# trace to see whether download-artifact placed files at
# `results/playwright-results-json-<shardId>/results.json` (expected)
# or somewhere else. Remove once single-shard runs are consistently
# green.
- name: Validate and normalize execution artifacts
id: normalize-results
# Checks every shard's results came from this commit and run, collapses
# transport duplicates, and fails on conflicting evidence. Advisory: its
# outcome feeds the classifier's artifactIntegrityVerified measurement.
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
EXPECTED_HEAD_SHA: ${{ github.sha }}
run: node .github/scripts/normalize_playwright_artifacts.cjs results "$EXPECTED_HEAD_SHA"
- name: Diagnose downloaded results layout
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
run: |
echo "=== results/ tree ==="
ls -laR results 2>&1 || echo "(results/ does not exist)"
echo
echo "=== expected shardIds (from plan-playwright.matrix) ==="
echo '${{ needs.playwright.outputs.plan_playwright_matrix }}' \
| jq -r '.include[].shardId' \
|| echo "(jq parse failed)"
- name: Setup Node.js
id: setup-node
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/setup-node@v5
with:
node-version-file: openmetadata-ui/src/main/resources/ui/.nvmrc
# Restore-only. setup-node's built-in `cache: yarn` saves a ~1.4 GB
# node-cache-* entry under the current ref as a post-step and has no
# restore-only mode; nothing on main writes that key family, so every
# PR missed and saved its own copy (3 x 1.4 GB measured 2026-09-29,
# 43% of the 10 GB budget) and evicted the warmer's fixtures. The
# yarn-pkg-cache-* key is written under main by
# populate-playwright-caches.yml, so this hits on every event.
- name: Restore yarn package cache
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: ~/.cache/yarn
key: yarn-pkg-cache-${{ runner.os }}-${{ hashFiles('openmetadata-ui/src/main/resources/ui/yarn.lock') }}
restore-keys: |
yarn-pkg-cache-${{ runner.os }}-
- name: Install report dependencies
id: install-report-dependencies
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
working-directory: openmetadata-ui/src/main/resources/ui
run: |
corepack enable
timeout --foreground --signal=TERM --kill-after=30s 5m \
yarn --ignore-scripts --frozen-lockfile
- name: Mark report generation start
id: mark-report-start
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
run: echo "PW_REPORT_STARTED_AT=$(date +%s)" >> "$GITHUB_ENV"
- name: Merge HTML report
id: merge-report
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
working-directory: openmetadata-ui/src/main/resources/ui
env:
PLAYWRIGHT_HTML_OUTPUT_DIR: ${{ runner.temp }}/playwright-report
run: |
if ! find "$RUNNER_TEMP/playwright-blobs" -type f -name '*.zip' -print -quit | grep -q .; then
echo "No Playwright blob reports were uploaded" >&2
exit 1
fi
timeout --foreground --signal=TERM --kill-after=30s 3m \
npx playwright merge-reports --reporter=html "$RUNNER_TEMP/playwright-blobs"
- name: Merge Playwright timing history
id: merge-timings
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
EXECUTION_MODE: ${{ needs.playwright.outputs.detect_changes_mode }}
SOURCE_SHA: ${{ github.sha }}
run: |
timeout --foreground --signal=TERM --kill-after=30s 1m \
python3 .github/scripts/merge_playwright_timings.py \
--input-glob "$RUNNER_TEMP/playwright-timings/**/playwright-timings.json" \
--mode "$EXECUTION_MODE" \
--source-sha "$SOURCE_SHA" \
--output "$RUNNER_TEMP/playwright-timing-history/playwright-timing-history.json"
- name: Verify Playwright timing coverage
id: verify-coverage
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
run: |
timeout --foreground --signal=TERM --kill-after=30s 1m \
python3 .github/scripts/verify_playwright_coverage.py \
--plan-glob "$RUNNER_TEMP/playwright-plans/*.json" \
--timing-glob "$RUNNER_TEMP/playwright-timings/**/playwright-timings.json" \
--result-glob "$GITHUB_WORKSPACE/results/playwright-results-json-*/results.json" \
--output "$RUNNER_TEMP/playwright-timing-history/playwright-coverage.json"
- name: Evaluate Playwright performance
id: evaluate-performance
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
EXECUTION_MODE: ${{ needs.playwright.outputs.detect_changes_mode }}
run: |
# No --enforce: time/flake budget targets are SIGNALS (surfaced by
# the "Signal Playwright budget breaches" step below), never a
# reason to fail the required check on an otherwise-green run.
# Blocking targets (reserved for corrupt-results states; empty
# today) would still exit non-zero under --enforce if reintroduced.
timeout --foreground --signal=TERM --kill-after=30s 2m \
python3 .github/scripts/evaluate_playwright_performance.py \
--timing-glob "$RUNNER_TEMP/playwright-timings/**/playwright-timings.json" \
--request-glob "$RUNNER_TEMP/playwright-timings/**/request-metrics.json" \
--phase-glob "$RUNNER_TEMP/playwright-timings/**/shard-phases.json" \
--mode "$EXECUTION_MODE" \
--output "$RUNNER_TEMP/playwright-timing-history/playwright-performance.json"
jq . "$RUNNER_TEMP/playwright-timing-history/playwright-performance.json"
- name: Upload merged Playwright report
id: upload-report
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/playwright-report
retention-days: 5
if-no-files-found: ignore
- name: Record reporting and report-upload duration
id: record-report-duration
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
EXECUTION_MODE: ${{ needs.playwright.outputs.detect_changes_mode }}
run: |
performance="$RUNNER_TEMP/playwright-timing-history/playwright-performance.json"
[[ -f "$performance" ]] || exit 0
report_seconds=$(($(date +%s) - PW_REPORT_STARTED_AT))
# Reporting duration is a BUDGET target: recorded, surfaced by the
# budget-signal step below, but never a reason to fail the check
# (it used to exit 1 here on full-mode runs and eject green PRs).
jq \
--argjson reportSeconds "$report_seconds" \
'.metrics.reportingSeconds = $reportSeconds |
.targets.reportingAtMostTwoMinutes = ($reportSeconds <= 120) |
.budgetTargets.reportingAtMostTwoMinutes = ($reportSeconds <= 120) |
.targetsMet = ([.targets[]] | all) |
.budgetTargetsMet = ([.budgetTargets[]] | all) |
.blockingTargetsMet = ([.blockingTargets[]] | all) |
.convergenceTargetsMet = ([.convergenceTargets[]] | all)' \
"$performance" > "$performance.tmp"
mv "$performance.tmp" "$performance"
if [[ "$report_seconds" -gt 120 ]]; then
echo "::warning::Playwright reporting and report upload took ${report_seconds}s (budget 120s)"
fi
# THE budget signal. Time/flake budgets no longer fail the required
# check (see evaluate_playwright_performance.py — run 32500973433
# ejected a PR with zero test failures); instead every breach is:
# * a ::warning annotation on this run,
# * a section in the job summary,
# * an upsert into the tracked issue "Playwright CI over time budget"
# (merge_group full runs only, comment throttled to one per 20 h)
# so capacity problems page a human through the issue, not by ejecting
# innocent PRs from the merge queue.
- name: Signal Playwright budget breaches
id: budget-signal
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.gate_should_run == 'true' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXECUTION_MODE: ${{ needs.playwright.outputs.detect_changes_mode }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
ISSUE_TITLE: "Playwright CI over time budget"
run: |
performance="$RUNNER_TEMP/playwright-timing-history/playwright-performance.json"
[[ -f "$performance" ]] || { echo "No performance payload; nothing to signal."; exit 0; }
met=$(jq -r '.budgetTargetsMet // true' "$performance")
if [[ "$met" == "true" ]]; then
echo "All Playwright budget targets met."
exit 0
fi
breached_names=$(jq -r '(.budgetTargets // {}) | to_entries[] | select(.value == false) | .key' "$performance")
detail_lines=$(jq -r '
(.failedBudgetTargetDetails // {}) | to_entries[] | . as $e |
"- **\($e.value.label)**: budget ≤ \($e.value.threshold) \($e.value.unit)" +
(if ($e.value.offendingShards | length) > 0
then " — exceeded on " + ($e.value.offendingShards | map("`\(.shardId)` (\(.value) \($e.value.unit))") | join(", "))
else "" end)' "$performance")
# Budget targets without phase attribution (flaky rate, retry
# share, boot shape) still need a line each.
plain_lines=$(jq -r '
(.failedBudgetTargetDetails // {}) as $d |
(.budgetTargets // {}) | to_entries[]
| select(.value == false and ($d[.key] | not))
| "- \(.key)"' "$performance")
while IFS= read -r name; do
[[ -n "$name" ]] && echo "::warning::Playwright budget breach: $name"
done <<< "$breached_names"
{
echo "## ⚠️ Playwright budget breaches"
echo
[[ -n "$detail_lines" ]] && echo "$detail_lines"
[[ -n "$plain_lines" ]] && echo "$plain_lines"
echo
echo "Budget breaches do not fail this check; investigate via the tracked issue."
} >> "$GITHUB_STEP_SUMMARY"
# Tracked issue: only authoritative (merge_group + full) runs feed
# it — PR-time targeted runs measure a subset and would be noise.
if [[ "${GITHUB_EVENT_NAME}" != "merge_group" || "$EXECUTION_MODE" != "full" ]]; then
exit 0
fi
body=$(printf 'Latest breach: [run %s](%s)\n\n%s\n%s\n\nThe merge-queue check stays green on budget breaches; this issue is the signal. Investigate shard packing (`build_playwright_shards.py`), the timing baseline, or runaway specs. Close when runs stay within budget.\n' \
"${GITHUB_RUN_ID}" "$RUN_URL" "$detail_lines" "$plain_lines")
existing=$(gh issue list --state open --search "in:title \"$ISSUE_TITLE\"" \
--json number,title --jq --arg t "$ISSUE_TITLE" '[.[] | select(.title == $t)][0].number // empty')
if [[ -z "$existing" ]]; then
gh issue create --title "$ISSUE_TITLE" --body "$body"
echo "Opened budget-breach issue."
else
# Throttle: at most one comment per 20 h so a breached week does
# not bury the issue in per-run comments.
last_comment=$(gh issue view "$existing" --json comments \
--jq '.comments[-1].createdAt // ""')
cutoff=$(date -u -d '20 hours ago' +%FT%TZ)
if [[ -z "$last_comment" || "$last_comment" < "$cutoff" ]]; then
gh issue comment "$existing" --body "$body"
echo "Commented on budget-breach issue #$existing."
else
echo "Issue #$existing already updated within 20 h; skipping comment."
fi
fi
- name: Upload timing history
id: upload-timing-history
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: playwright-timing-history-${{ needs.playwright.outputs.detect_changes_mode }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/playwright-timing-history
retention-days: 30
if-no-files-found: warn
- name: Evaluate zero-retry gate in shadow mode
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
env:
EXPECTED_MATRIX: ${{ needs.playwright.outputs.plan_playwright_matrix }}
MATRIX_OUTCOME: ${{ needs.playwright.outputs.playwright_ci_result }}
SOURCE_SHA: ${{ github.sha }}
run: |
# main's flake baseline lets the ledger separate a retry pass this run
# introduced (newRetryPassStableIds) from one main already has. Report
# only; a missing baseline just means every retry pass is unattributed.
baseline_args=()
if git fetch --depth=1 --no-tags origin ci/playwright-timing 2>/dev/null &&
git show FETCH_HEAD:flake-baseline.json > "$RUNNER_TEMP/flake-baseline.json" 2>/dev/null; then
baseline_args=(--retry-baseline "$RUNNER_TEMP/flake-baseline.json")
fi
python3 .github/scripts/classify_playwright_outcome.py \
--report-glob 'results/playwright-results-json-*/results.json' \
--status-glob 'results/playwright-results-json-*/ci-status.json' \
--matrix-outcome "$MATRIX_OUTCOME" \
--expected-matrix-json "$EXPECTED_MATRIX" \
--profile postgresql-pr \
--source-sha "$SOURCE_SHA" \
--coverage "$RUNNER_TEMP/playwright-timing-history/playwright-coverage.json" \
--artifact-integrity-outcome "${{ steps.normalize-results.outcome }}" \
${baseline_args[@]+"${baseline_args[@]}"} \
--output "$RUNNER_TEMP/playwright-shadow-gate/outcome.json"
- name: Upload Playwright shadow-gate ledger
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: playwright-shadow-gate-postgresql-pr-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/playwright-shadow-gate/outcome.json
if-no-files-found: warn
retention-days: 30
# If gate itself didn't produce a valid decision (crash, cancelled,
# unknown), FAIL loudly rather than silently reporting green below.
# Without this guard, the "should_run != 'true'" branch (or any
# negative match) would treat an unset gate output the same as an
# explicit skip decision — hiding the gate failure and letting a
# required check pass on an invalid pipeline state.
- name: Guard against missing gate decision
if: ${{ github.event_name != 'merge_group' && needs.playwright.outputs.gate_result != 'success' }}
run: |
echo "::error::gate did not succeed (result=${{ needs.playwright.outputs.gate_result }}, should_run=${{ needs.playwright.outputs.gate_should_run }}). Refusing synthetic green — this playwright-summary must not report success without a valid gate decision."
exit 1
- name: Render consolidated job summary and gate on results
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.gate_should_run == 'true' }}
uses: actions/github-script@v9
env:
CHECK_CHANGES_RESULT: ${{ needs.playwright.outputs.check_changes_result }}
CACHE_KEYS_RESULT: ${{ needs.playwright.outputs.cache_keys_result }}
BUILD_RESULT: ${{ needs.playwright.outputs.build_result }}
DETECT_CHANGES_RESULT: ${{ needs.playwright.outputs.detect_changes_result }}
PLAN_RESULT: ${{ needs.playwright.outputs.plan_playwright_result }}
FIXTURE_RESTORE_RESULT: ${{ needs.playwright.outputs.restore_playwright_fixture_result }}
FIXTURE_RESULT: ${{ needs.playwright.outputs.prepare_playwright_fixture_result }}
PLAYWRIGHT_RESULT: ${{ needs.playwright.outputs.playwright_ci_result }}
SUMMARY_CHECKOUT_OUTCOME: ${{ steps.checkout.outcome }}
REPORT_DOWNLOAD_BLOBS_OUTCOME: ${{ steps.download-blobs.outcome }}
REPORT_DOWNLOAD_TIMINGS_OUTCOME: ${{ steps.download-timings.outcome }}
REPORT_DOWNLOAD_PLANS_OUTCOME: ${{ steps.download-plans.outcome }}
REPORT_DOWNLOAD_RESULTS_OUTCOME: ${{ steps.download-results.outcome }}
REPORT_SETUP_NODE_OUTCOME: ${{ steps.setup-node.outcome }}
REPORT_INSTALL_OUTCOME: ${{ steps.install-report-dependencies.outcome }}
REPORT_START_OUTCOME: ${{ steps.mark-report-start.outcome }}
REPORT_MERGE_OUTCOME: ${{ steps.merge-report.outcome }}
REPORT_TIMING_MERGE_OUTCOME: ${{ steps.merge-timings.outcome }}
REPORT_COVERAGE_OUTCOME: ${{ steps.verify-coverage.outcome }}
REPORT_PERFORMANCE_OUTCOME: ${{ steps.evaluate-performance.outcome }}
REPORT_UPLOAD_OUTCOME: ${{ steps.upload-report.outcome }}
REPORT_DURATION_OUTCOME: ${{ steps.record-report-duration.outcome }}
REPORT_HISTORY_OUTCOME: ${{ steps.upload-timing-history.outcome }}
E2E_CHANGED: ${{ needs.playwright.outputs.check_changes_e2e }}
DOCKER_COMPOSE_CHANGED: ${{ needs.playwright.outputs.check_changes_docker_compose }}
EXPECTED_MATRIX: ${{ needs.playwright.outputs.plan_playwright_matrix }}
COMMENT_PAYLOAD_PATH: ${{ runner.temp }}/playwright-pr-comment/summary.json
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { renderPlaywrightSummary } = require('./.github/scripts/render_playwright_summary.cjs');
await renderPlaywrightSummary({ github, context, core });
- name: Upload Playwright PR comment payload
if: ${{ always() && github.event_name != 'merge_group' }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: playwright-pr-comment-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/playwright-pr-comment/summary.json
retention-days: 5
if-no-files-found: ignore
# Auto-refresh the checked-in timing baseline from successful full-mode
# workflow_dispatch runs on main. Merge groups upload no timing metrics (their
# shards verify coverage locally), so they cannot be the source. Without this, `.github/playwright/timing-baseline.json`
# only gets updated by hand — and it drifts fast (see PR #30871 for the
# 12-day, 23%-dead-title snapshot that triggered this workflow addition).
#
# COMMITS DIRECTLY TO MAIN (no PR). The previous auto-PR design
# deadlocked with the merge queue: the refresh PR had to pass through the
# very queue whose activity kept invalidating it, and concurrent refresh
# runs raced on the bot branch (`cannot lock ref`, run 32354038772). A
# data-only JSON regenerated from a known-good run doesn't need review —
# the guards below are the review. `[skip ci]` keeps the push from
# burning a CI cycle; note any push to main still resets in-flight
# merge-queue entries, which is why the materiality threshold exists.
#
# Guards:
# * workflow_dispatch on main only (merge groups upload no timing metrics;
# a PR run is not a known-good snapshot of main)
# * full execution mode only (targeted PR plans do not exercise every
# spec — a targeted refresh would lose coverage)
# * playwright-summary success only (no partial data on gate failures)
# * a drift cap in refresh_timing_baseline.py refuses > 40 % churn as
# a safety valve against an accidentally-broken source run
# * a materiality threshold (--min-materiality-percent) skips commits
# for run-to-run jitter — only structural changes (files gained or
# lost, zero-duration entries recovering) or ≥ 10 % of entries
# drifting/shifting significantly produce a commit
# * fetch → regenerate → push retry loop (3 attempts) absorbs races
# with the queue landing merges mid-refresh
# After each full run on main, record what main itself does not reliably
# pass and alert #pw-health on any failure or flaky pass (failed first, passed
# on retry). #ci-cleanup is reserved for merge-queue failures. The flake baseline lives next to the timing
# baseline on ci/playwright-timing, so PR summaries can tell a flake they
# introduced from one main already has.
main-health:
name: Main health
needs: [playwright, playwright-summary]
if: |
always() &&
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') &&
github.ref == 'refs/heads/main' &&
needs.playwright.outputs.playwright_ci_result != 'skipped'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
actions: read
contents: write
env:
DATA_BRANCH: ci/playwright-timing
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: main
persist-credentials: true
- name: Download all results JSON
continue-on-error: true
uses: actions/download-artifact@v7
with:
pattern: playwright-results-json-*
path: results
merge-multiple: false
- name: Keep only the newest attempt per shard
continue-on-error: true
run: python3 .github/scripts/keep_latest_playwright_attempt.py results
- name: Classify the run and refresh the flake baseline
id: classify
env:
EXPECTED_MATRIX: ${{ needs.playwright.outputs.plan_playwright_matrix }}
MATRIX_OUTCOME: ${{ needs.playwright.outputs.playwright_ci_result }}
SOURCE_SHA: ${{ github.sha }}
run: |
set -uo pipefail
data="$RUNNER_TEMP/timing-data"
ledger="$RUNNER_TEMP/main-health/outcome.json"
# Regenerate inside the retry loop: the timing refresh pushes to the
# same branch, so a rejected push re-reads the latest baseline.
for attempt in 1 2 3; do
rm -rf "$data"
git fetch --no-tags origin "$DATA_BRANCH"
git worktree prune
git worktree add --detach "$data" FETCH_HEAD
git -C "$data" config user.email "github-actions[bot]@users.noreply.github.com"
git -C "$data" config user.name "github-actions[bot]"
baseline_args=() current=()
if [[ -f "$data/flake-baseline.json" ]]; then
baseline_args=(--retry-baseline "$data/flake-baseline.json")
cp "$data/flake-baseline.json" "$RUNNER_TEMP/previous-flake-baseline.json"
current=(--current "$RUNNER_TEMP/previous-flake-baseline.json")
fi
python3 .github/scripts/classify_playwright_outcome.py \
--report-glob 'results/playwright-results-json-*/results.json' \
--status-glob 'results/playwright-results-json-*/ci-status.json' \
--matrix-outcome "$MATRIX_OUTCOME" \
--expected-matrix-json "$EXPECTED_MATRIX" \
--profile postgresql-main \
--source-sha "$SOURCE_SHA" \
${baseline_args[@]+"${baseline_args[@]}"} \
--output "$ledger" || exit 1
echo "classification=$(jq -r .classification "$ledger")" >> "$GITHUB_OUTPUT"
python3 .github/scripts/refresh_flake_baseline.py \
--ledger "$ledger" \
${current[@]+"${current[@]}"} \
--output "$data/flake-baseline.json" \
--window 10 \
--threshold 2 \
--run-id "$GITHUB_RUN_ID" \
--source-sha "$SOURCE_SHA" \
--summary "$RUNNER_TEMP/flake-baseline-summary.md"
rc=$?
# 3 = the run measured nothing (cancelled, no results): keep the
# stored baseline rather than ageing real entries out of the window.
if [[ "$rc" -eq 3 ]]; then exit 0; fi
if [[ "$rc" -ne 0 ]]; then exit "$rc"; fi
cat "$RUNNER_TEMP/flake-baseline-summary.md" >> "$GITHUB_STEP_SUMMARY"
git -C "$data" add flake-baseline.json
if git -C "$data" diff --cached --quiet; then exit 0; fi
git -C "$data" commit -q -m "chore(playwright): update flake baseline from run ${GITHUB_RUN_ID}"
if git -C "$data" push origin "HEAD:refs/heads/$DATA_BRANCH"; then exit 0; fi
echo "Push rejected on attempt $attempt ($DATA_BRANCH moved); retrying." >&2
done
echo "Failed to push the flake baseline after 3 attempts." >&2
exit 1
- name: Publish the result to the job summary
if: ${{ always() }}
continue-on-error: true
run: |
ledger="$RUNNER_TEMP/main-health/outcome.json"
[[ -f "$ledger" ]] || exit 0
jq -r '
"### Playwright on main",
"",
"- Classification: `\(.classification)`",
"- Tests: \(.counts.tests) · failed \(.counts.failed) · passed only on retry \(.counts.retryPassed) · skipped \(.counts.skipped)",
(.infrastructureIssues[:10][] | "- :warning: \(.)"),
(.failures[:20][] | "- FAILED `\(.file)` › \(.title)"),
(.retryPasses[:20][] | "- FLAKY `\(.file)` › \(.title)")
' "$ledger" >> "$GITHUB_STEP_SUMMARY"
- name: Upload the main-health ledger
if: ${{ always() }}
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: playwright-main-health-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/main-health/outcome.json
if-no-files-found: warn
retention-days: 30
# Everything from main goes to #pw-health: failures and flaky passes are
# the fix list for dropping PR retries.
- name: Build the Slack message
id: slack
if: ${{ always() && steps.classify.outputs.classification != '' && steps.classify.outputs.classification != 'passed' }}
continue-on-error: true
env:
CLASSIFICATION: ${{ steps.classify.outputs.classification }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMIT_URL: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
run: |
set -euo pipefail
channel=C0C008ZAK0V # #pw-health
case "$CLASSIFICATION" in
passed_with_retries|cancelled) emoji=':large_yellow_circle:' ;;
*) emoji=':red_circle:' ;;
esac
jq -n --arg channel "$channel" --arg emoji "$emoji" \
--arg cls "$CLASSIFICATION" --arg sha "${GITHUB_SHA:0:7}" \
--arg commit "$COMMIT_URL" --arg run "$RUN_URL" \
--slurpfile ledger "$RUNNER_TEMP/main-health/outcome.json" '
$ledger[0] as $l |
{channel: $channel, text: ([
"\($emoji) *Playwright on main* — `\($cls)` at <\($commit)|\($sha)>",
"\($l.counts.failed) failed and \($l.counts.retryPassed) passed only on retry, of \($l.counts.tests) tests."
] + [$l.failures[:10][] | "• FAILED `\(.file)` › \(.title)"]
+ [$l.retryPasses[:10][] | "• FLAKY `\(.file)` › \(.title)"]
+ ["<\($run)|run>"] | join("\n"))}' > "$RUNNER_TEMP/slack.json"
- name: Post to Slack
if: ${{ always() && steps.slack.outcome == 'success' }}
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: chat.postMessage
token: ${{ secrets.COLLATE_BOT_SLACK_TOKEN }}
# The action discards Slack API errors by default.
errors: true
payload-file-path: ${{ runner.temp }}/slack.json
refresh-timing-baseline:
name: Refresh timing baseline
needs: [playwright, playwright-summary]
if: |
always() &&
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') &&
github.ref == 'refs/heads/main' &&
needs.playwright.outputs.detect_changes_mode == 'full' &&
needs.playwright-summary.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
# The baseline lives on the data-only `ci/playwright-timing` branch, not
# main: main only takes changes through the merge queue (every direct push
# was rejected with GH013), and a push there would reset every in-flight
# queue entry. The data branch has no ruleset, so the workflow token can
# push to it directly.
- name: Checkout
uses: actions/checkout@v7
with:
ref: main
persist-credentials: true
- name: Download timing history artifact
uses: actions/download-artifact@v7
with:
name: playwright-timing-history-full-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/timing-history
- name: Locate merged history file
id: locate
run: |
history=$(find "$RUNNER_TEMP/timing-history" -name 'playwright-timing-history.json' -type f | head -1)
if [[ -z "$history" ]]; then
echo "No playwright-timing-history.json found under $RUNNER_TEMP/timing-history" >&2
find "$RUNNER_TEMP/timing-history" -type f >&2 || true
exit 1
fi
echo "history_path=$history" >> "$GITHUB_OUTPUT"
- name: Refresh baseline on ci/playwright-timing
env:
HISTORY_PATH: ${{ steps.locate.outputs.history_path }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
DATA_BRANCH: ci/playwright-timing
run: |
data="$RUNNER_TEMP/timing-data"
# Regenerate inside the retry loop so a concurrent refresh landing first
# changes the input rather than producing a rejected push.
for attempt in 1 2 3; do
rm -rf "$data"
git fetch --no-tags origin "$DATA_BRANCH"
git worktree prune
git worktree add --detach "$data" FETCH_HEAD
git -C "$data" config user.email "github-actions[bot]@users.noreply.github.com"
git -C "$data" config user.name "github-actions[bot]"
set +e
python3 .github/scripts/refresh_timing_baseline.py \
--history "$HISTORY_PATH" \
--current "$data/timing-baseline.json" \
--output "$data/timing-baseline.json" \
--source-run-id "$RUN_ID" \
--min-materiality-percent 10 \
--summary "$RUNNER_TEMP/baseline-refresh-summary.md"
rc=$?
set -e
if [[ "$rc" -eq 3 ]]; then
echo "Change below materiality threshold; skipping refresh commit."
exit 0
elif [[ "$rc" -ne 0 ]]; then
echo "refresh_timing_baseline.py exited $rc" >&2
exit "$rc"
fi
if git -C "$data" diff --quiet -- timing-baseline.json; then
echo "Baseline unchanged; nothing to commit."
exit 0
fi
git -C "$data" add timing-baseline.json
git -C "$data" commit \
-m "chore(playwright): refresh timing baseline from run ${RUN_ID}" \
-m "$(cat "$RUNNER_TEMP/baseline-refresh-summary.md")" \
-m "Source: ${RUN_URL}"
if git -C "$data" push origin "HEAD:refs/heads/$DATA_BRANCH"; then
echo "Baseline refreshed on $DATA_BRANCH (attempt $attempt)."
cat "$RUNNER_TEMP/baseline-refresh-summary.md" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
echo "Push rejected ($DATA_BRANCH moved during refresh); retrying." >&2
done
echo "Failed to push refreshed baseline after 3 attempts." >&2
exit 1