-
-
Notifications
You must be signed in to change notification settings - Fork 79
1116 lines (986 loc) · 41.2 KB
/
Copy pathphp.yml
File metadata and controls
1116 lines (986 loc) · 41.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
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
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: build-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
action-policy:
name: Central action policy preflight
if: ${{ github.server_url == 'https://github.com' }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out candidate source
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- name: Check out central action policy
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
repository: durable-workflow/.github
ref: main
path: .central-action-policy
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.13"
- name: Install policy dependencies
run: python -m pip install PyYAML==6.0.2
- name: Require centrally approved immutable action commits
run: >-
python .central-action-policy/scripts/qualification_policy.py validate
--policy .central-action-policy/qualification/policy.json
--target workflow
--workflow-directory .github/workflows
preflight:
name: Validate repository contracts
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
laravel_source_matrix: ${{ steps.laravel-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Verify build and feature selection contracts
run: python scripts/ci/test-build-routing.py
- name: Verify complete feature inventories
run: php scripts/ci/verify-feature-shards.php
- name: Validate workflow YAML syntax
run: yq eval-all '.' .github/workflows/*.yml >/dev/null
- name: Validate CI script syntax
run: |
bash -n \
scripts/ci/laravel-embedded-upgrade-smoke.sh \
scripts/ci/check-packagist-release.sh \
scripts/ci/check-platform-conformance-mirror.sh \
scripts/ci/test-platform-conformance-resolver-audit.sh
php -l scripts/ci/compare-platform-conformance-mirrors.php
php -l scripts/ci/check-v2-coverage.php
php -l scripts/ci/list-worker-protocol-resolvers.php
php -l scripts/ci/check-laravel-dependency-security.php
php -l scripts/ci/laravel-embedded-upgrade-matrix.php
php -l scripts/ci/verify-history-export-source-identity.php
php scripts/ci/check-v2-coverage.php --self-test
python - <<'PY'
import ast
from pathlib import Path
for path in Path("scripts/ci").glob("*.py"):
ast.parse(path.read_text(), filename=str(path))
PY
- name: Verify platform conformance resolver audit
run: scripts/ci/test-platform-conformance-resolver-audit.sh
- name: Validate Laravel dependency security policy
run: php scripts/ci/check-laravel-dependency-security.php --policy-only
- name: Install payload consumer dependencies
run: composer install --prefer-dist --no-progress --no-dev --no-scripts
- name: Derive bounded Laravel source qualification
id: laravel-matrix
run: echo "matrix=$(php scripts/ci/laravel-embedded-upgrade-matrix.php --scope=source)" >> "$GITHUB_OUTPUT"
- name: Require durable replay and codec evidence
env:
CORPUS_BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
arguments=()
if [[ "$CORPUS_BASE_REF" =~ ^[0-9a-f]{40}$ ]] && [[ ! "$CORPUS_BASE_REF" =~ ^0+$ ]]; then
arguments+=(--base-ref "$CORPUS_BASE_REF")
fi
python scripts/ci/validate-regression-corpus.py \
--skip-counterfactual \
"${arguments[@]}"
python scripts/ci/test-regression-corpus-policy.py
- name: Scan public boundary
shell: bash
env:
BUILD_EVENT_NAME: ${{ github.event_name }}
BUILD_BEFORE_SHA: ${{ github.event.before }}
BUILD_HEAD_SHA: ${{ github.sha }}
PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PULL_REQUEST_BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
set -euo pipefail
baseline=""
if [ "$BUILD_EVENT_NAME" = "pull_request" ]; then
range="${PULL_REQUEST_BASE_SHA}..${PULL_REQUEST_HEAD_SHA}"
base_ref="origin/${PULL_REQUEST_BASE_REF}"
if git rev-parse --verify --quiet "${base_ref}^{commit}" >/dev/null; then
baseline="$base_ref"
else
baseline="$PULL_REQUEST_BASE_SHA"
fi
elif [[ "$BUILD_BEFORE_SHA" =~ ^[0-9a-f]{40}$ ]] \
&& [[ ! "$BUILD_BEFORE_SHA" =~ ^0+$ ]] \
&& git cat-file -e "${BUILD_BEFORE_SHA}^{commit}"; then
range="${BUILD_BEFORE_SHA}..${BUILD_HEAD_SHA}"
elif git rev-parse --verify --quiet "${BUILD_HEAD_SHA}^" >/dev/null; then
range="${BUILD_HEAD_SHA}^..${BUILD_HEAD_SHA}"
else
range="$BUILD_HEAD_SHA"
fi
PUBLIC_BOUNDARY_GIT_RANGE="$range" \
PUBLIC_BOUNDARY_GIT_BASELINE="$baseline" \
scripts/check-public-boundary.sh
regression-corpus:
needs: preflight
runs-on: ubuntu-latest
timeout-minutes: 6
services:
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Prepare official consumer runtime
env:
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
if [ -d /dev/shm ] && [ -w /dev/shm ]; then
temporary_root=/dev/shm
else
temporary_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
fi
run_token="${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-1}"
corpus_db="${temporary_root}/workflow-regression-corpus-${run_token}.sqlite"
touch "$corpus_db"
if getent hosts redis > /dev/null 2>&1; then
redis_host=redis
redis_port=6379
elif [ -n "$REDIS_PUBLISHED_PORT" ]; then
redis_host=127.0.0.1
redis_port="$REDIS_PUBLISHED_PORT"
else
echo "::error::Unable to resolve Redis service endpoint" >&2
exit 1
fi
{
echo "CORPUS_DB_PATH=$corpus_db"
echo "APP_KEY=base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI="
echo "DB_CONNECTION=sqlite"
echo "DB_DATABASE=$corpus_db"
echo "CACHE_DRIVER=redis"
echo "CACHE_STORE=redis"
echo "QUEUE_CONNECTION=sync"
echo "QUEUE_FAILED_DRIVER=null"
echo "REDIS_HOST=$redis_host"
echo "REDIS_PORT=$redis_port"
echo "REDIS_PASSWORD="
} >> "$GITHUB_ENV"
- name: Prove new regression evidence against base and current bindings
env:
CORPUS_BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
arguments=()
if [[ "$CORPUS_BASE_REF" =~ ^[0-9a-f]{40}$ ]] && [[ ! "$CORPUS_BASE_REF" =~ ^0+$ ]]; then
arguments+=(--base-ref "$CORPUS_BASE_REF")
fi
python scripts/ci/validate-regression-corpus.py "${arguments[@]}"
- name: Remove regression-corpus database
if: ${{ always() }}
run: |
if [ -n "${CORPUS_DB_PATH:-}" ] \
&& [[ "${CORPUS_DB_PATH##*/}" == workflow-regression-corpus-*.sqlite ]]; then
rm -f -- "$CORPUS_DB_PATH"
fi
quality:
needs: preflight
runs-on: ubuntu-latest
timeout-minutes: 13
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Check coding style via ECS
run: vendor/bin/ecs check
- name: Run static analysis via PHPStan
run: vendor/bin/phpstan analyse src tests
laravel-embedded-upgrade-source:
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} embedded upgrade
needs: preflight
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.preflight.outputs.laravel_source_matrix) }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
tools: composer
- name: Run the clean stable-v1 to source-v2 journey
env:
LARAVEL_VERSION: ${{ matrix.laravel }}
WORKFLOW_V2_PATH: ${{ github.workspace }}
run: scripts/ci/laravel-embedded-upgrade-smoke.sh
pr-unit-contracts:
needs: preflight
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 13
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Resolve bounded pull-request test selection
run: >-
php scripts/ci/select-pr-tests.php
--config=.github/pr-test-selection.json
--weights=.github/feature-test-timings.json
--weight-profile=mysql
--output-dir=build/pr-selection
- name: Run database-independent unit contracts
run: |
mkdir -p build/test-results
xargs -a build/pr-selection/unit-files.txt \
vendor/bin/phpunit --testdox \
--log-junit build/test-results/pr-unit-contracts.xml
pr-feature-mysql:
needs: preflight
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 13
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: password
options: >-
--tmpfs /var/lib/mysql:rw,noexec,nosuid,size=1024m
ports:
- 3306
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 20
persist-credentials: false
- name: Resolve changed files
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
mkdir -p build/pr-selection
if [ -n "$BASE_SHA" ] && [ -n "$HEAD_SHA" ] \
&& git cat-file -e "${BASE_SHA}^{commit}" \
&& git cat-file -e "${HEAD_SHA}^{commit}"; then
git diff --name-only --diff-filter=ACMRT "$BASE_SHA" "$HEAD_SHA" \
> build/pr-selection/changed-files.txt
else
: > build/pr-selection/changed-files.txt
echo "Changed-file targeting unavailable; using the high-signal fallback."
fi
- name: Resolve bounded pull-request test selection
run: >-
php scripts/ci/select-pr-tests.php
--config=.github/pr-test-selection.json
--weights=.github/feature-test-timings.json
--weight-profile=mysql
--changed-files=build/pr-selection/changed-files.txt
--output-dir=build/pr-selection
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Resolve service endpoints and export test defaults
env:
MYSQL_PUBLISHED_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
resolve_service() {
service="$1"
container_port="$2"
published_port="$3"
prefix="$4"
if getent hosts "$service" > /dev/null 2>&1; then
echo "${prefix}_HOST=${service}"
echo "${prefix}_PORT=${container_port}"
elif [ -n "$published_port" ]; then
echo "${prefix}_HOST=127.0.0.1"
echo "${prefix}_PORT=${published_port}"
else
echo "::error::Unable to resolve ${service} or determine its published port" >&2
exit 1
fi
}
{
resolve_service mysql 3306 "$MYSQL_PUBLISHED_PORT" DB
resolve_service redis 6379 "$REDIS_PUBLISHED_PORT" REDIS
echo "APP_KEY=base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI="
echo "DB_DATABASE=testbench"
echo "DB_USERNAME=root"
echo "DB_PASSWORD=password"
echo "QUEUE_FAILED_DRIVER=null"
echo "REDIS_PASSWORD="
echo "CACHE_DRIVER=redis"
echo "CACHE_STORE=redis"
} >> "$GITHUB_ENV"
- name: Create MySQL database
run: >-
mysql
-e 'SET GLOBAL innodb_flush_log_at_trx_commit=2; SET GLOBAL sync_binlog=0; CREATE DATABASE testbench'
-h"$DB_HOST" -uroot -ppassword -P "$DB_PORT"
- name: Run bounded MySQL smoke selection
id: pr_mysql_suite
run: |
mkdir -p build/test-results
cat build/pr-selection/summary.txt
set +e
# shellcheck disable=SC2016
timeout --foreground 8m bash -euo pipefail -c '
filter=$(cat build/pr-selection/mysql-fallback-filter.txt)
xargs -a build/pr-selection/mysql-fallback-files.txt \
vendor/bin/phpunit --testdox --testsuite feature \
--filter "$filter" \
--log-junit build/test-results/pr-smoke-fallback.xml
if [ -s build/pr-selection/mysql-changed-files.txt ]; then
xargs -a build/pr-selection/mysql-changed-files.txt \
vendor/bin/phpunit --testdox --testsuite feature \
--log-junit build/test-results/pr-smoke-changed.xml
fi
'
status=$?
set -e
for report in build/test-results/pr-smoke-*.xml; do
[ -f "$report" ] || continue
name=$(basename "$report" .xml)
php scripts/ci/summarize-junit-times.php \
--input="$report" \
--output="build/test-results/${name}-timing.md" \
--csv="build/test-results/${name}-timing.csv"
cat "build/test-results/${name}-timing.md"
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
cat "build/test-results/${name}-timing.md" >> "$GITHUB_STEP_SUMMARY"
fi
done
exit "$status"
env:
DB_CONNECTION: mysql
QUEUE_CONNECTION: redis
XDEBUG_MODE: off
- name: Upload pull-request MySQL smoke timing report
if: ${{ always() && github.server_url == 'https://github.com' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: pr-feature-timing-mysql
path: |
build/pr-selection/*
build/test-results/pr-smoke-*
- name: Upload laravel.log if pull-request MySQL smoke fails
if: ${{ github.server_url == 'https://github.com' && (failure() || steps.pr_mysql_suite.outcome == 'failure') }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: laravel-log-pr-mysql
path: vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
feature-mysql:
needs: preflight
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 18
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: password
# Keep disposable test data on tmpfs so schema setup and committed-row
# truncation are not gated by the container overlay's fsync latency.
options: >-
--tmpfs /var/lib/mysql:rw,noexec,nosuid,size=1024m
ports:
- 3306
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
- name: Set up PHP coverage driver
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
coverage: pcov
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Resolve service endpoints and export test defaults
env:
MYSQL_PUBLISHED_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
resolve_service() {
service="$1"
container_port="$2"
published_port="$3"
prefix="$4"
if getent hosts "$service" > /dev/null 2>&1; then
echo "${prefix}_HOST=${service}"
echo "${prefix}_PORT=${container_port}"
elif [ -n "$published_port" ]; then
echo "${prefix}_HOST=127.0.0.1"
echo "${prefix}_PORT=${published_port}"
else
echo "::error::Unable to resolve ${service} or determine its published port" >&2
exit 1
fi
}
{
resolve_service mysql 3306 "$MYSQL_PUBLISHED_PORT" DB
resolve_service redis 6379 "$REDIS_PUBLISHED_PORT" REDIS
echo "APP_KEY=base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI="
echo "DB_DATABASE=testbench"
echo "DB_USERNAME=root"
echo "DB_PASSWORD=password"
echo "QUEUE_FAILED_DRIVER=null"
echo "REDIS_PASSWORD="
# Testbench defaults cache to array (per-process, in-memory). The V2
# TaskWatchdog throttle set by Tests\TestCase::setUp needs to be
# visible to the two queue:work worker processes so their wake()
# poll short-circuits — array cache means the workers never see the
# test's throttle and runPass races the test's DB state (originally
# diagnosed as the #427 PG "hang" and the MySQL Mode-B flakes).
# The local docker stack uses tests/.env.feature which already sets
# CACHE_DRIVER=redis for the same reason; mirror it here.
echo "CACHE_DRIVER=redis"
echo "CACHE_STORE=redis"
} >> "$GITHUB_ENV"
- name: Create MySQL database
run: >-
mysql
-e 'SET GLOBAL innodb_flush_log_at_trx_commit=2; SET GLOBAL sync_binlog=0; SET GLOBAL max_connections=500; CREATE DATABASE testbench'
-h"$DB_HOST" -uroot -ppassword -P "$DB_PORT"
- name: Run feature test suite (MySQL shard ${{ matrix.shard }})
id: mysql_suite
timeout-minutes: 12
run: |
mkdir -p build/test-results
php scripts/ci/split-feature-tests.php \
--dir=tests/Feature \
--shard=${{ matrix.shard }} \
--shards=4 \
--weights=.github/feature-test-timings.json \
--weight-profile=mysql \
--summary="build/test-results/mysql-shard-${{ matrix.shard }}-summary.txt" \
> /tmp/mysql-shard-files
cat /tmp/mysql-shard-files
cp /tmp/mysql-shard-files "build/test-results/mysql-shard-${{ matrix.shard }}-files.txt"
started_at=$(date +%s)
set +e
timeout --foreground 12m xargs -a /tmp/mysql-shard-files \
vendor/bin/phpunit --testdox --testsuite feature \
--coverage-clover "build/test-results/mysql-shard-${{ matrix.shard }}-coverage.xml" \
--log-junit "build/test-results/mysql-shard-${{ matrix.shard }}.xml"
status=$?
elapsed=$(( $(date +%s) - started_at ))
set -e
printf 'mysql shard=%s exit=%s elapsed_seconds=%s\n' '${{ matrix.shard }}' "$status" "$elapsed" \
| tee "build/test-results/mysql-shard-${{ matrix.shard }}-elapsed.txt"
if [ -f "build/test-results/mysql-shard-${{ matrix.shard }}.xml" ]; then
php scripts/ci/summarize-junit-times.php \
--input="build/test-results/mysql-shard-${{ matrix.shard }}.xml" \
--output="build/test-results/mysql-shard-${{ matrix.shard }}-timing.md" \
--csv="build/test-results/mysql-shard-${{ matrix.shard }}-timing.csv"
fi
exit "$status"
env:
DB_CONNECTION: mysql
QUEUE_CONNECTION: redis
XDEBUG_MODE: off
- name: Emit MySQL shard diagnostics
if: ${{ always() }}
env:
SUITE_OUTCOME: ${{ steps.mysql_suite.outcome }}
run: |
cat "build/test-results/mysql-shard-${{ matrix.shard }}-elapsed.txt" 2>/dev/null || true
cat "build/test-results/mysql-shard-${{ matrix.shard }}-timing.md" 2>/dev/null || true
if [ "$SUITE_OUTCOME" != "success" ]; then
echo "MySQL shard ${{ matrix.shard }} failed; assigned files:"
cat "build/test-results/mysql-shard-${{ matrix.shard }}-files.txt" 2>/dev/null || true
tail -n 300 vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log 2>/dev/null || true
fi
- name: Upload MySQL feature timing report
if: ${{ always() && github.server_url == 'https://github.com' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: feature-timing-mysql-${{ matrix.shard }}
path: build/test-results/mysql-shard-${{ matrix.shard }}*
- name: Upload laravel.log if MySQL tests fail
if: ${{ github.server_url == 'https://github.com' && (failure() || steps.mysql_suite.outcome == 'failure') }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: laravel-log-mysql-${{ matrix.shard }}
path: vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
feature-postgresql:
needs: preflight
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3]
services:
postgres:
image: postgres
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: testbench
POSTGRES_INITDB_ARGS: --no-sync
ports:
- 5432
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Resolve service endpoints and export test defaults
env:
POSTGRES_PUBLISHED_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
resolve_service() {
service="$1"
container_port="$2"
published_port="$3"
prefix="$4"
if getent hosts "$service" > /dev/null 2>&1; then
echo "${prefix}_HOST=${service}"
echo "${prefix}_PORT=${container_port}"
elif [ -n "$published_port" ]; then
echo "${prefix}_HOST=127.0.0.1"
echo "${prefix}_PORT=${published_port}"
else
echo "::error::Unable to resolve ${service} or determine its published port" >&2
exit 1
fi
}
{
resolve_service postgres 5432 "$POSTGRES_PUBLISHED_PORT" DB
resolve_service redis 6379 "$REDIS_PUBLISHED_PORT" REDIS
echo "APP_KEY=base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI="
echo "DB_DATABASE=testbench"
echo "DB_USERNAME=root"
echo "DB_PASSWORD=password"
echo "QUEUE_FAILED_DRIVER=null"
echo "REDIS_PASSWORD="
# Testbench defaults cache to array (per-process, in-memory). The V2
# TaskWatchdog throttle set by Tests\TestCase::setUp needs to be
# visible to the two queue:work worker processes so their wake()
# poll short-circuits — array cache means the workers never see the
# test's throttle and runPass races the test's DB state (originally
# diagnosed as the #427 PG "hang" and the MySQL Mode-B flakes).
# The local docker stack uses tests/.env.feature which already sets
# CACHE_DRIVER=redis for the same reason; mirror it here.
echo "CACHE_DRIVER=redis"
echo "CACHE_STORE=redis"
} >> "$GITHUB_ENV"
- name: Run feature test suite (PostgreSQL shard ${{ matrix.shard }})
id: pgsql_suite
timeout-minutes: 12
run: |
mkdir -p build/test-results
php scripts/ci/split-feature-tests.php \
--dir=tests/Feature \
--shard=${{ matrix.shard }} \
--shards=4 \
--weights=.github/feature-test-timings.json \
--weight-profile=postgresql \
--summary="build/test-results/pgsql-shard-${{ matrix.shard }}-summary.txt" \
> /tmp/pgsql-shard-files
cat /tmp/pgsql-shard-files
cp /tmp/pgsql-shard-files "build/test-results/pgsql-shard-${{ matrix.shard }}-files.txt"
started_at=$(date +%s)
set +e
timeout --foreground 10m xargs -a /tmp/pgsql-shard-files \
vendor/bin/phpunit --testdox --testsuite feature \
--log-junit "build/test-results/pgsql-shard-${{ matrix.shard }}.xml"
status=$?
elapsed=$(( $(date +%s) - started_at ))
set -e
printf 'postgresql shard=%s exit=%s elapsed_seconds=%s\n' '${{ matrix.shard }}' "$status" "$elapsed" \
| tee "build/test-results/pgsql-shard-${{ matrix.shard }}-elapsed.txt"
if [ -f "build/test-results/pgsql-shard-${{ matrix.shard }}.xml" ]; then
php scripts/ci/summarize-junit-times.php \
--input="build/test-results/pgsql-shard-${{ matrix.shard }}.xml" \
--output="build/test-results/pgsql-shard-${{ matrix.shard }}-timing.md" \
--csv="build/test-results/pgsql-shard-${{ matrix.shard }}-timing.csv"
fi
exit "$status"
env:
DB_CONNECTION: pgsql
QUEUE_CONNECTION: redis
XDEBUG_MODE: off
# Safety net kept after #427: libpq honors PGOPTIONS on every
# connection, so any runaway query or lock wait fails loudly inside
# the bounded shard budget. The numbers are well above legitimate
# individual query cost but well below the step budget, so a future
# regression surfaces with the offending SQL in laravel.log rather
# than a silent hang.
PGOPTIONS: "-c synchronous_commit=off -c statement_timeout=120000 -c lock_timeout=30000 -c idle_in_transaction_session_timeout=60000"
- name: Emit PostgreSQL shard diagnostics
if: ${{ always() }}
env:
SUITE_OUTCOME: ${{ steps.pgsql_suite.outcome }}
run: |
cat "build/test-results/pgsql-shard-${{ matrix.shard }}-elapsed.txt" 2>/dev/null || true
cat "build/test-results/pgsql-shard-${{ matrix.shard }}-timing.md" 2>/dev/null || true
if [ "$SUITE_OUTCOME" != "success" ]; then
echo "PostgreSQL shard ${{ matrix.shard }} failed; assigned files:"
cat "build/test-results/pgsql-shard-${{ matrix.shard }}-files.txt" 2>/dev/null || true
tail -n 300 vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log 2>/dev/null || true
fi
- name: Upload PostgreSQL feature timing report
if: ${{ always() && github.server_url == 'https://github.com' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: feature-timing-postgresql-${{ matrix.shard }}
path: build/test-results/pgsql-shard-${{ matrix.shard }}*
- name: Upload laravel.log if PostgreSQL tests fail
if: ${{ github.server_url == 'https://github.com' && (failure() || steps.pgsql_suite.outcome == 'failure') }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: laravel-log-postgresql-${{ matrix.shard }}
path: vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
feature-mariadb:
needs: preflight
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.5
env:
MARIADB_ROOT_PASSWORD: password
MARIADB_DATABASE: testbench
options: >-
--health-cmd "mariadb-admin ping -ppassword"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 3306
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Resolve service endpoints and export test defaults
env:
MARIADB_PUBLISHED_PORT: ${{ job.services.mariadb.ports['3306'] }}
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
resolve_service() {
service="$1"
container_port="$2"
published_port="$3"
prefix="$4"
if getent hosts "$service" > /dev/null 2>&1; then
echo "${prefix}_HOST=${service}"
echo "${prefix}_PORT=${container_port}"
elif [ -n "$published_port" ]; then
echo "${prefix}_HOST=127.0.0.1"
echo "${prefix}_PORT=${published_port}"
else
echo "::error::Unable to resolve ${service} or determine its published port" >&2
exit 1
fi
}
{
resolve_service mariadb 3306 "$MARIADB_PUBLISHED_PORT" DB
resolve_service redis 6379 "$REDIS_PUBLISHED_PORT" REDIS
} >> "$GITHUB_ENV"
- name: Run locking, readiness and replay regressions on MariaDB 10.5
run: |
vendor/bin/phpunit --testdox --testsuite feature \
--filter '/(testHistoryPayloadPaginatedUsesConfiguredSummaryCountersWithoutHydratingHistory|testHistoryPayloadPaginatedUsesBoundedAggregatesWhenSummaryIsMissingOrStale|testEmbeddedHeartbeatAndTimeoutEnforcementUseOneConcurrentLockOrder)/' \
tests/Feature/V2/V2WorkflowTaskBridgeTest.php \
tests/Feature/V2/V2ActivityTimeoutTest.php
DB_CONNECTION=mariadb vendor/bin/phpunit --testdox --testsuite feature \
--filter '/(testSnapshotSummarizesDurableBacklogRepairCompatibilityAndWorkerFleet|testPublicReplayerCanReplayLiveRun|testPublicReplayerCanReplayHistoryExportBundle|testHistoryPayloadPaginatedUsesConfiguredSummaryCountersWithoutHydratingHistory|testHistoryPayloadPaginatedUsesBoundedAggregatesWhenSummaryIsMissingOrStale|testEmbeddedHeartbeatAndTimeoutEnforcementUseOneConcurrentLockOrder)/' \
tests/Feature/V2/V2OperatorMetricsTest.php \
tests/Feature/V2/V2WorkflowReplayerTest.php \
tests/Feature/V2/V2WorkflowTaskBridgeTest.php \
tests/Feature/V2/V2ActivityTimeoutTest.php
env:
APP_KEY: base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI=
DB_CONNECTION: mysql
DB_DATABASE: testbench
DB_USERNAME: root
DB_PASSWORD: password
CACHE_DRIVER: redis
CACHE_STORE: redis
QUEUE_CONNECTION: redis
QUEUE_FAILED_DRIVER: 'null'
REDIS_PASSWORD: ''
XDEBUG_MODE: off
- name: Upload Laravel log if MariaDB tests fail
if: ${{ github.server_url == 'https://github.com' && failure() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: laravel-log-mariadb
path: vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
coverage:
needs:
- preflight
- feature-mysql
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
env:
COVERAGE_BRANCH: ${{ github.head_ref || github.ref_name }}
COVERAGE_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
services:
redis:
image: redis
ports:
- 6379
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 10
persist-credentials: false
ref: ${{ env.COVERAGE_COMMIT }}
- name: Set up PHP coverage driver
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: '8.3'
coverage: pcov
- name: Cache Composer packages
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: vendor
key: ${{ github.event_name }}-${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ github.event_name }}-${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Download MySQL feature coverage
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: feature-timing-mysql-*
path: build/feature-coverage
merge-multiple: true
- name: Create SQLite database on fast temporary storage
run: |
if [ -d /dev/shm ] && [ -w /dev/shm ]; then
temporary_root=/dev/shm
else
temporary_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
fi
run_token="${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ATTEMPT:-1}"
coverage_db="${temporary_root}/workflow-coverage-${run_token}.sqlite"
touch "$coverage_db"
echo "COVERAGE_DB_PATH=$coverage_db" >> "$GITHUB_ENV"
echo "TMPDIR=$temporary_root" >> "$GITHUB_ENV"
- name: Resolve service endpoint and export coverage test defaults
env:
REDIS_PUBLISHED_PORT: ${{ job.services.redis.ports['6379'] }}
run: |
resolve_service() {
service="$1"
container_port="$2"
published_port="$3"
prefix="$4"
if getent hosts "$service" > /dev/null 2>&1; then
echo "${prefix}_HOST=${service}"
echo "${prefix}_PORT=${container_port}"
elif [ -n "$published_port" ]; then
echo "${prefix}_HOST=127.0.0.1"
echo "${prefix}_PORT=${published_port}"
else