Skip to content

Commit 790edfb

Browse files
committed
Adds type input to allow testing of skins
1 parent ff7b922 commit 790edfb

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The action is a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action)
44
that uses the following actions to install an ephemeral [MediaWiki](https://mediawiki.org) instance with Composer and PHP on board and run
5-
PHPUnit tests for your extension repo:
5+
PHPUnit tests for your extension or skin repo:
66

77
* [shivammathur/setup-php](https://github.com/shivammathur/setup-php)
88
* [actions/cache](https://github.com/actions/cache)
@@ -25,6 +25,7 @@ PHPUnit tests for your extension repo:
2525
* `mwbranch` - MediaWiki branch to install
2626
* `extension` - extension name to test (this should match the desired extension directory)
2727
* `testgroup` - @group of tests to run (this should match your extension group defined on unit tests)
28+
* `type` - (optional) either can be `extension` or `skin`, default value is `extension`
2829

2930
# Example
3031

action.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,35 @@ inputs:
1717
testgroup:
1818
description: 'Extension tests @group'
1919
required: true
20+
type:
21+
description: 'Is it an extension or skin'
22+
required: false
23+
default: 'extension'
2024
runs:
2125
using: 'composite'
2226
steps:
23-
- name: Setup PHP
27+
- name: Install PHP
2428
uses: shivammathur/setup-php@v2
2529
with:
2630
php-version: ${{ inputs.php }}
2731
extensions: mbstring, intl
2832
tools: composer:2.1.14
2933

30-
- name: Cache Composer cache
34+
- name: Add Composer cache
3135
uses: actions/cache@v2
3236
with:
3337
path: ~/.composer/cache
3438
key: composer-php${{ inputs.php }}
3539

3640
- name: Install MediaWiki
37-
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.mwbranch }} ${{ inputs.extension }}
41+
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.mwbranch }} ${{ inputs.extension }} ${{ inputs.type }}
3842
shell: bash
3943

4044
- uses: actions/checkout@v2
4145
with:
42-
path: mediawiki/extensions/${{ inputs.extension }}
46+
path: mediawiki/${{ inputs.type }}s/${{ inputs.extension }}
4347

44-
- name: Composer update
48+
- name: Composer updates
4549
working-directory: mediawiki
4650
run: composer update
4751
shell: bash

install.sh

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,48 @@ set -o pipefail
44

55
MW_BRANCH=$1
66
EXTENSION_NAME=$2
7+
TYPE=$3
78

9+
# Download wiki release
810
wget https://github.com/wikimedia/mediawiki/archive/$MW_BRANCH.tar.gz -nv -q
911

12+
# Extract into `mediawiki` directory
1013
tar -zxf $MW_BRANCH.tar.gz
1114
mv mediawiki-$MW_BRANCH mediawiki
1215

13-
cd mediawiki
16+
# Install composer dependencies
17+
cd mediawiki && composer -q install
18+
php maintenance/install.php \
19+
--dbtype sqlite \
20+
--dbuser root \
21+
--dbname mw \
22+
--dbpath $(pwd) \
23+
--pass DummyAdminPassword DummyWikiName DummyAdminUser > /dev/null
1424

15-
composer -q install
16-
php maintenance/install.php --dbtype sqlite --dbuser root --dbname mw --dbpath $(pwd) --pass AdminPassword WikiName AdminUser > /dev/null
17-
18-
# echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php
19-
# echo 'ini_set("display_errors", 1);' >> LocalSettings.php
25+
# https://www.mediawiki.org/wiki/Manual:$wgShowExceptionDetails
2026
echo '$wgShowExceptionDetails = true;' >> LocalSettings.php
27+
# https://www.mediawiki.org/wiki/Manual:$wgShowDBErrorBacktrace , note this is deprecated in 1.37+
2128
echo '$wgShowDBErrorBacktrace = true;' >> LocalSettings.php
29+
# https://www.mediawiki.org/wiki/Manual:$wgDevelopmentWarnings
2230
echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php
2331

24-
echo "wfLoadExtension( '$EXTENSION_NAME' );" >> LocalSettings.php
32+
# Loads extension or skin depending on type option provided
33+
if [ "$TYPE" = "extension" ]; then
34+
echo "wfLoadExtension( '$EXTENSION_NAME' );" >> LocalSettings.php
35+
else
36+
echo "wfLoadSkin( '$EXTENSION_NAME' );" >> LocalSettings.php
37+
fi
2538

39+
# Include everything from `extensions` and `skins` directories
2640
cat <<EOT >> composer.local.json
2741
{
28-
"require": {
29-
30-
},
42+
"require": {},
3143
"extra": {
3244
"merge-plugin": {
3345
"merge-dev": true,
3446
"include": [
35-
"extensions/*/composer.json"
47+
"extensions/*/composer.json",
48+
"skins/*/composer.json"
3649
]
3750
}
3851
}

0 commit comments

Comments
 (0)