Skip to content

Commit

Permalink
overhaul ci, refactor extension loading, raise minimum requirements
Browse files Browse the repository at this point in the history
* switch unit tests from tavis to github
* add new ci sets for mw > 1.39
* switch hook registration to default mw schema
* switch to mw autoloader, abandoning composer autoloader
* fix unit tests
* raising minimum requirement to mw 1.39 and smw 4.1
  • Loading branch information
oetterer committed Jul 16, 2024
1 parent f9aaaf7 commit e06b903
Show file tree
Hide file tree
Showing 27 changed files with 508 additions and 363 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "composer"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ "*" ]

jobs:
test:
name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }} (TYPE ${{ matrix.type }})"

strategy:
matrix:
include:
- mw: 'REL1_39'
php: 8.0
type: coverage
experimental: false
- mw: 'REL1_39'
php: 8.1
type: normal
experimental: false
- mw: 'REL1_40'
php: 8.1
type: normal
experimental: false
- mw: 'REL1_41'
php: 8.1
type: normal
experimental: false
- mw: 'REL1_42'
php: 8.2
type: normal
experimental: false
- mw: 'master'
php: 8.3
type: normal
experimental: true

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

defaults:
run:
working-directory: mediawiki

env:
MW_ROOT: mediawiki
TYPE: ${{ matrix.type }}


steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl
tools: composer

- name: Cache MediaWiki
id: cache-mediawiki
uses: actions/cache@v4
with:
path: |
mediawiki
!mediawiki/extensions/
!mediawiki/vendor/
key: mw_${{ matrix.mw }}-php${{ matrix.php }}

- name: Cache Composer cache
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php }}

- uses: actions/checkout@v4
with:
path: EarlyCopy

- name: Install MediaWiki
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
working-directory: ~
run: bash EarlyCopy/.github/workflows/installWiki.sh ${{ matrix.mw }} SemanticScribunto

- uses: actions/checkout@v4
with:
path: mediawiki/extensions/SemanticScribunto

- name: Composer update
run: composer update

- name: run update.php
run: php maintenance/update.php --quick

- if: env.TYPE != 'coverage'
name: Run PHPUnit w/o coverage
run: php tests/phpunit/phpunit.php -c extensions/SemanticScribunto/ --testsuite semantic-scribunto-unit

- if: env.TYPE == 'coverage'
name: Run PHPUnit w/ coverage
run: php tests/phpunit/phpunit.php -c extensions/SemanticScribunto/ --testsuite semantic-scribunto-unit --coverage-clover coverage.clover

- if: env.TYPE == 'coverage'
name: upload coverage report
working-directory: ~
run: bash EarlyCopy/.github/workflows/uploadCoverageReport.sh
63 changes: 63 additions & 0 deletions .github/workflows/installWiki.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#! /bin/bash

MW_BRANCH=$1
EXTENSION_NAME=$2

## install core
wget https://github.com/wikimedia/mediawiki/archive/${MW_BRANCH}.tar.gz -nv

tar -zxf $MW_BRANCH.tar.gz
mv mediawiki-$MW_BRANCH mediawiki
cd $MW_ROOT

composer install
php maintenance/install.php --dbtype sqlite --dbuser root --dbname mw --dbpath $(pwd) --pass AdminPassword WikiName AdminUser

cat <<EOT >> composer.local.json
{
"extra": {
"merge-plugin": {
"merge-dev": true,
"include": [
"extensions/${EXTENSION_NAME}/composer.json"
]
}
}
}
EOT

## Vector
cd skins
# most mw dumps ship with empty skin directories
[[ -e Vector ]] && rm -rf Vector
git clone --branch ${MW_BRANCH} https://github.com/wikimedia/Vector.git


## Scribunto
cd ../extensions
wget https://github.com/wikimedia/mediawiki-extensions-Scribunto/archive/${MW_BRANCH}.tar.gz
tar -zxf ${MW_BRANCH}.tar.gz
[[ -e Scribunto ]] && rm -rf Scribunto
mv mediawiki-extensions-Scribunto* Scribunto
cd ..


## extend LocalSettings.php
echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php
echo 'ini_set("display_errors", 1);' >> LocalSettings.php
echo '$wgShowExceptionDetails = true;' >> LocalSettings.php
echo '$wgShowDBErrorBacktrace = true;' >> LocalSettings.php
echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php

echo '$wgArticlePath = $wgScriptPath . "/$1";' >> LocalSettings.php
echo '$wgEnableUploads = true;' >> LocalSettings.php

echo 'wfLoadSkin( "Vector" );' >> LocalSettings.php
echo '$wgDefaultSkin = "vector-2022";' >> LocalSettings.php

echo 'wfLoadExtension( "SemanticMediaWiki" );' >> LocalSettings.php
echo 'wfLoadExtension( "Scribunto" );' >> LocalSettings.php
echo 'enableSemantics( "reynolds.serenity.verse" );' >> LocalSettings.php

## add loading of $EXTENSION_NAME
echo 'wfLoadExtension( "'$EXTENSION_NAME'" );' >> LocalSettings.php
14 changes: 14 additions & 0 deletions .github/workflows/uploadCoverageReport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash

COVERAGE_REPORT=${MW_ROOT}/coverage.clover

if [[ ! -e ${COVERAGE_REPORT} ]]; then
echo "File coverage.clover is missing. Abort the upload!"
# this was exit 127; restore exit value when code coverage is again supported
exit
fi

cd EarlyCopy

wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover ../${COVERAGE_REPORT}
10 changes: 10 additions & 0 deletions .github/workflows/uploadImages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

cd $MW_ROOT

## inject Resources
php maintenance/importImages.php extensions/BootstrapComponents/tests/resources/ png
php maintenance/rebuildall.php
php maintenance/runJobs.php --quiet

cd ..
10 changes: 1 addition & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"require": {
"php": ">=7.3",
"composer/installers": "^2|^1.0.1",
"mediawiki/semantic-media-wiki": "~3.0|~4.0"
"mediawiki/semantic-media-wiki": "~4.0"
},
"require-dev": {
"mediawiki/semantic-media-wiki": "@dev",
Expand All @@ -45,14 +45,6 @@
"dev-master": "2.3.x-dev"
}
},
"autoload": {
"files" : [
"SemanticScribunto.php"
],
"psr-4": {
"SMW\\Scribunto\\": "src/"
}
},
"config": {
"process-timeout": 0
},
Expand Down
17 changes: 13 additions & 4 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@
"license-name": "GPL-2.0-or-later",
"type": "semantic",
"requires": {
"MediaWiki": ">= 1.35",
"MediaWiki": ">= 1.39",
"extensions": {
"Scribunto": "*",
"SemanticMediaWiki": ">= 3.0"
"SemanticMediaWiki": ">= 4.1"
}
},
"AutoloadNamespaces": {
"SMW\\Scribunto\\": "src/"
},
"TestAutoloadNamespaces": {
"SMW\\Scribunto\\Tests\\": "tests/phpunit/"
},
"Hooks": {
"ScribuntoExternalLibraries": "SMW\\Scribunto\\HooksHandler::onScribuntoExternalLibraries"
},
"callback": "SMW\\Scribunto\\SemanticScribunto::initExtension",
"MessagesDirs": {
"SemanticScribunto": [
"i18n"
]
},
"callback": "SemanticScribunto::initExtension",
"ExtensionFunctions": [
"SemanticScribunto::onExtensionFunction"
"SMW\\Scribunto\\SemanticScribunto::onExtensionFunction"
],
"load_composer_autoloader":true,
"manifest_version": 2
Expand Down
61 changes: 32 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">
<testsuites>
<testsuite name="semantic-scribunto-unit">
<directory>tests/phpunit/Unit</directory>
</testsuite>
<testsuite name="semantic-scribunto-integration">
<directory>tests/phpunit/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<php>
<var name="seqlgHttpResponseCacheType" value="hash"/>
</php>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="semantic-scribunto-unit">
<directory>tests/phpunit/Unit</directory>
</testsuite>
<testsuite name="semantic-scribunto-integration">
<directory>tests/phpunit/Integration</directory>
</testsuite>
</testsuites>
<php>
<var name="seqlgHttpResponseCacheType" value="hash"/>
</php>
</phpunit>
Loading

0 comments on commit e06b903

Please sign in to comment.