-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
186 lines (182 loc) · 7.12 KB
/
Copy pathtests.yml
File metadata and controls
186 lines (182 loc) · 7.12 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
name: tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.5, 8.4, 8.3]
laravel: [13.*, 12.*, 11.*]
db: [sqlite]
dependency-version: [prefer-stable]
include:
- laravel: 13.*
testbench: 11.*
- laravel: 12.*
testbench: 10.*
- laravel: 11.*
testbench: 9.*
- php: 8.5
laravel: 13.*
testbench: 11.*
db: mysql
dependency-version: prefer-stable
- php: 8.5
laravel: 13.*
testbench: 11.*
db: pgsql
dependency-version: prefer-stable
- php: 8.5
laravel: 12.*
testbench: 10.*
db: mysql
dependency-version: prefer-stable
- php: 8.5
laravel: 12.*
testbench: 10.*
db: pgsql
dependency-version: prefer-stable
- php: 8.4
laravel: 11.*
testbench: 9.*
db: mysql
dependency-version: prefer-stable
- php: 8.4
laravel: 11.*
testbench: 9.*
db: pgsql
dependency-version: prefer-stable
exclude:
- laravel: 11.*
php: 8.5
name: P${{ matrix.php }} - L${{ matrix.laravel }} - DB:${{ matrix.db }}
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testing
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: testing
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Cache Composer dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.composer/cache/files
key: composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-${{ matrix.php }}-${{ matrix.laravel }}-
composer-${{ matrix.php }}-
- name: Set up PHP
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, pdo_pgsql
coverage: none
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/*
cache: npm
- name: Install npm dependencies
run: npm ci --ignore-scripts
- name: Install Chromium system dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libnss3 libatk-bridge2.0-0 libdrm2 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2t64
- name: Cache Playwright Chromium
id: playwright-cache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/ms-playwright
key: playwright-chromium-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install Playwright Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: npx playwright install chromium
- name: Wait for MySQL
if: matrix.db == 'mysql'
run: |
for i in {1..60}; do
nc -z 127.0.0.1 3306 && echo "MySQL is up" && exit 0
echo "Waiting for MySQL ($i) ..." && sleep 2
done
echo "MySQL did not become ready in time" && exit 1
- name: Wait for Postgres
if: matrix.db == 'pgsql'
run: |
for i in {1..60}; do
nc -z 127.0.0.1 5432 && echo "Postgres is up" && exit 0
echo "Waiting for Postgres ($i) ..." && sleep 2
done
echo "Postgres did not become ready in time" && exit 1
- name: Cache Blade views
run: ./vendor/bin/testbench view:cache
- name: Execute tests (parallel)
id: parallel-tests
continue-on-error: true
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --parallel --exclude-group=commands
env:
DB_PASSWORD: password
- name: Retry tests (parallel, attempt 2)
if: steps.parallel-tests.outcome == 'failure'
id: parallel-retry-2
continue-on-error: true
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --parallel --bail --exclude-group=commands
env:
DB_PASSWORD: password
- name: Retry tests (parallel, attempt 3)
if: steps.parallel-retry-2.outcome == 'failure'
id: parallel-retry-3
continue-on-error: true
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --parallel --bail --exclude-group=commands
env:
DB_PASSWORD: password
- name: Retry tests (parallel, attempt 4)
if: steps.parallel-retry-3.outcome == 'failure'
id: parallel-retry-4
continue-on-error: true
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --parallel --bail --exclude-group=commands
env:
DB_PASSWORD: password
- name: Retry tests (parallel, attempt 5)
if: steps.parallel-retry-4.outcome == 'failure'
id: parallel-retry-5
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --parallel --bail --exclude-group=commands
env:
DB_PASSWORD: password
- name: Warn about flaky tests
if: steps.parallel-tests.outcome == 'failure' && (steps.parallel-retry-2.outcome == 'success' || steps.parallel-retry-3.outcome == 'success' || steps.parallel-retry-4.outcome == 'success' || steps.parallel-retry-5.outcome == 'success')
run: |
echo "::warning::Parallel tests failed but a retry passed. This may indicate a race condition or test isolation issue."
- name: Execute command tests (serial)
run: ./vendor/bin/pest --configuration=phpunit.${{ matrix.db }}.xml --group=commands
env:
DB_PASSWORD: password