Skip to content

Commit bc19792

Browse files
JeroenDeDauwclaude
andcommitted
Fix CI for MW master compatibility
- Use per-matrix search engine images: Elasticsearch 7.10 for REL1_43–REL1_45, OpenSearch 1.3 for master (CirrusSearch dropped Elasticsearch support on master) - Handle MW master's removal of tests/phpunit/phpunit.php by falling back to composer phpunit - Download phpunit.xml.template in install script since GitHub tarballs exclude it via .gitattributes export-ignore - Stop using removed SpecialPageTestBase, extend MediaWikiIntegrationTestCase directly - Pass PageIdentity instead of LinkTarget to getRevisionByTitle (deprecated since MW 1.36, enforced on master) - Bump cache key version and mark master as non-experimental Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3e06af3 commit bc19792

6 files changed

Lines changed: 40 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,40 @@ jobs:
1616
php: '8.1'
1717
experimental: false
1818
coverage: false
19+
search-image: 'docker-registry.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image:v7.10.2-12'
1920
- mw: 'REL1_43'
2021
php: '8.2'
2122
experimental: false
2223
coverage: true
24+
search-image: 'docker-registry.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image:v7.10.2-12'
2325
- mw: 'REL1_44'
2426
php: '8.3'
2527
experimental: false
2628
coverage: false
29+
search-image: 'docker-registry.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image:v7.10.2-12'
2730
- mw: 'REL1_45'
2831
php: '8.4'
2932
experimental: false
3033
coverage: false
34+
search-image: 'docker-registry.wikimedia.org/repos/search-platform/cirrussearch-elasticsearch-image:v7.10.2-12'
3135
- mw: 'master'
3236
php: '8.5'
33-
experimental: true
37+
experimental: false
3438
coverage: false
39+
search-image: 'docker-registry.wikimedia.org/repos/search-platform/cirrussearch-opensearch-image:v1.3.20-12'
3540

3641
runs-on: ubuntu-latest
3742

3843
services:
3944
elasticsearch:
40-
image: docker-registry.wikimedia.org/releng/cirrus-elasticsearch:7.10.2-s0 # Compatibility info at https://www.mediawiki.org/wiki/Extension:CirrusSearch
45+
image: ${{ matrix.search-image }}
4146
ports:
4247
- 9200:9200
4348
- 9300:9300
4449
env:
4550
discovery.type: single-node
4651
ES_JAVA_OPTS: "-Xms512m -Xmx512m -Dlog4j2.formatMsgNoLookups=true"
52+
OPENSEARCH_JAVA_OPTS: "-Xms512m -Xmx512m"
4753

4854
defaults:
4955
run:
@@ -65,7 +71,7 @@ jobs:
6571
mediawiki
6672
!mediawiki/extensions/
6773
!mediawiki/vendor/
68-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v2
74+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v3
6975

7076
- name: Cache Composer cache
7177
uses: actions/cache@v4
@@ -101,11 +107,21 @@ jobs:
101107
php maintenance/runJobs.php
102108
103109
- name: Run PHPUnit
104-
run: php tests/phpunit/phpunit.php -c extensions/WikibaseFacetedSearch/
110+
run: |
111+
if [ -f tests/phpunit/phpunit.php ]; then
112+
php tests/phpunit/phpunit.php -c extensions/WikibaseFacetedSearch/
113+
else
114+
composer phpunit -- extensions/WikibaseFacetedSearch/tests/
115+
fi
105116
if: ${{ ! matrix.coverage }}
106117

107118
- name: Run PHPUnit with code coverage
108-
run: php tests/phpunit/phpunit.php -c extensions/WikibaseFacetedSearch/ --coverage-clover coverage.xml
119+
run: |
120+
if [ -f tests/phpunit/phpunit.php ]; then
121+
php tests/phpunit/phpunit.php -c extensions/WikibaseFacetedSearch/ --coverage-clover coverage.xml
122+
else
123+
composer phpunit -- extensions/WikibaseFacetedSearch/tests/ --coverage-clover coverage.xml
124+
fi
109125
if: ${{ matrix.coverage }}
110126

111127
- name: Upload code coverage
@@ -145,7 +161,7 @@ jobs:
145161
mediawiki
146162
mediawiki/extensions/
147163
mediawiki/vendor/
148-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v2
164+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v3
149165

150166
- name: Cache Composer cache
151167
uses: actions/cache@v4
@@ -214,7 +230,7 @@ jobs:
214230
uses: actions/cache@v4
215231
with:
216232
path: ~/.composer/cache
217-
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v2
233+
key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v3
218234

219235
- name: Install MediaWiki
220236
if: steps.cache-mediawiki.outputs.cache-hit != 'true'

.github/workflows/installMediaWiki.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ mv mediawiki-$MW_BRANCH mediawiki
1212

1313
cd mediawiki
1414

15+
# phpunit.xml.template is excluded from GitHub tarballs via .gitattributes export-ignore.
16+
# Download it directly from the repo if missing.
17+
if [ ! -f phpunit.xml.template ]; then
18+
wget "https://raw.githubusercontent.com/wikimedia/mediawiki/$MW_BRANCH/phpunit.xml.template" -nv -O phpunit.xml.template 2>/dev/null || true
19+
fi
20+
1521
composer install
1622
php maintenance/install.php --dbtype sqlite --dbuser root --dbname mw --dbpath $(pwd) --pass AdminPassword WikiName AdminUser
1723

src/Persistence/PageContentFetcher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use MediaWiki\Revision\RevisionLookup;
99
use MediaWiki\Revision\SlotRecord;
1010
use MediaWiki\Title\MalformedTitleException;
11+
use MediaWiki\Title\Title;
1112
use MediaWiki\Title\TitleParser;
1213

1314
class PageContentFetcher {
@@ -20,7 +21,7 @@ public function __construct(
2021

2122
public function getPageContent( string $pageTitle ): ?Content {
2223
try {
23-
$title = $this->titleParser->parseTitle( $pageTitle );
24+
$title = Title::newFromLinkTarget( $this->titleParser->parseTitle( $pageTitle ) );
2425
} catch ( MalformedTitleException ) {
2526
return null;
2627
}

tests/phpunit/EntryPoints/SpecialWikibaseFacetedSearchConfigTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,22 @@
44

55
namespace ProfessionalWiki\WikibaseFacetedSearch\Tests\EntryPoints;
66

7-
use MediaWiki\SpecialPage\SpecialPage;
87
use MediaWiki\Title\Title;
98
use ProfessionalWiki\WikibaseFacetedSearch\WikibaseFacetedSearchExtension;
10-
use SpecialPageTestBase;
119

1210
/**
1311
* @covers \ProfessionalWiki\WikibaseFacetedSearch\EntryPoints\SpecialWikibaseFacetedSearchConfig
1412
*/
15-
class SpecialWikibaseFacetedSearchConfigTest extends SpecialPageTestBase {
16-
17-
protected function newSpecialPage(): SpecialPage {
18-
return $this->getServiceContainer()->getSpecialPageFactory()->getPage( 'WikibaseFacetedSearchConfig' );
19-
}
13+
class SpecialWikibaseFacetedSearchConfigTest extends \MediaWikiIntegrationTestCase {
2014

2115
public function testRedirect(): void {
22-
$specialRules = $this->newSpecialPage();
16+
$specialPage = $this->getServiceContainer()->getSpecialPageFactory()->getPage( 'WikibaseFacetedSearchConfig' );
2317

24-
$specialRules->execute( null );
18+
$specialPage->execute( null );
2519

2620
$this->assertEquals(
2721
Title::newFromText( WikibaseFacetedSearchExtension::CONFIG_PAGE_TITLE, NS_MEDIAWIKI )->getFullURL(),
28-
$specialRules->getOutput()->getRedirect()
22+
$specialPage->getOutput()->getRedirect()
2923
);
3024
}
3125

tests/phpunit/Persistence/SitelinkBasedStatementsLookupTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class SitelinkBasedStatementsLookupTest extends WikibaseFacetedSearchIntegration
3333
private SitelinkBasedStatementsLookup $lookup;
3434

3535
protected function setUp(): void {
36+
parent::setUp();
37+
3638
$this->sitelinkStore = new HashSiteLinkStore();
3739
$this->entityLookup = new InMemoryEntityLookup();
3840
$this->lookup = new SitelinkBasedStatementsLookup(

tests/phpunit/WikibaseFacetedSearchIntegrationTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ protected function deleteConfigPage(): void {
3333
*/
3434
$title = Title::newFromText( 'MediaWiki:' . WikibaseFacetedSearchExtension::CONFIG_PAGE_TITLE );
3535

36-
$this->deletePage( new WikiPage( $title ) );
36+
if ( $title->exists() ) {
37+
$this->deletePage( new WikiPage( $title ) );
38+
}
3739
}
3840

3941
protected function getPageHtml( string $pageTitle ): string {

0 commit comments

Comments
 (0)