Skip to content

Commit 9757f66

Browse files
committed
Add phpstan and phpcs to GitHub CI
1 parent a3493a2 commit 9757f66

File tree

1 file changed

+117
-1
lines changed

1 file changed

+117
-1
lines changed

.github/workflows/ci.yml

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
mediawiki
6161
!mediawiki/extensions/
6262
!mediawiki/vendor/
63-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}-v22
63+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v1
6464

6565
- name: Cache Composer cache
6666
uses: actions/cache@v4
@@ -86,3 +86,119 @@ jobs:
8686

8787
- name: Run PHPUnit
8888
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: curl EarlyCopy/.github/workflows/installMediaWiki.sh | bash -s ${{ 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

0 commit comments

Comments
 (0)