Skip to content

Commit 6163295

Browse files
authored
Update CI and fix various issues (#39)
* Set up PHPStan and phpcs * Fix all phpcs issues * Drop support for MW 1.34 * Bump MW and PHP requirements to 1.39 and 7.4 respectively * Fix various CI issues * Update GitHub CI versions * Add phpstan and phpcs to GitHub CI * Code review from CodeRabbit
1 parent 088f40e commit 6163295

21 files changed

+356
-150
lines changed

.github/workflows/ci.yml

Lines changed: 140 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,30 @@ on:
1212
jobs:
1313
test:
1414
name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}"
15+
continue-on-error: ${{ matrix.experimental }}
1516

1617
strategy:
18+
fail-fast: false
1719
matrix:
1820
include:
19-
- mw: 'REL1_43'
20-
php: 8.3
21-
- mw: 'REL1_42'
22-
php: 8.2
23-
- mw: 'REL1_41'
24-
php: 8.1
25-
- mw: 'REL1_40'
26-
php: 8.0
2721
- mw: 'REL1_39'
2822
php: 8.0
29-
composer: v2
30-
- mw: 'REL1_38'
31-
php: 8.0
32-
composer: v2
33-
- mw: 'REL1_37'
34-
php: 8.0
35-
composer: v2
36-
- mw: 'REL1_36'
37-
php: 7.4
38-
composer: v1
39-
- mw: 'REL1_35'
40-
php: 7.3
41-
composer: v1
42-
- mw: 'REL1_34'
43-
php: 7.2
44-
composer: v1
23+
experimental: false
24+
- mw: 'REL1_40'
25+
php: 8.1
26+
experimental: false
27+
- mw: 'REL1_41'
28+
php: 8.2
29+
experimental: false
30+
- mw: 'REL1_42'
31+
php: 8.2
32+
experimental: false
33+
- mw: 'REL1_43'
34+
php: 8.3
35+
experimental: false
36+
- mw: 'master'
37+
php: 8.4
38+
experimental: true
4539

4640
runs-on: ubuntu-latest
4741

@@ -56,25 +50,25 @@ jobs:
5650
with:
5751
php-version: ${{ matrix.php }}
5852
extensions: mbstring, intl
59-
tools: composer:${{ matrix.composer }}
53+
tools: composer:v2
6054

6155
- name: Cache MediaWiki
6256
id: cache-mediawiki
63-
uses: actions/cache@v2
57+
uses: actions/cache@v4
6458
with:
6559
path: |
6660
mediawiki
6761
!mediawiki/extensions/
6862
!mediawiki/vendor/
69-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}-v21
63+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v1
7064

7165
- name: Cache Composer cache
72-
uses: actions/cache@v2
66+
uses: actions/cache@v4
7367
with:
7468
path: ~/.composer/cache
7569
key: composer-php${{ matrix.php }}
7670

77-
- uses: actions/checkout@v2
71+
- uses: actions/checkout@v4
7872
with:
7973
path: EarlyCopy
8074

@@ -83,7 +77,7 @@ jobs:
8377
working-directory: ~
8478
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} WikibaseLocalMedia
8579

86-
- uses: actions/checkout@v2
80+
- uses: actions/checkout@v4
8781
with:
8882
path: mediawiki/extensions/WikibaseLocalMedia
8983

@@ -92,3 +86,119 @@ jobs:
9286

9387
- name: Run PHPUnit
9488
run: php tests/phpunit/phpunit.php extensions/WikibaseLocalMedia/tests/
89+
90+
PHPStan:
91+
name: "PHPStan: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}"
92+
93+
strategy:
94+
matrix:
95+
include:
96+
- mw: 'REL1_43'
97+
php: '8.3'
98+
99+
runs-on: ubuntu-latest
100+
101+
defaults:
102+
run:
103+
working-directory: mediawiki
104+
105+
steps:
106+
- name: Setup PHP
107+
uses: shivammathur/setup-php@v2
108+
with:
109+
php-version: ${{ matrix.php }}
110+
extensions: mbstring
111+
tools: composer, cs2pr
112+
113+
- name: Cache MediaWiki
114+
id: cache-mediawiki
115+
uses: actions/cache@v4
116+
with:
117+
path: |
118+
mediawiki
119+
mediawiki/extensions/
120+
mediawiki/vendor/
121+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v1
122+
123+
- name: Cache Composer cache
124+
uses: actions/cache@v4
125+
with:
126+
path: ~/.composer/cache
127+
key: composer_static_analysis
128+
129+
- uses: actions/checkout@v4
130+
with:
131+
path: EarlyCopy
132+
133+
- name: Install MediaWiki
134+
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
135+
working-directory: ~
136+
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} WikibaseLocalMedia
137+
138+
- uses: actions/checkout@v4
139+
with:
140+
path: mediawiki/extensions/WikibaseLocalMedia
141+
142+
- name: Composer allow-plugins
143+
run: composer config --no-plugins allow-plugins.composer/installers true
144+
145+
- run: composer update
146+
147+
- name: Composer install
148+
run: cd extensions/WikibaseLocalMedia && composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
149+
150+
- name: PHPStan
151+
run: cd extensions/WikibaseLocalMedia && php vendor/bin/phpstan analyse --error-format=checkstyle --no-progress | cs2pr
152+
153+
phpcs:
154+
name: "Code style: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}"
155+
156+
strategy:
157+
matrix:
158+
include:
159+
- mw: 'REL1_43'
160+
php: '8.3'
161+
162+
runs-on: ubuntu-latest
163+
164+
defaults:
165+
run:
166+
working-directory: mediawiki/extensions/WikibaseLocalMedia
167+
168+
steps:
169+
- name: Setup PHP
170+
uses: shivammathur/setup-php@v2
171+
with:
172+
php-version: ${{ matrix.php }}
173+
extensions: mbstring, intl, php-ast
174+
tools: composer
175+
176+
- name: Cache MediaWiki
177+
id: cache-mediawiki
178+
uses: actions/cache@v4
179+
with:
180+
path: |
181+
mediawiki
182+
!mediawiki/extensions/
183+
!mediawiki/vendor/
184+
key: mw_static_analysis
185+
186+
- name: Cache Composer cache
187+
uses: actions/cache@v4
188+
with:
189+
path: ~/.composer/cache
190+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v1
191+
192+
- name: Install MediaWiki
193+
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
194+
working-directory: ~
195+
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} WikibaseLocalMedia
196+
197+
- uses: actions/checkout@v4
198+
with:
199+
path: mediawiki/extensions/WikibaseLocalMedia
200+
201+
- name: Composer install
202+
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
203+
204+
- run: vendor/bin/phpcs -p -s

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Commands run from inside the MediaWiki container ##########################################################
2+
3+
ci: test cs
4+
test: phpunit
5+
cs: phpcs stan
6+
7+
phpunit:
8+
ifdef filter
9+
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --filter $(filter)
10+
else
11+
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist
12+
endif
13+
14+
perf:
15+
php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --group Performance
16+
17+
phpcs:
18+
vendor/bin/phpcs -p -s --standard=$(shell pwd)/phpcs.xml
19+
20+
stan:
21+
vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=2G
22+
23+
stan-baseline:
24+
vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=2G --generate-baseline
25+
26+
27+
28+
# Commands run from the host machine #######################################################################
29+
30+
npm-install:
31+
docker run -it --rm -v "$(CURDIR)":/home/node/app -w /home/node/app -u node node:22 npm install
32+
33+
lint:
34+
docker run -it --rm -v "$(CURDIR)":/home/node/app -w /home/node/app -u node node:22 npm run lint

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Also see [this animated gif](https://twitter.com/i/status/1286293710112731137).
2222

2323
## Platform requirements
2424

25-
* [PHP] 7.2 or later, including PHP 8.0
26-
* [MediaWiki] 1.34 up to 1.39
27-
* [Wikibase Repository] REL1_34, REL1_35, REL1_36, REL1_37, REL1_38, or REL1_39
25+
* [PHP] 7.4 or later
26+
* [MediaWiki] 1.39 or later
27+
* [Wikibase Repository] REL1_39 or later
2828

2929
For more information on the different versions of this extension, see the [release notes](#release-notes).
3030

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@
4444
"source": "https://github.com/ProfessionalWiki/WikibaseLocalMedia/issues"
4545
},
4646
"require": {
47-
"php": ">=7.2",
47+
"php": ">=7.4",
4848
"composer/installers": "^2|^1.0.1"
4949
},
5050
"require-dev": {
51-
"vimeo/psalm": "dev-master",
52-
"phpstan/phpstan": "dev-master"
51+
"phpstan/phpstan": "^2.1.6",
52+
"mediawiki/mediawiki-codesniffer": "^46.0.0"
5353
},
5454
"config": {
5555
"allow-plugins": {
56-
"composer/installers": true
56+
"composer/installers": true,
57+
"dealerdirect/phpcodesniffer-composer-installer": true
5758
}
5859
}
5960
}

extension.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Wikibase Local Media",
33
"type": "wikibase",
44

5-
"version": "1.1.0",
5+
"version": "2.0.0",
66

77
"author": [
88
"[https://www.EntropyWins.wtf/mediawiki Jeroen De Dauw]",
@@ -16,7 +16,7 @@
1616
"license-name": "GPL-2.0-or-later",
1717

1818
"requires": {
19-
"MediaWiki": ">= 1.34.0",
19+
"MediaWiki": ">= 1.39.0",
2020
"extensions": {
2121
"WikibaseRepository": "*"
2222
}

phpcs.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<file>src/</file>
4+
<file>tests/php</file>
5+
6+
<arg name="extensions" value="php"/>
7+
8+
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" />
9+
</ruleset>

0 commit comments

Comments
 (0)