-
-
Notifications
You must be signed in to change notification settings - Fork 78
247 lines (244 loc) · 8.97 KB
/
php.yml
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
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: 0 0 * * *
jobs:
lint:
runs-on: "ubuntu-latest"
name: "Linting | PHP ${{ matrix.php-version }}"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, gd
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
- name: "PHPCS"
run: "php vendor/bin/phpcs"
- name: "PHPStan"
run: "php vendor/bin/phpstan analyze"
tests:
continue-on-error: ${{ matrix.experimental }}
runs-on: "ubuntu-latest"
name: "Tests | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
matrix:
experimental: [false]
php-version:
- "8.1"
- "8.2"
- "8.3"
drupal:
- "^10"
include:
- php-version: "8.3"
drupal: "11.x-dev"
experimental: true
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "xdebug"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, gd
- name: "Set drupal/core to ${{ matrix.drupal }}"
run: "composer require drupal/core-recommended:${{ matrix.drupal }} --with-all-dependencies --dev --no-update"
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
- name: "PHPUnit"
run: "php vendor/bin/phpunit"
build_integration:
needs:
- lint
- tests
continue-on-error: ${{ matrix.experimental }}
runs-on: "ubuntu-latest"
name: "Build Integration | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
matrix:
experimental: [false]
php-version:
- "8.1"
- "8.2"
drupal:
- "^10"
include:
- php-version: "8.3"
drupal: "11.x-dev"
experimental: true
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv
- name: Setup Drupal
uses: bluehorndigital/[email protected]
with:
version: ${{ matrix.drupal }}
path: ~/drupal
- name: "set the version alias for self"
run: |
if [ "${{ github.event_name }}" == 'pull_request' ]; then
echo "VERSION_ALIAS=dev-"${{ github.sha }}"" >> $GITHUB_OUTPUT
else
echo "VERSION_ALIAS=dev-main" >> $GITHUB_OUTPUT
fi
id: branch_alias
- name: "require phpstan-drupal"
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require drupal/core-dev "phpstan/phpstan:^2.0" "phpstan/phpstan-phpunit:^2.0" mglaman/phpstan-drupal "${{ steps.branch_alias.outputs.VERSION_ALIAS }} as 2.99.99" phpstan/extension-installer --with-all-dependencies
cp $GITHUB_WORKSPACE/tests/fixtures/config/drupal-phpstan.neon phpstan.neon
- name: "Test core/install.php"
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/install.php --debug
- name: "Test BrowserTestBase is autoloaded"
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache | grep -q "Class Drupal\Tests\BrowserTestBase not found and could not be autoloaded." && false || true
- name: "Verify test fixtures are ignored."
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/modules/migrate_drupal --no-progress | grep -q "tests/fixtures" && false || true
- name: 'Check "Cannot redeclare token_theme() due to blazy_test.module"'
if: ${{ matrix.drupal != '11.x-dev' }}
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require drupal/token drupal/blazy
./vendor/bin/phpstan analyze web/modules/contrib/blazy --no-progress || if (($? == 255)); then false; else true; fi
COMPOSER_MEMORY_LIMIT=-1 composer remove drupal/token drupal/blazy
- name: 'Check "Cannot redeclare video_embed_media_media_bundle_insert()"'
if: ${{ matrix.drupal != '11.x-dev' }}
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require drupal/video_embed_field drupal/slick
./vendor/bin/phpstan analyze web/modules/contrib --no-progress || if (($? == 255)); then false; else true; fi
COMPOSER_MEMORY_LIMIT=-1 composer remove drupal/video_embed_field drupal/slick
build_integration_no_phpunit:
needs:
- lint
- tests
continue-on-error: ${{ matrix.experimental }}
runs-on: "ubuntu-latest"
name: "Build Integration (No PHPUnit) | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
matrix:
experimental: [false]
php-version:
- "8.1"
- "8.2"
drupal:
- "^10"
include:
- php-version: "8.3"
drupal: "11.x-dev"
experimental: true
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv
- name: Setup Drupal
uses: bluehorndigital/[email protected]
with:
version: ${{ matrix.drupal }}
path: ~/drupal
- name: "Remove PHPUnit"
run: |
cd ~/drupal
composer --dev remove phpspec/prophecy-phpunit drupal/core-dev
- name: "require phpstan-drupal"
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require mglaman/phpstan-drupal *@dev
cp $GITHUB_WORKSPACE/tests/fixtures/config/drupal-no-dev-phpstan.neon phpstan.neon
- name: "Test core/install.php"
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/install.php --debug
- name: "Test no crash"
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache --debug
core_baseline:
needs:
- lint
- tests
continue-on-error: true
runs-on: "ubuntu-latest"
name: "Drupal core HEAD baseline check"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "set the version alias for self"
run: |
if [ "${{ github.event_name }}" == 'pull_request' ]; then
echo "VERSION_ALIAS=dev-"${{ github.sha }}"" >> $GITHUB_OUTPUT
else
echo "VERSION_ALIAS=dev-main" >> $GITHUB_OUTPUT
fi
id: branch_alias
- name: determine phpstan cache directory
run: echo PHPSTAN_TMP_DIR=$(php -r "print sys_get_temp_dir() . '/phpstan';") >> $GITHUB_OUTPUT
id: phpstan_tmp_dir
- name: cache phpstan
uses: actions/cache@v4
with:
path: ${{ steps.phpstan_tmp_dir.outputs.PHPSTAN_TMP_DIR }}
key: ${{ runner.os }}-phpstan-core-baseline
restore-keys: ${{ runner.os }}-phpstan-core-baseline
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: composer:v2
extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, gd, apcu
- name: "Checkout Drupal core"
run: |
cd ${{ runner.temp }}
git clone https://git.drupalcode.org/project/drupal.git
cd drupal
composer config repositories.0 composer https://packages.drupal.org/8
composer config repositories.1 path $GITHUB_WORKSPACE
- name: "Install Drupal core dependencies"
uses: "ramsey/composer-install@v3"
with:
working-directory: "${{ runner.temp }}/drupal"
- name: "require phpstan-drupal"
run: |
cd ${{ runner.temp }}/drupal
composer require drupal/core-dev "phpstan/phpstan:^2.0" "phpstan/phpstan-phpunit:^2.0" mglaman/phpstan-drupal "${{ steps.branch_alias.outputs.VERSION_ALIAS }} as 2.99.99" phpstan/extension-installer --with-all-dependencies
- name: "Check baseline"
run: |
cd ${{ runner.temp }}/drupal
./vendor/bin/phpstan analyze --configuration=core/phpstan.neon.dist