Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI for MW 1.39 #84

Merged
merged 4 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 25 additions & 63 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,88 +8,50 @@ on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-20.04

test:

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}

strategy:
matrix:
include:
- mediawiki_version: '1.35'
semantic_mediawiki_version: 4.1.0
coverage: true
experimental: false
- mediawiki_version: '1.35'
semantic_mediawiki_version: dev-master
coverage: false
experimental: false
- mediawiki_version: '1.36'
semantic_mediawiki_version: dev-master
- mediawiki_version: '1.39'
smw_version: dev-master
php_version: 8.1
database_type: mysql
database_image: "mariadb:10"
coverage: false
experimental: false
- mediawiki_version: '1.37'
semantic_mediawiki_version: dev-master
coverage: false
experimental: true

container:
image: gesinn/docker-mediawiki:${{ matrix.mediawiki_version }}

env:
EXT_NAME: SemanticMetaTags
MW_INST_PATH: /var/www/html
MW_DB_PATH: /var/www/data
MW_EXT_PATH: /var/www/html/extensions
MW_VERSION: ${{ matrix.mediawiki_version }}
SMW_VERSION: ${{ matrix.smw_version }}
PHP_VERSION: ${{ matrix.php_version }}
DB_TYPE: ${{ matrix.database_type }}
DB_IMAGE: ${{ matrix.database_image }}

steps:
- name: Install SemanticMediaWiki
run: |
COMPOSER=composer.local.json composer require --update-with-dependencies --working-dir ${{ env.MW_INST_PATH }} mediawiki/semantic-media-wiki ${{ matrix.semantic_mediawiki_version }}
composer update --working-dir ${{ env.MW_INST_PATH }}
echo "wfLoadExtension( 'SemanticMediaWiki' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
echo "enableSemantics( 'localhost' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
tail -n5 ${{ env.MW_INST_PATH }}/LocalSettings.php
php ${{ env.MW_INST_PATH }}/maintenance/update.php --skip-external-dependencies --quick

- name: Checkout Extension
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.EXT_NAME }}

# Setting actions/checkout@v2 path to env.MW_EXT_PATH fails with "Repository path '/var/www/html/extensions' is not under ..."
# See also open PR https://github.com/actions/checkout/pull/388
- name: Move Extension
run: |
mkdir -p ${{ env.MW_EXT_PATH }}
mv ${{ env.EXT_NAME }} ${{ env.MW_EXT_PATH }}
submodules: recursive

- name: Install SemanticMetaTags
run: |
COMPOSER=composer.local.json composer require --no-update --working-dir ${{ env.MW_INST_PATH }} mediawiki/semantic-meta-tags @dev
COMPOSER=composer.local.json composer config repositories.semantic-meta-tags '{"type": "path", "url": "extensions/SemanticMetaTags"}' --working-dir ${{ env.MW_INST_PATH }}
composer update --working-dir ${{ env.MW_INST_PATH }}
echo "wfLoadExtension( '${{ env.EXT_NAME }}' );" >> ${{ env.MW_INST_PATH }}/LocalSettings.php
tail -n5 ${{ env.MW_INST_PATH }}/LocalSettings.php
php ${{ env.MW_INST_PATH }}/maintenance/update.php --quick
- name: Update submodules
run: git submodule update --init --remote

- name: Run Tests
run: >
php ${{ env.MW_INST_PATH }}/tests/phpunit/phpunit.php
--configuration ${{ env.MW_EXT_PATH }}/${{ env.EXT_NAME }}
--testdox
- name: Run tests
run: make ci
if: matrix.coverage == false

- name: Run Tests With Coverage
run: >
php ${{ env.MW_INST_PATH }}/tests/phpunit/phpunit.php
--configuration ${{ env.MW_EXT_PATH }}/${{ env.EXT_NAME }}
--testdox
--coverage-clover ${{ env.MW_INST_PATH }}/docs/coverage.xml
- name: Run tests with coverage
run: make ci-coverage
if: matrix.coverage == true

- name: Upload code coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.MW_INST_PATH }}/docs/coverage.xml
files: coverage/php/coverage.xml
if: matrix.coverage == true
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "build"]
path = build
url = https://github.com/gesinn-it-pub/docker-compose-ci.git
46 changes: 46 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude name="MediaWiki.Commenting.FunctionComment.NoParamType" />
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
<exclude name="MediaWiki.PHPUnit.AssertEmpty.AssertEmptyUsed" />
<exclude name="Squiz.Operators.ValidLogicalOperators.NotAllowed" />
<exclude name="Generic.ControlStructures.DisallowYodaConditions.Found" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
<exclude name="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgContLang" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
<exclude name="Universal.WhiteSpace.CommaSpacing" />
<exclude name="MediaWiki.Commenting.MissingCovers.MissingCovers" />
</rule>
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
<properties>
<property name="allowedPrefixes" type="array" value="eg,wg" />
</properties>
</rule>
<rule ref="MediaWiki.Commenting.FunctionComment.ObjectTypeHintReturn">
<severity>0</severity>
</rule>
<file>.</file>
<exclude-pattern>/(vendor|conf)/</exclude-pattern>
<exclude-pattern type="relative">extensions/*</exclude-pattern>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
</ruleset>
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-include .env
export

# setup for docker-compose-ci build directory
# delete "build" directory to update docker-compose-ci

ifeq (,$(wildcard ./build/))
$(shell git submodule update --init --remote)
endif

EXTENSION=SemanticMetaTags

# docker images
MW_VERSION?=1.39
PHP_VERSION?=8.1
DB_TYPE?=mysql
DB_IMAGE?="mariadb:10"

# extensions
SMW_VERSION?=dev-master

# composer
# Enables "composer update" inside of extension
COMPOSER_EXT?=true

# nodejs
# Enables node.js related tests and "npm install"
# NODE_JS?=true

# check for build dir and git submodule init if it does not exist
include build/Makefile


6 changes: 0 additions & 6 deletions SemanticMetaTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class SemanticMetaTags {
* the extension is activated.
*/
public static function load() {

if ( !defined( 'MEDIAWIKI' ) ) {
return;
}
Expand All @@ -36,14 +35,12 @@ public static function load() {
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once __DIR__ . '/vendor/autoload.php';
}

}

/**
* @since 1.0
*/
public static function initExtension( $credits = [] ) {

// See https://phabricator.wikimedia.org/T151136
define( 'SMT_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' );

Expand All @@ -55,7 +52,6 @@ public static function initExtension( $credits = [] ) {
* @since 1.4
*/
public static function doCheckRequirements() {

if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.27', 'lt' ) ) {
die( '<b>Error:</b> This version of <a href="https://github.com/SemanticMediaWiki/SemanticMetaTags/">SemanticMetaTags</a> is only compatible with MediaWiki 1.27 or above. You need to upgrade MediaWiki first.' );
}
Expand All @@ -65,7 +61,6 @@ public static function doCheckRequirements() {
* @since 1.0
*/
public static function onExtensionFunction() {

if ( !defined( 'SMW_VERSION' ) ) {

if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
Expand Down Expand Up @@ -93,7 +88,6 @@ public static function onExtensionFunction() {
);

$hookRegistry->register();

}

}
1 change: 1 addition & 0 deletions build
Submodule build added at 10d574
52 changes: 33 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,50 @@
"source": "https://github.com/SemanticMediaWiki/SemanticMetaTags"
},
"require": {
"php": ">=7.1",
"composer/installers": "1.*,>=1.0.1"
"php": ">=7.4",
"composer/installers": ">=1.0.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "~2.1",
"phpmd/phpmd": "~2.1"
"mediawiki/mediawiki-codesniffer": "43.0.0",
"mediawiki/minus-x": "1.1.3",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.4.0"
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
"dev-master": "4.x-dev"
}
},
"autoload": {},
"config": {
"process-timeout": 0,
"allow-plugins": {
"composer/installers": true
}
},
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts":{
"test": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
"cs": [
"vendor/bin/phpcs src/* tests/* --standard=phpcs.xml --extensions=php -sp",
"vendor/bin/phpmd src/,tests/ text phpmd.xml"
"test": [
"@analyze",
"@phpunit"
],
"test-coverage": [
"@analyze",
"@phpunit-coverage"
],
"analyze": [
"@lint",
"@phpcs",
"@minus-x"
],
"phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist",
"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",
"post-test-coverage": [
"sed -i 's|/var/www/html/extensions/SemanticMetaTags/||g' coverage/php/coverage.xml",
"find coverage/php -type f -name '*.html' -exec sed -i 's|/var/www/html/extensions/||g' {} +"
],
"ci": [
"composer validate --no-interaction",
"composer phpunit",
"composer cs"
]
"phpcs": "phpcs -ps -d memory_limit=2G",
"phpcs-fix": "phpcbf -p",
"lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions",
"minus-x": "minus-x check ."
}
}
Empty file modified docs/README.md
100755 → 100644
Empty file.
Loading
Loading