Skip to content

Commit

Permalink
(tests) Check how outdated are dependencies of Selenium testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Jan 1, 2025
1 parent a2f065f commit 7099047
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 203 deletions.
176 changes: 3 additions & 173 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,182 +1,12 @@
name: Run PHPUnit testsuite
name: Run Selenium testsuite

on: [push, pull_request, workflow_dispatch]

env:
PARALLEL_PHPUNIT_TESTS: 4
DBNAME: testwiki
DBPASS: "123456"
MEDIAWIKI_USER: "Moderator User"
MEDIAWIKI_PASSWORD: "123456"

jobs:
# Job #1: PHPUnit testsuite (unit tests + integration tests)
phpunit:
strategy:
fail-fast: false
matrix:
php: [8.1]
branch: [REL1_39, REL1_40, REL1_41, REL1_42, REL1_43]
dbtype: [mysql, postgres]
env:
branch: ${{ matrix.branch }}
DBTYPE: ${{ matrix.dbtype }}
runs-on: ubuntu-24.04
services:
memcached:
image: memcached:latest
ports:
- 11211:11211
options: --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/11211'" --health-interval 10s --health-timeout 5s --health-retries 5
mariadb:
image: mariadb:11.4
env:
MYSQL_ROOT_PASSWORD: ${{ env.DBPASS }}
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:latest
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: ${{ env.DBPASS }}
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
buildcache
key: buildcache-${{ env.branch }}-${{ hashFiles('**/no/files/need/to/invalidate/cache/for/now') }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, opcache, mysqli
tools: composer
ini-values: zend.enable_gc=Off, opcache.enable_cli=1, opcache.file_cache="/dev/shm", opcache.file_cache_only=1, opcache.file_cache_consistency_checks=0, opcache.validate_timestamps=0
- name: (debug) Print "php -i"
run: php -i
- uses: edwardspec/github-action-build-mediawiki@v1
with:
branch: ${{ env.branch }}
extraLocalSettings: tests/travis/ModerationSettings.php
extensions: "AbuseFilter CheckUser Echo MobileFrontend PageForms VisualEditor"
skins: "MinervaNeue"
dbtype: ${{ env.DBTYPE }}
dbname: ${{ env.DBNAME }}
dbpass: ${{ env.DBPASS }}
dbserver: ${{ env.DBTYPE == 'mysql' && '127.0.0.1:3306' || '127.0.0.1' }}

- name: Finalize the installation of MediaWiki
run: |
cp -fv tests/travis/my.cnf ~/.my.cnf
cp -fv tests/travis/pgpass.conf ~/.pgpass
chmod 0600 ~/.my.cnf ~/.pgpass
rsync -a --exclude buildcache --exclude mediawiki --exclude .git . mediawiki/extensions/Moderation/
cd mediawiki && echo 'DELETE FROM recentchanges;' | php maintenance/sql.php
( cd extensions/AbuseFilter && composer update --no-dev )
WITH_ECHO=1 php maintenance/update.php --quick
php maintenance/createAndPromote.php "$MEDIAWIKI_USER" "$MEDIAWIKI_PASSWORD" --custom-groups moderator,automoderated
( cd extensions/Moderation && composer install ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }} )
echo '{{CURRENTVERSION}}' | php maintenance/parse.php
( cd extensions/Moderation/tests/phpunit/consequence && ln -sv ../unit/*Test.php . )
# Start by running non-blackbox unit tests that can use temporary DB tables.
# These tests are much faster than the integration testsuite.
- name: Run non-blackbox unit tests (very fast)
run: cd mediawiki && php tests/phpunit/phpunit.php extensions/Moderation/tests/phpunit/consequence/

# Run all tests.
- name: Run integration tests (blackbox)
run: cd mediawiki && PHPUNIT_USE_NORMAL_TABLES=1 php tests/phpunit/phpunit.php extensions/Moderation/tests/phpunit/blackbox
- name: Run integration tests (decoupled)
run: cd mediawiki && PHPUNIT_USE_NORMAL_TABLES=1 php tests/phpunit/phpunit.php extensions/Moderation/tests/phpunit/decoupled

# Job #2: phpcs, parallel-lint, etc.
# Run eslint (JavaScript linter)
linter:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer
- uses: actions/cache@v4
with:
path: ~/.composer/cache
key: buildcache-linter
- name: Install dependencies
run: composer install && npm install
- run: composer test
- run: npm install
- run: npm test

# Job #3: Phan (PHP static analyzer)
phan:
runs-on: ubuntu-24.04
env:
branch: REL1_43
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: ast
tools: composer
- uses: actions/cache@v4
with:
path: |
~/.composer/cache
buildcache
key: buildcache-phan
- uses: edwardspec/github-action-build-mediawiki@v1
with:
branch: ${{ env.branch }}
noinstall: 1
extensions: "AbuseFilter CheckUser Echo MobileFrontend PageForms VisualEditor"
skins: "MinervaNeue"
- name: Install dependencies
run: |
rsync -a --exclude buildcache --exclude mediawiki --exclude .git . mediawiki/extensions/Moderation/
cd mediawiki/extensions/Moderation
composer install
- name: RUN -- phan
run: cd mediawiki/extensions/Moderation && ./vendor/bin/phan --analyze-twice

# Job #4: Phan (PHP static analyzer) with PHAN_CHECK_TESTSUITE=1
phan-testsuite:
if: ${{ github.ref == 'refs/heads/phpunit' }}
runs-on: ubuntu-24.04
env:
branch: REL1_43
PHAN_CHECK_TESTSUITE: 1
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: ast
tools: composer
- uses: actions/cache@v4
with:
path: |
~/.composer/cache
buildcache
key: buildcache-phan
- uses: edwardspec/github-action-build-mediawiki@v1
with:
branch: ${{ env.branch }}
noinstall: 1
extensions: "AbuseFilter CheckUser Echo MobileFrontend PageForms VisualEditor"
skins: "MinervaNeue"
- name: Install dependencies
run: |
rsync -a --exclude buildcache --exclude mediawiki --exclude .git . mediawiki/extensions/Moderation/
cd mediawiki/extensions/Moderation
composer install
# Workaround incorrect annotation of with() method in PHPUnit 9 (used in MediaWiki 1.43)
# to avoid over 100 false positive Phan warnings.
sed -i '/@param mixed\[\] \$arguments/d' ../../vendor/phpunit/phpunit/src/Framework/MockObject/Builder/InvocationMocker.php
- name: RUN -- phan
run: cd mediawiki/extensions/Moderation && ./vendor/bin/phan --analyze-twice
32 changes: 14 additions & 18 deletions tests/selenium/package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"private": true,
"devDependencies": {
"@wdio/cli": "^5.10.0",
"@wdio/local-runner": "^5.10.4",
"@wdio/mocha-framework": "^5.10.1",
"@wdio/sauce-service": "^5.9.3",
"@wdio/selenium-standalone-service": "^5.16.5",
"@wdio/spec-reporter": "^5.9.3",
"@wdio/sync": "^5.10.1",
"bluebird": "^3.5.1",
"chai": "^3.5.0",
"chromedriver": "^75.0.0",
"deepmerge": "^1.5.2",
"fs-ext": "^1.2.1",
"mocha": "^5.2.0",
"mwbot": "^1.0.10",
"request": "^2.75.0",
"url": "^0.11.0",
"wdio-chromedriver-service": "^5.0.2",
"wdio-mediawiki": "^0.3.0"
"@wdio/cli": "^6.6.3",
"@wdio/local-runner": "^6.6.3",
"@wdio/mocha-framework": "^6.6.3",
"@wdio/spec-reporter": "^6.6.3",
"@wdio/sync": "^6.6.3",
"bluebird": "^3.7.2",
"chai": "^5.1.2",
"deepmerge": "^4.3.1",
"fs-ext": "^2.1.1",
"mocha": "^11.0.1",
"mwbot": "^2.1.3",
"request": "^2.88.2",
"url": "^0.11.4",
"wdio-mediawiki": "^2.5.0"
}
}
20 changes: 10 additions & 10 deletions tests/selenium/specs/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var PageName = 'Test ' + browser.getTestString(),

describe( 'Postedit notification', function () {

before( function () {
before( async () => {
ExistingPagePromise = browser.precreatePageAsync();
browser.loginIntoNewAccount();
} );
Expand All @@ -42,12 +42,12 @@ describe( 'Postedit notification', function () {
doTestEdit( PageName );
} );

it( 'should be visible', function () {
it( 'should be visible', async function () {
PostEdit.init();
expect( PostEdit.notification.isDisplayed(), 'notification.isDisplayed' ).to.be.true;
} );

it( 'shouldn\'t contain default text (for wikis without Moderation)', function () {
it( 'shouldn\'t contain default text (for wikis without Moderation)', async function () {
/* i18n messages from MediaWiki core:
postedit-confirmation-created
postedit-confirmation-saved
Expand All @@ -56,16 +56,16 @@ describe( 'Postedit notification', function () {
expect( PostEdit.text ).to.not.contain( 'Your edit was saved' );
} );

it ( 'should contain "Pending Review" icon', function () {
it ( 'should contain "Pending Review" icon', async function () {
expect( PostEdit.pendingIcon.isDisplayed(), 'pendingIcon.isDisplayed' ).to.be.true;
} );

it ( 'should say "your edit has been sent to moderation"', function () {
it ( 'should say "your edit has been sent to moderation"', async function () {
expect( PostEdit.text )
.to.contain( 'Success: your edit has been sent to moderation' );
} );

it ( 'should contain "continue editing" link', function () {
it ( 'should contain "continue editing" link', async function () {

expect( PostEdit.editLink.isDisplayed(), 'editLink.isDisplayed' ).to.be.true;

Expand All @@ -75,11 +75,11 @@ describe( 'Postedit notification', function () {
.to.equal( 'edit' );
} );

it ( 'shouldn\'t contain "sign up" link if the user is logged in', function () {
it ( 'shouldn\'t contain "sign up" link if the user is logged in', async function () {
expect( PostEdit.signupLink.isDisplayed(), 'signupLink.isDisplayed' ).to.be.false;
} );

it ( 'shouldn\'t disappear after 3.5 seconds', function () {
it ( 'shouldn\'t disappear after 3.5 seconds', async function () {
/* Default postedit notification of MediaWiki is removed after 3.5 seconds
(because it's not important whether the user reads it or not).
Expand All @@ -91,13 +91,13 @@ describe( 'Postedit notification', function () {
expect( PostEdit.notification.isDisplayed(), 'notification.isDisplayed' ).to.be.true;
} );

it ( 'should be removed when you click on it', function () {
it ( 'should be removed when you click on it', async function () {
/* Clicking on notification should remove it */
PostEdit.notification.click();
PostEdit.notification.waitForDisplayed( 500, true ); /* Wait for it to vanish */
} );

it ( 'should be shown after editing the existing article', function () {
it ( 'should be shown after editing the existing article', async function () {
/*
Older MobileFrontend (for MediaWiki <=1.26) reloaded the page
when creating a new article and didn't reload it when editing
Expand Down
4 changes: 2 additions & 2 deletions tests/selenium/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ exports.config = {
],
maxInstances: 1,
capabilities: [
/*
{
browserName: 'firefox',
"moz:firefoxOptions": {
args: ['-headless']
}
},
/*
*/
{
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--headless', '--disable-gpu', '--window-size=1280,800']
}
}
*/

],
sync: true,
Expand Down

0 comments on commit 7099047

Please sign in to comment.