Skip to content

Commit d3dde25

Browse files
committed
Add CI
1 parent caeaa03 commit d3dde25

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

.github/workflows/ci.yml

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