|
| 1 | +# Mediawiki Extension PHPUnit Runner |
| 2 | + |
| 3 | +The action is a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action) |
| 4 | +that uses the following actions to install an ephemeral MediaWiki instance with Composer and PHP on board and run |
| 5 | +PHPUnit tests for your extension repo: |
| 6 | + |
| 7 | +* [shivammathur/setup-php](https://github.com/shivammathur/setup-php) |
| 8 | +* [actions/cache](https://github.com/actions/cache) |
| 9 | +* [actions/checkout](https://github.com/actions/checkout) |
| 10 | + |
| 11 | +# Usage |
| 12 | + |
| 13 | +```yaml |
| 14 | +- uses: actions/mediawiki-phpunit@v1 |
| 15 | + with: |
| 16 | + php: 7.4 |
| 17 | + mwbranch: REL1_35 |
| 18 | + extension: DummyExtension |
| 19 | + testgroup: extension-DummyExtension |
| 20 | +``` |
| 21 | +
|
| 22 | +# Inputs |
| 23 | +
|
| 24 | +* `php` - version of PHP to install |
| 25 | +* `mwbranch` - MediaWiki branch to install |
| 26 | +* `extension` - extension name to test (this should match the desired extension directory) |
| 27 | +* `testgroup` - @group of tests to run (this should match your extension group defined on unit tests) |
| 28 | + |
| 29 | +# Example |
| 30 | + |
| 31 | +The below is an example of how to setup your GitHub Actions workflow on extension repository: |
| 32 | + |
| 33 | +`.github/workflows/main.yml` |
| 34 | + |
| 35 | +```yaml |
| 36 | +name: Example |
| 37 | +
|
| 38 | +on: |
| 39 | + push: |
| 40 | + branches: [ master ] |
| 41 | + pull_request: |
| 42 | + branches: [ "*" ] |
| 43 | +
|
| 44 | +jobs: |
| 45 | + test: |
| 46 | + name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}" |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + include: |
| 50 | + - mw: 'REL1_35' |
| 51 | + php: 7.4 |
| 52 | + - mw: 'REL1_36' |
| 53 | + php: 7.4 |
| 54 | + - mw: 'REL1_37' |
| 55 | + php: 7.4 |
| 56 | + - mw: 'master' |
| 57 | + php: 7.4 |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + # check out the extension repository |
| 61 | + - name: Checkout |
| 62 | + uses: actions/checkout@v3 |
| 63 | + # run the action to install MediaWiki, PHP, Composer |
| 64 | + # and run PHPUnit tests for the extension |
| 65 | + - name: Mediawiki PHPUnit |
| 66 | + uses: actions/mediawiki-phpunit@v1 |
| 67 | + with: |
| 68 | + php: ${{ matrix.php }} |
| 69 | + mwbranch: ${{ matrix.mw }} |
| 70 | + extension: MyExtension |
| 71 | + testgroup: extension-MyExtension |
| 72 | +``` |
| 73 | + |
| 74 | +Example of adding a group to your extension tests: |
| 75 | + |
| 76 | +`MyExtension/tests/phpunit/MyExtensionTest.php` |
| 77 | + |
| 78 | +```php |
| 79 | +/** |
| 80 | + * @group extension-MyExtension |
| 81 | + */ |
| 82 | +class MyExtensionTest extends MediaWikiTestCase { |
| 83 | + // ... |
| 84 | +} |
| 85 | +``` |
0 commit comments