Skip to content

Commit ecd4539

Browse files
committed
Modernise CI
* Adds CI for MW 1.43 * Uses gesinn-it-pub/docker-compose-ci for CI * Runs linting, phpcs and more * Fixes some phpcs errors - although not all. Fixes #103
1 parent 0014bd9 commit ecd4539

27 files changed

+270
-346
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,107 +5,81 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ "*" ]
8+
workflow_dispatch:
89

910
jobs:
11+
1012
test:
11-
name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }} (TYPE ${{ matrix.type }})"
13+
14+
runs-on: ubuntu-latest
15+
continue-on-error: ${{ matrix.experimental }}
1216

1317
strategy:
1418
matrix:
1519
include:
16-
- mw: 'REL1_39'
17-
php: 7.4
18-
type: normal
19-
experimental: false
20-
- mw: 'REL1_39'
21-
php: 8.0
22-
type: coverage
20+
- mediawiki_version: '1.39'
21+
smw_version: dev-master
22+
php_version: 8.1
23+
database_type: mysql
24+
database_image: "mariadb:10"
25+
coverage: false
2326
experimental: false
24-
- mw: 'REL1_39'
25-
php: 8.1
26-
type: normal
27+
- mediawiki_version: '1.40'
28+
smw_version: dev-master
29+
php_version: 8.1
30+
database_type: mysql
31+
database_image: "mariadb:11.2"
32+
coverage: true
2733
experimental: false
28-
- mw: 'REL1_40'
29-
php: 8.1
30-
type: normal
34+
- mediawiki_version: '1.41'
35+
smw_version: dev-master
36+
php_version: 8.1
37+
database_type: mysql
38+
database_image: "mariadb:11.2"
39+
coverage: false
3140
experimental: false
32-
- mw: 'REL1_41'
33-
php: 8.1
34-
type: normal
41+
- mediawiki_version: '1.42'
42+
smw_version: dev-master
43+
php_version: 8.1
44+
database_type: mysql
45+
database_image: "mariadb:11.2"
46+
coverage: false
3547
experimental: false
36-
- mw: 'REL1_42'
37-
php: 8.2
38-
type: normal
48+
- mediawiki_version: '1.43'
49+
smw_version: dev-master
50+
php_version: 8.1
51+
database_type: mysql
52+
database_image: "mariadb:11.2"
53+
coverage: false
3954
experimental: false
40-
- mw: 'master'
41-
php: 8.3
42-
type: normal
43-
experimental: true
44-
45-
runs-on: ubuntu-latest
46-
continue-on-error: ${{ matrix.experimental }}
47-
48-
defaults:
49-
run:
50-
working-directory: mediawiki
5155

5256
env:
53-
MW_ROOT: mediawiki
54-
TYPE: ${{ matrix.type }}
55-
57+
MW_VERSION: ${{ matrix.mediawiki_version }}
58+
SMW_VERSION: ${{ matrix.smw_version }}
59+
PHP_VERSION: ${{ matrix.php_version }}
60+
DB_TYPE: ${{ matrix.database_type }}
61+
DB_IMAGE: ${{ matrix.database_image }}
5662

5763
steps:
58-
- name: Setup PHP
59-
uses: shivammathur/setup-php@v2
64+
- name: Checkout
65+
uses: actions/checkout@v4
6066
with:
61-
php-version: ${{ matrix.php }}
62-
extensions: mbstring, intl
63-
tools: composer
67+
submodules: recursive
6468

65-
- name: Cache MediaWiki
66-
id: cache-mediawiki
67-
uses: actions/cache@v4
68-
with:
69-
path: |
70-
mediawiki
71-
!mediawiki/extensions/
72-
!mediawiki/vendor/
73-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}
69+
- name: Update submodules
70+
run: git submodule update --init --remote
7471

75-
- name: Cache Composer cache
76-
uses: actions/cache@v4
77-
with:
78-
path: ~/.composer/cache
79-
key: composer-php${{ matrix.php }}
72+
- name: Run tests
73+
run: make ci
74+
if: matrix.coverage == false
8075

81-
- uses: actions/checkout@v4
82-
with:
83-
path: EarlyCopy
76+
- name: Run tests with coverage
77+
run: make ci-coverage
78+
if: matrix.coverage == true
8479

85-
- name: Install MediaWiki
86-
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
87-
working-directory: ~
88-
run: bash EarlyCopy/.github/workflows/installWiki.sh ${{ matrix.mw }} SemanticScribunto
89-
90-
- uses: actions/checkout@v4
80+
- name: Upload code coverage
81+
uses: codecov/codecov-action@v4
9182
with:
92-
path: mediawiki/extensions/SemanticScribunto
93-
94-
- name: Composer update
95-
run: composer update
96-
97-
- name: run update.php
98-
run: php maintenance/update.php --quick
99-
100-
- if: env.TYPE != 'coverage'
101-
name: Run PHPUnit w/o coverage
102-
run: php tests/phpunit/phpunit.php -c extensions/SemanticScribunto/ --testsuite semantic-scribunto-unit
103-
104-
- if: env.TYPE == 'coverage'
105-
name: Run PHPUnit w/ coverage
106-
run: php tests/phpunit/phpunit.php -c extensions/SemanticScribunto/ --testsuite semantic-scribunto-unit --coverage-clover coverage.clover
107-
108-
- if: env.TYPE == 'coverage'
109-
name: upload coverage report
110-
working-directory: ~
111-
run: bash EarlyCopy/.github/workflows/uploadCoverageReport.sh
83+
token: ${{ secrets.CODECOV_TOKEN }}
84+
files: coverage/php/coverage.xml
85+
if: matrix.coverage == true

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "build"]
2+
path = build
3+
url = https://github.com/gesinn-it-pub/docker-compose-ci.git

.phpcs.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
4+
<exclude name="Generic.Files.LineLength.TooLong" />
5+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
6+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
7+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
8+
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
9+
<exclude name="MediaWiki.Commenting.FunctionComment.NoParamType" />
10+
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
11+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
12+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
13+
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
14+
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
15+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
16+
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found" />
17+
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
18+
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
19+
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
20+
<exclude name="MediaWiki.PHPUnit.AssertEmpty.AssertEmptyUsed" />
21+
<exclude name="Squiz.Operators.ValidLogicalOperators.NotAllowed" />
22+
<exclude name="Generic.ControlStructures.DisallowYodaConditions.Found" />
23+
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
24+
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
25+
<exclude name="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix" />
26+
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
27+
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgContLang" />
28+
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
29+
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
30+
<exclude name="Universal.WhiteSpace.CommaSpacing" />
31+
<exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
32+
</rule>
33+
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
34+
<properties>
35+
<property name="allowedPrefixes" type="array" value="eg,wg" />
36+
</properties>
37+
</rule>
38+
<rule ref="MediaWiki.Commenting.FunctionComment.ObjectTypeHintReturn">
39+
<severity>0</severity>
40+
</rule>
41+
<file>.</file>
42+
<exclude-pattern>/(vendor|conf)/</exclude-pattern>
43+
<exclude-pattern type="relative">extensions/*</exclude-pattern>
44+
<arg name="extensions" value="php"/>
45+
<arg name="encoding" value="UTF-8"/>
46+
</ruleset>

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-include .env
2+
export
3+
4+
# setup for docker-compose-ci build directory
5+
# delete "build" directory to update docker-compose-ci
6+
7+
ifeq (,$(wildcard ./build/))
8+
$(shell git submodule update --init --remote)
9+
endif
10+
11+
EXTENSION=SemanticScribunto
12+
13+
# docker images
14+
MW_VERSION?=1.39
15+
PHP_VERSION?=8.1
16+
DB_TYPE?=mysql
17+
DB_IMAGE?="mariadb:10"
18+
19+
# extensions
20+
SMW_VERSION?=dev-master
21+
22+
# composer
23+
# Enables "composer update" inside of extension
24+
COMPOSER_EXT?=true
25+
26+
# nodejs
27+
# Enables node.js related tests and "npm install"
28+
# NODE_JS?=true
29+
30+
# check for build dir and git submodule init if it does not exist
31+
include build/Makefile
32+

build

Submodule build added at 10d5746

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fixes:
2+
- "/var/www/html/extensions/SemanticScribunto/::"

composer.json

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,52 @@
3131
"source": "https://github.com/SemanticMediaWiki/SemanticScribunto"
3232
},
3333
"require": {
34-
"php": ">=7.3",
35-
"composer/installers": "^2|^1.0.1",
36-
"mediawiki/semantic-media-wiki": "~4.0|~5.0"
34+
"php": ">=7.4",
35+
"composer/installers": "^2|^1.0.1"
3736
},
3837
"require-dev": {
39-
"mediawiki/semantic-media-wiki": "@dev",
40-
"squizlabs/php_codesniffer": "~3.10",
41-
"phpmd/phpmd": "~2.1"
38+
"mediawiki/mediawiki-codesniffer": "43.0.0",
39+
"mediawiki/minus-x": "1.1.3",
40+
"php-parallel-lint/php-console-highlighter": "1.0.0",
41+
"php-parallel-lint/php-parallel-lint": "1.4.0"
4242
},
4343
"extra": {
4444
"branch-alias": {
4545
"dev-master": "2.4.0-dev"
4646
}
4747
},
4848
"config": {
49-
"process-timeout": 0
49+
"process-timeout": 0,
50+
"allow-plugins": {
51+
"composer/installers": true,
52+
"dealerdirect/phpcodesniffer-composer-installer": true
53+
}
5054
},
5155
"scripts":{
52-
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
53-
"test": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
56+
"test": [
57+
"@analyze",
58+
"@phpunit"
59+
],
60+
"test-coverage": [
61+
"@analyze",
62+
"@phpunit-coverage"
63+
],
64+
"analyze": [
65+
"@lint",
66+
"@phpcs",
67+
"@minus-x"
68+
],
69+
"phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist",
70+
"phpunit-coverage": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml",
5471
"unit": "composer phpunit -- --testsuite semantic-scribunto-unit",
5572
"integration": "composer phpunit -- --testsuite semantic-scribunto-integration",
56-
"cs": [
57-
"vendor/bin/phpcs src/* tests/* --standard=phpcs.xml --extensions=php -sp",
58-
"vendor/bin/phpmd src/,tests/ text phpmd.xml"
73+
"post-test-coverage": [
74+
"sed -i 's|/var/www/html/extensions/SemanticScribunto/||g' coverage/php/coverage.xml",
75+
"find coverage/php -type f -name '*.html' -exec sed -i 's|/var/www/html/extensions/||g' {} +"
5976
],
60-
"ci": [
61-
"composer validate --no-interaction",
62-
"composer phpunit",
63-
"composer cs"
64-
]
77+
"phpcs": "phpcs -ps -d memory_limit=2G",
78+
"phpcs-fix": "phpcbf -p",
79+
"lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions",
80+
"minus-x": "minus-x check ."
6581
}
6682
}

0 commit comments

Comments
 (0)