Skip to content

Commit 6725195

Browse files
authored
Merge pull request #62 from SemanticMediaWiki/add-ci
Add CI
2 parents e4864e6 + f005ff3 commit 6725195

File tree

15 files changed

+408
-211
lines changed

15 files changed

+408
-211
lines changed

.github/workflows/ci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
12+
test:
13+
14+
runs-on: ubuntu-22.04
15+
continue-on-error: ${{ matrix.experimental }}
16+
17+
strategy:
18+
matrix:
19+
include:
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
26+
experimental: false
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
33+
experimental: false
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
40+
experimental: false
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
47+
experimental: false
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
54+
experimental: false
55+
56+
env:
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 }}
62+
63+
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
with:
68+
submodules: recursive
69+
70+
- name: Update submodules
71+
run: git submodule update --init --remote
72+
73+
- name: Run tests
74+
run: make ci
75+
if: matrix.coverage == false
76+
77+
- name: Run tests with coverage
78+
run: make ci-coverage
79+
if: matrix.coverage == true
80+
81+
- name: Upload code coverage
82+
uses: codecov/codecov-action@v5
83+
with:
84+
token: ${{ secrets.CODECOV_TOKEN }}
85+
files: coverage/php/coverage.xml
86+
if: matrix.coverage == true
87+

.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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
</rule>
31+
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
32+
<properties>
33+
<property name="allowedPrefixes" type="array" value="eg,wg" />
34+
</properties>
35+
</rule>
36+
<rule ref="MediaWiki.Commenting.FunctionComment.ObjectTypeHintReturn">
37+
<severity>0</severity>
38+
</rule>
39+
<file>.</file>
40+
<exclude-pattern>/(vendor|conf)/</exclude-pattern>
41+
<exclude-pattern type="relative">extensions/*</exclude-pattern>
42+
<arg name="extensions" value="php"/>
43+
<arg name="encoding" value="UTF-8"/>
44+
</ruleset>
45+

.scrutinizer.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1-
inherit: true
1+
filter:
2+
excluded_paths:
3+
- 'vendor/*'
24

35
tools:
4-
external_code_coverage: true
5-
php_code_sniffer: true
6+
php_mess_detector:
7+
config:
8+
controversial_rules: { superglobals: false }
69
php_cpd: true
10+
php_pdepend: true
11+
php_code_coverage: false
12+
php_code_sniffer: true
713
php_cs_fixer: true
814
php_loc: true
9-
php_mess_detector: true
10-
php_pdepend: true
1115
php_analyzer: true
1216
sensiolabs_security_checker: true
17+
external_code_coverage:
18+
timeout: '900'
1319

14-
filter:
15-
excluded_paths:
16-
- 'vendor/*'
20+
checks:
21+
php:
22+
psr2_class_declaration: false
23+
psr2_switch_declaration: false
24+
sql_injection_vulnerabilities: true
25+
security_vulnerabilities: true
26+
no_eval: true
27+
code_rating: true
28+
duplication: true

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=SemanticTasks
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+

SemanticTasks.php

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @defgroup SemanticTasks Semantic Tasks
77
*/
88

9+
use MediaWiki\MediaWikiServices;
910
use ST\SemanticTasksMailer;
1011

1112
SemanticTasks::load();
@@ -22,13 +23,11 @@ public static function load() {
2223
}
2324

2425
/**
25-
* @global boolean $wgSemanticTasksNotifyIfUnassigned
2626
* @since 1.0
2727
* @see https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#callback
2828
*/
2929
public static function initExtension( $credits = [] ) {
30-
31-
$version = 'UNKNOWN' ;
30+
$version = 'UNKNOWN';
3231

3332
// See https://phabricator.wikimedia.org/T151136
3433
if ( isset( $credits['version'] ) ) {
@@ -41,16 +40,12 @@ public static function initExtension( $credits = [] ) {
4140
if ( !defined( 'MW_VERSION' ) ) {
4241
define( 'MW_VERSION', $GLOBALS['wgVersion'] );
4342
}
44-
45-
// Register extension messages and other localisation.
46-
$wgMessagesDirs['SemanticTasks'] = __DIR__ . '/i18n';
4743
}
4844

4945
/**
5046
* @since 1.0
5147
*/
5248
public static function onExtensionFunction() {
53-
5449
// Check requirements after LocalSetting.php has been processed
5550
if ( !defined( 'SMW_VERSION' ) ) {
5651
if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
@@ -66,37 +61,22 @@ public static function onExtensionFunction() {
6661
$assignees = new \ST\Assignees();
6762

6863
// Register extension hooks.
69-
global $wgHooks;
70-
71-
if ( version_compare( MW_VERSION, '1.35', '<' ) ) {
72-
$wgHooks['PageContentSave'][] = [ $assignees, 'saveAssignees' ];
73-
$wgHooks['PageContentSaveComplete'][] = function(WikiPage $article, User $current_user, Content $text,
74-
$summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision) use ($assignees) {
75-
SemanticTasksMailer::mailAssigneesUpdatedTask(
76-
$assignees, $article, $current_user, $text,
77-
$summary, $minoredit, $watchthis, $sectionanchor, $flags, $revision
78-
);
79-
};
80-
81-
} else {
82-
$wgHooks['MultiContentSave'][] = [ $assignees, 'saveAssigneesMultiContentSave' ];
83-
$wgHooks['PageSaveComplete'][] = function( WikiPage $wikiPage, MediaWiki\User\UserIdentity $user, string $summary, int $flags, MediaWiki\Revision\RevisionRecord $revisionRecord, MediaWiki\Storage\EditResult $editResult ) use ( $assignees ) {
84-
85-
// @see includes/Storage/PageUpdater.php
86-
$mainContent = $revisionRecord->getContent( MediaWiki\Revision\SlotRecord::MAIN, MediaWiki\Revision\RevisionRecord::RAW );
87-
$minoredit = $editResult->isNullEdit() || ( $flags & EDIT_MINOR )
88-
// *** this is for the use in conjunction with WSSlots
89-
|| ( $flags & EDIT_INTERNAL );
90-
$watchthis = null;
91-
$sectionanchor = null;
92-
93-
SemanticTasksMailer::mailAssigneesUpdatedTask(
94-
$assignees, $wikiPage, $user, $mainContent,
95-
$summary, $minoredit, $watchthis, $sectionanchor, $flags, $revisionRecord
96-
);
97-
};
98-
}
99-
64+
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
65+
$hookContainer->register( 'MultiContentSave', [ $assignees, 'saveAssigneesMultiContentSave' ] );
66+
$hookContainer->register( 'PageSaveComplete', static function ( WikiPage $wikiPage, MediaWiki\User\UserIdentity $user, string $summary, int $flags, MediaWiki\Revision\RevisionRecord $revisionRecord, MediaWiki\Storage\EditResult $editResult ) use ( $assignees ) {
67+
// @see includes/Storage/PageUpdater.php
68+
$mainContent = $revisionRecord->getContent( MediaWiki\Revision\SlotRecord::MAIN, MediaWiki\Revision\RevisionRecord::RAW );
69+
$minoredit = $editResult->isNullEdit() || ( $flags & EDIT_MINOR )
70+
// *** this is for the use in conjunction with WSSlots
71+
|| ( $flags & EDIT_INTERNAL );
72+
$watchthis = null;
73+
$sectionanchor = null;
74+
75+
SemanticTasksMailer::mailAssigneesUpdatedTask(
76+
$assignees, $wikiPage, $user, $mainContent,
77+
$summary, $minoredit, $watchthis, $sectionanchor, $flags, $revisionRecord
78+
);
79+
} );
10080
}
10181

10282
}

build

Submodule build added at 13d00b1

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/SemanticTasks/::"

composer.json

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,48 @@
1010
"homepage": "https://www.mediawiki.org/wiki/Extension:Semantic_Tasks",
1111
"license": "GPL-2.0-or-later",
1212
"require": {
13-
"mediawiki/semantic-media-wiki": "~3.0|~4.0"
13+
"composer/installers": ">=1.0.1"
1414
},
1515
"require-dev": {
16-
"jakub-onderka/php-parallel-lint": "1.0.0",
17-
"jakub-onderka/php-console-highlighter": "0.3.2",
18-
"mediawiki/minus-x": "0.3.1"
16+
"mediawiki/mediawiki-codesniffer": "46.0.0",
17+
"mediawiki/minus-x": "1.1.3",
18+
"php-parallel-lint/php-console-highlighter": "1.0.0",
19+
"php-parallel-lint/php-parallel-lint": "1.4.0"
1920
},
20-
"autoload": {
21-
"psr-4": {
22-
"ST\\": "src/"
23-
},
24-
"files": [
25-
"SemanticTasks.php"
26-
]
21+
"config": {
22+
"process-timeout": 0,
23+
"allow-plugins": {
24+
"composer/installers": true,
25+
"dealerdirect/phpcodesniffer-composer-installer": true
26+
}
2727
},
2828
"scripts": {
2929
"test": [
30-
"parallel-lint . --exclude vendor --exclude node_modules --exclude extensions",
31-
"minus-x check ."
30+
"@analyze",
31+
"@phpunit"
32+
],
33+
"test-coverage": [
34+
"@analyze",
35+
"@phpunit-coverage"
36+
],
37+
"analyze": [
38+
"@lint",
39+
"@phpcs",
40+
"@minus-x"
3241
],
3342
"fix": [
34-
"minus-x fix ."
43+
"minus-x fix .",
44+
"@phpcs-fix"
3545
],
36-
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist"
37-
},
38-
"minimum-stability": "dev"
46+
"phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist",
47+
"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",
48+
"post-test-coverage": [
49+
"sed -i 's|/var/www/html/extensions/SemanticTasks/||g' coverage/php/coverage.xml",
50+
"find coverage/php -type f -name '*.html' -exec sed -i 's|/var/www/html/extensions/||g' {} +"
51+
],
52+
"phpcs": "phpcs -ps -d memory_limit=2G",
53+
"phpcs-fix": "phpcbf -p",
54+
"lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions",
55+
"minus-x": "minus-x check ."
56+
}
3957
}

0 commit comments

Comments
 (0)