Skip to content
Merged
59 changes: 23 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ jobs:
strategy:
matrix:
include:
- mw: 'REL1_36'
php: 8.0
experimental: false
- mw: 'REL1_37'
php: 8.0
experimental: false
- mw: 'REL1_38'
php: 8.0
experimental: false
- mw: 'REL1_39'
php: 8.0
experimental: false
- mw: 'REL1_41'
php: 8.1
experimental: false
- mw: 'REL1_42'
php: 8.2
experimental: false
- mw: 'REL1_43'
php: 8.3
experimental: false
Expand Down Expand Up @@ -88,17 +70,18 @@ jobs:
- name: Run update.php
run: php maintenance/update.php --quick

- name: Run PHPUnit
- name: Run PHPUnit (MW < master)
if: matrix.mw != 'master'
run: php tests/phpunit/phpunit.php -c extensions/AutomatedValues/
if: matrix.php != 7.4

- name: Run PHPUnit with code coverage
run: php tests/phpunit/phpunit.php -c extensions/AutomatedValues/ --coverage-clover coverage.xml
if: matrix.php == 7.4

- name: Upload code coverage
run: bash <(curl -s https://codecov.io/bash)
if: matrix.php == 7.4
- name: Run PHPUnit (MW master)
if: matrix.mw == 'master'
run: |
# phpunit.xml.template is export-ignored from the GitHub tarball, fetch it separately
if [ ! -f phpunit.xml.template ]; then
wget -q -O phpunit.xml.template "https://raw.githubusercontent.com/wikimedia/mediawiki/${{ matrix.mw }}/phpunit.xml.template"
fi
composer phpunit -- extensions/AutomatedValues/tests/



Expand All @@ -116,7 +99,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.3
extensions: mbstring
tools: composer, cs2pr

Expand All @@ -128,7 +111,7 @@ jobs:
mediawiki
mediawiki/extensions/
mediawiki/vendor/
key: mw_phpstan
key: mw_phpstan_v3

- name: Cache Composer cache
uses: actions/cache@v4
Expand All @@ -143,7 +126,7 @@ jobs:
- name: Install MediaWiki
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
working-directory: ~
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh REL1_39 AutomatedValues
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh REL1_43 AutomatedValues

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -176,7 +159,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.3
extensions: mbstring
tools: composer, cs2pr

Expand All @@ -188,7 +171,7 @@ jobs:
mediawiki
mediawiki/extensions/
mediawiki/vendor/
key: mw_psalm
key: mw_psalm_v3

- name: Cache Composer cache
uses: actions/cache@v4
Expand All @@ -203,7 +186,7 @@ jobs:
- name: Install MediaWiki
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
working-directory: ~
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh REL1_39 AutomatedValues
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh REL1_43 AutomatedValues

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -236,7 +219,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
extensions: mbstring, intl, php-ast
tools: composer

Expand All @@ -248,18 +231,22 @@ jobs:
mediawiki
!mediawiki/extensions/
!mediawiki/vendor/
key: mw_static_analysis
key: mw_static_analysis_v3

- name: Cache Composer cache
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer_static_analysis

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

- name: Install MediaWiki
if: steps.cache-mediawiki.outputs.cache-hit != 'true'
working-directory: ~
run: curl https://gist.githubusercontent.com/JeroenDeDauw/49a3858653ff4b5be7ec849019ede06c/raw/installMediaWiki.sh | bash -s REL1_36 AutomatedValues
run: bash EarlyCopy/.github/workflows/installMediaWiki.sh REL1_43 AutomatedValues

- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"descriptionmsg": "automated-values-description",

"requires": {
"MediaWiki": ">= 1.35.0",
"MediaWiki": ">= 1.43.0",
"extensions": {
"WikibaseRepository": "*"
}
Expand Down
2 changes: 1 addition & 1 deletion src/AutomatedValuesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use ProfessionalWiki\AutomatedValues\DataAccess\RulesJsonValidator;
use ProfessionalWiki\AutomatedValues\DataAccess\RulesLookup;
use ProfessionalWiki\AutomatedValues\DataAccess\WikiRulesLookup;
use Title;
use MediaWiki\Title\Title;

class AutomatedValuesFactory {

Expand Down
16 changes: 10 additions & 6 deletions src/DataAccess/PageContentFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@

namespace ProfessionalWiki\AutomatedValues\DataAccess;

use MediaWiki\Content\Content;
use MediaWiki\Revision\RevisionLookup;
use MediaWiki\Title\MalformedTitleException;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleParser;

class PageContentFetcher {

private \TitleParser $titleParser;
private TitleParser $titleParser;
private RevisionLookup $revisionLookup;

public function __construct( \TitleParser $titleParser, RevisionLookup $revisionLookup ) {
public function __construct( TitleParser $titleParser, RevisionLookup $revisionLookup ) {
$this->titleParser = $titleParser;
$this->revisionLookup = $revisionLookup;
}

public function getPageContent( string $pageTitle ): ?\Content {
public function getPageContent( string $pageTitle ): ?Content {
try {
$title = $this->titleParser->parseTitle( $pageTitle );
} catch ( \MalformedTitleException $e ) {
$linkTarget = $this->titleParser->parseTitle( $pageTitle );
} catch ( MalformedTitleException $e ) {
return null;
}

$revision = $this->revisionLookup->getRevisionByTitle( $title );
$revision = $this->revisionLookup->getRevisionByTitle( Title::newFromLinkTarget( $linkTarget ) );

if ( $revision === null ) {
return null;
Expand Down
5 changes: 3 additions & 2 deletions src/DataAccess/WikiRulesLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace ProfessionalWiki\AutomatedValues\DataAccess;

use MediaWiki\Content\JsonContent;
use ProfessionalWiki\AutomatedValues\Domain\Rules;

class WikiRulesLookup implements RulesLookup {
Expand All @@ -21,14 +22,14 @@ public function __construct( PageContentFetcher $contentFetcher, RulesDeserializ
public function getRules(): Rules {
$content = $this->contentFetcher->getPageContent( 'MediaWiki:' . $this->pageName );

if ( $content instanceof \JsonContent ) {
if ( $content instanceof JsonContent ) {
return $this->rulesFromJsonContent( $content );
}

return new Rules();
}

private function rulesFromJsonContent( \JsonContent $content ): Rules {
private function rulesFromJsonContent( JsonContent $content ): Rules {
return $this->deserializer->deserialize( $content->getText() );
}

Expand Down
8 changes: 4 additions & 4 deletions src/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace ProfessionalWiki\AutomatedValues;

use EditPage;
use MediaWiki\EditPage\EditPage;
use MediaWiki\Html\Html;
use MediaWiki\Revision\RenderedRevision;
use MediaWiki\Revision\RevisionAccessException;
use OutputPage;
use MediaWiki\Title\Title;
use ProfessionalWiki\AutomatedValues\DataAccess\RulesJsonValidator;
use Title;
use Wikibase\DataModel\Entity\StatementListProvidingEntity;
use Wikibase\Repo\Content\EntityContent;

Expand Down Expand Up @@ -45,7 +45,7 @@ public static function onEditFilter( EditPage $editPage, ?string $text, ?string
&& !RulesJsonValidator::newInstance()->validate( $text ) ) {

// Would be nice to show a more specific error message, but at the moment RulesJsonValidator does not support this.
$error = \Html::errorBox( wfMessage( 'automated-values-config-invalid' )->escaped() );
$error = Html::errorBox( wfMessage( 'automated-values-config-invalid' )->escaped() );
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/SpecialAutomatedValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace ProfessionalWiki\AutomatedValues;

use SpecialPage;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Title\Title;

class SpecialAutomatedValues extends SpecialPage {

Expand All @@ -15,9 +16,9 @@ public function __construct() {
public function execute( $subPage ): void {
parent::execute( $subPage );

$title = \Title::newFromText( 'MediaWiki:AutomatedValues' );
$title = Title::newFromText( 'MediaWiki:AutomatedValues' );

if ( $title instanceof \Title ) {
if ( $title instanceof Title ) {
$this->getOutput()->redirect( $title->getFullURL() );
}
}
Expand Down
Loading