Skip to content

Commit 55365bb

Browse files
committed
Add CI
1 parent caeaa03 commit 55365bb

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

.github/workflows/ci.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Continuous Integration
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
env:
13+
EXTNAME: CrawlerProtection
14+
MW_INSTALL_PATH: ${{ github.workspace }}
15+
16+
jobs:
17+
style:
18+
name: Code Style
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ ubuntu-latest ]
24+
php: [ '8.2', '8.3', '8.4' ]
25+
mediawiki: [ REL1_43 ]
26+
include:
27+
- os: ubuntu-latest
28+
php: '7.4'
29+
mediawiki: REL1_35
30+
- os: ubuntu-latest
31+
php: '7.4'
32+
mediawiki: REL1_39
33+
- os: ubuntu-latest
34+
php: '8.2'
35+
mediawiki: REL1_39
36+
steps:
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php }}
41+
extensions: mbstring, intl
42+
coverage: none
43+
tools: composer
44+
- name: Setup MediaWiki
45+
uses: actions/checkout@v4
46+
with:
47+
repository: wikimedia/mediawiki
48+
ref: ${{ matrix.mediawiki }}
49+
- name: Setup Extension
50+
uses: actions/checkout@v4
51+
with:
52+
path: extensions/${{ env.EXTNAME }}
53+
- name: Setup Composer
54+
run: |
55+
echo '{"extra":{"merge-plugin":{"include":["extensions/*/composer.json","skins/*/composer.json"]}}}' > composer.local.json
56+
composer update
57+
composer update
58+
- name: Lint
59+
run: ./vendor/bin/parallel-lint --exclude node_modules --exclude vendor extensions/${{ env.EXTNAME }}
60+
- name: PHP Code Sniffer
61+
run: ./vendor/bin/phpcs -sp --standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki extensions/${{ env.EXTNAME }}
62+
63+
security:
64+
name: Static Analysis
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
os: [ ubuntu-latest ]
70+
# 1.43 phan is broken on php 8.4
71+
php: [ '8.2', '8.3' ]
72+
mediawiki: [ REL1_43 ]
73+
include:
74+
- os: ubuntu-latest
75+
php: '7.4'
76+
mediawiki: REL1_35
77+
- os: ubuntu-latest
78+
php: '7.4'
79+
mediawiki: REL1_39
80+
- os: ubuntu-latest
81+
php: '8.2'
82+
mediawiki: REL1_39
83+
steps:
84+
- name: Setup PHP
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: ${{ matrix.php }}
88+
extensions: mbstring, intl, ast
89+
coverage: none
90+
tools: composer
91+
- name: Setup MediaWiki
92+
uses: actions/checkout@v4
93+
with:
94+
repository: wikimedia/mediawiki
95+
ref: ${{ matrix.mediawiki }}
96+
- name: Setup Extension
97+
uses: actions/checkout@v4
98+
with:
99+
path: extensions/${{ env.EXTNAME }}
100+
- name: Setup Composer
101+
run: |
102+
echo '{"extra":{"merge-plugin":{"include":["extensions/*/composer.json","skins/*/composer.json"]}}}' > composer.local.json
103+
composer update
104+
composer update
105+
- name: Phan
106+
run: ./vendor/bin/phan -d extensions/${{ env.EXTNAME }} --minimum-target-php-version=7.4 --long-progress-bar
107+
phpunit:
108+
name: Unit Tests
109+
runs-on: ${{ matrix.os }}
110+
strategy:
111+
fail-fast: false
112+
matrix:
113+
os: [ ubuntu-latest ]
114+
php: [ '8.2', '8.3', '8.4' ]
115+
mediawiki: [ REL1_43 ]
116+
include:
117+
- os: ubuntu-latest
118+
php: '7.4'
119+
mediawiki: REL1_35
120+
- os: ubuntu-latest
121+
php: '7.4'
122+
mediawiki: REL1_39
123+
- os: ubuntu-latest
124+
php: '8.2'
125+
mediawiki: REL1_39
126+
steps:
127+
- name: Setup PHP
128+
uses: shivammathur/setup-php@v2
129+
with:
130+
php-version: ${{ matrix.php }}
131+
extensions: mbstring, intl, ast
132+
coverage: none
133+
tools: composer
134+
- name: Setup MediaWiki
135+
uses: actions/checkout@v4
136+
with:
137+
repository: wikimedia/mediawiki
138+
ref: ${{ matrix.mediawiki }}
139+
- name: Setup Extension
140+
uses: actions/checkout@v4
141+
with:
142+
path: extensions/${{ env.EXTNAME }}
143+
- name: Setup Composer
144+
run: |
145+
echo '{"extra":{"merge-plugin":{"include":["extensions/*/composer.json","skins/*/composer.json"]}}}' > composer.local.json
146+
composer update
147+
composer update
148+
- name: Install MediaWiki
149+
run: php maintenance/install.php --dbtype=sqlite --with-extensions --pass=UnitTestingAdminPassword519 UnitTesting WikiAdmin
150+
- name: Phpunit
151+
run: ./vendor/bin/phpunit -- extensions/${{ env.EXTNAME }}/tests/phpunit

.phan/config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
// use phan config shipped with mediawiki core
4+
$cfg = require __DIR__ . '/../../../vendor/mediawiki/mediawiki-phan-config/src/config.php';
5+
6+
// we suppress things for backwards compat reasons, so suppressions may not apply to all phan test runs
7+
// as part of dropping support for old versions, old suppressions will be removed
8+
$cfg['suppress_issue_types'][] = 'UnusedSuppression';
9+
$cfg['suppress_issue_types'][] = 'UnusedPluginSuppression';
10+
11+
return $cfg;

0 commit comments

Comments
 (0)