-
Notifications
You must be signed in to change notification settings - Fork 705
254 lines (218 loc) · 7.89 KB
/
Copy pathlaravel-ci.yml
File metadata and controls
254 lines (218 loc) · 7.89 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
name: 'ci / Laravel'
on:
workflow_dispatch:
push:
branches:
- main
- 6.x
pull_request:
concurrency:
group: laravel-ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
pint:
name: 'Code Quality / Pint'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: json, dom, curl, libxml, mbstring
tools: composer:v2, laravel/pint
coverage: none
- name: Run Pint
run: pint --parallel --test --verbose
rector:
name: 'Code Quality / Rector'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPOSER_AUTH_JSON: |
{
"http-basic": {
"repo.packagist.com": {
"username": "${{ secrets.packagist_username }}",
"password": "${{ secrets.packagist_token }}"
}
}
}
- name: Set version
run: composer config version "6.x-dev"
- name: Install dependencies
uses: ramsey/composer-install@v3
- name: Rector Cache
uses: actions/cache@v4
with:
path: /tmp/rector
key: ${{ runner.os }}-rector-${{ github.run_id }}
restore-keys: ${{ runner.os }}-rector-
- run: mkdir -p /tmp/rector
- name: Run Rector
run: vendor/bin/rector process --dry-run --ansi
phpstan:
name: 'Code Quality / Phpstan'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
tools: composer:v2
coverage: none
- name: Set version
run: composer config version "6.x-dev"
- name: Install composer dependencies
uses: ramsey/composer-install@v3
- name: PHPStan Cache
uses: actions/cache@v4
with:
path: /tmp/phpstan
key: ${{ runner.os }}-phpstan-${{ github.run_id }}
restore-keys: ${{ runner.os }}-phpstan-
- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
unit-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Unit on ${{ matrix.os }}'
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
# ComponentManifestDriftTest needs the Custom Elements Manifest, which is
# gitignored (packages/craftcms-ui/dist). The cache key hashes everything
# the analyzer reads, so a hit is never stale; the cache itself is shared
# repo-wide, so whichever workflow generates it first serves the rest. On
# a miss the pinned npx run (~seconds) needs no npm install.
- name: Restore Custom Elements Manifest
id: cem
uses: actions/cache@v4
with:
path: packages/craftcms-ui/dist/custom-elements.json
key: cem-${{ hashFiles('packages/craftcms-ui/src/components/**', 'packages/craftcms-ui/custom-elements-manifest.config.mjs', 'packages/craftcms-ui/package.json', 'packages/craftcms-ui/tsconfig.json') }}
- name: Generate Custom Elements Manifest
if: steps.cem.outputs.cache-hit != 'true'
working-directory: packages/craftcms-ui
run: npx --yes @custom-elements-manifest/analyzer@0.11.0 analyze
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: ./vendor/bin/pest --ci --compact --testsuite=Unit
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
arch-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Arch'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: ./vendor/bin/pest --ci --testsuite=Arch
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
feature-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Feature on ${{ matrix.os }} with ${{ matrix.db }}'
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.5]
db: [mysql, pgsql, sqlite]
exclude:
# Service containers (mysql/pgsql) are only supported on Linux runners.
- os: windows-latest
db: mysql
- os: windows-latest
db: pgsql
services:
pgsql:
image: ${{ (matrix.os == 'ubuntu-latest' && matrix.db == 'pgsql') && 'postgres:latest' || '' }}
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_DB: craft_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mysql:
image: ${{ (matrix.os == 'ubuntu-latest' && matrix.db == 'mysql') && 'mysql:8.0' || '' }}
env:
MYSQL_ROOT_PASSWORD: mysecretpassword
MYSQL_DATABASE: craft_test
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install libvips
if: matrix.os == 'ubuntu-latest' && matrix.db == 'sqlite'
run: sudo apt-get update && sudo apt-get install -y libvips-dev
- name: Copy tests .env
shell: bash
run: |
cp ./tests/.env.example.${{ matrix.db }} ./tests/.env
sed -i 's/DB_PASSWORD=/DB_PASSWORD=mysecretpassword/' tests/.env
touch database/craft_tests.sqlite
- name: Run tests
uses: ./.github/actions/run-tests
env:
CRAFT_REQUIRE_VIPS: ${{ matrix.os == 'ubuntu-latest' && matrix.db == 'sqlite' && '1' || '' }}
with:
test-command: ./vendor/bin/pest --ci --compact --testsuite=Feature
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
yii2-adapter-tests:
needs: [pint, phpstan, rector]
name: 'Tests / Yii2 Adapter'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
uses: ./.github/actions/run-tests
with:
test-command: yii2-adapter/vendor/bin/pest --ci --compact --configuration ./yii2-adapter/phpunit.xml.dist --test-directory ./tests-laravel
github-token: ${{ secrets.GITHUB_TOKEN }}
packagist-username: ${{ secrets.packagist_username }}
packagist-token: ${{ secrets.packagist_token }}
working-directory: yii2-adapter