Skip to content

Commit

Permalink
Adds type input to allow testing of skins
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmaka committed May 29, 2022
1 parent ff7b922 commit 790edfb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

# Example

Expand Down
14 changes: 9 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,35 @@ inputs:
testgroup:
description: 'Extension tests @group'
required: true
type:
description: 'Is it an extension or skin'
required: false
default: 'extension'
runs:
using: 'composite'
steps:
- name: Setup PHP
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php }}
extensions: mbstring, intl
tools: composer:2.1.14

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

- name: Install MediaWiki
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.mwbranch }} ${{ inputs.extension }}
run: bash $GITHUB_ACTION_PATH/install.sh ${{ inputs.mwbranch }} ${{ inputs.extension }} ${{ inputs.type }}
shell: bash

- uses: actions/checkout@v2
with:
path: mediawiki/extensions/${{ inputs.extension }}
path: mediawiki/${{ inputs.type }}s/${{ inputs.extension }}

- name: Composer update
- name: Composer updates
working-directory: mediawiki
run: composer update
shell: bash
Expand Down
35 changes: 24 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,48 @@ set -o pipefail

MW_BRANCH=$1
EXTENSION_NAME=$2
TYPE=$3

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

# Extract into `mediawiki` directory
tar -zxf $MW_BRANCH.tar.gz
mv mediawiki-$MW_BRANCH mediawiki

cd mediawiki
# Install composer dependencies
cd mediawiki && composer -q install
php maintenance/install.php \
--dbtype sqlite \
--dbuser root \
--dbname mw \
--dbpath $(pwd) \
--pass DummyAdminPassword DummyWikiName DummyAdminUser > /dev/null

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

# echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php
# echo 'ini_set("display_errors", 1);' >> LocalSettings.php
# https://www.mediawiki.org/wiki/Manual:$wgShowExceptionDetails
echo '$wgShowExceptionDetails = true;' >> LocalSettings.php
# https://www.mediawiki.org/wiki/Manual:$wgShowDBErrorBacktrace , note this is deprecated in 1.37+
echo '$wgShowDBErrorBacktrace = true;' >> LocalSettings.php
# https://www.mediawiki.org/wiki/Manual:$wgDevelopmentWarnings
echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php

echo "wfLoadExtension( '$EXTENSION_NAME' );" >> LocalSettings.php
# Loads extension or skin depending on type option provided
if [ "$TYPE" = "extension" ]; then
echo "wfLoadExtension( '$EXTENSION_NAME' );" >> LocalSettings.php
else
echo "wfLoadSkin( '$EXTENSION_NAME' );" >> LocalSettings.php
fi

# Include everything from `extensions` and `skins` directories
cat <<EOT >> composer.local.json
{
"require": {
},
"require": {},
"extra": {
"merge-plugin": {
"merge-dev": true,
"include": [
"extensions/*/composer.json"
"extensions/*/composer.json",
"skins/*/composer.json"
]
}
}
Expand Down

0 comments on commit 790edfb

Please sign in to comment.