Skip to content
book-open

GitHub Action

Mediawiki Extension PHPUnit Runner

v2 Pre-release

Mediawiki Extension PHPUnit Runner

book-open

Mediawiki Extension PHPUnit Runner

Setups MediaWiki and runs PHPUnit test for an extension

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Mediawiki Extension PHPUnit Runner

uses: WikiTeq/mediawiki-phpunit-action@v2

Learn more about this action in WikiTeq/mediawiki-phpunit-action

Choose a version

Mediawiki Extension PHPUnit Runner

The action is a composite action that uses the following actions to install an ephemeral MediaWiki instance with Composer and PHP on board and run PHPUnit tests for your extension or skin repo:

Usage

- uses: wikiteq/mediawiki-phpunit-action@v2
  with:
    php: 7.4
    mwbranch: REL1_35
    extension: DummyExtension

Inputs

  • php - version of PHP to install
  • mwbranch - MediaWiki branch to install
  • extension - extension name to test (this should match the desired extension directory)
  • type - (optional) either can be extension or skin, default value is extension
  • use_mysql - (optional) whether to use MySQL instead of SQLite

Example

The below is an example of how to setup your GitHub Actions workflow on extension repository:

.github/workflows/main.yml

name: Example

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ "*" ]

jobs:
  test:
    name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}"
    strategy:
      matrix:
        include:
          - mw: 'REL1_35'
            php: 7.4
          - mw: 'REL1_36'
            php: 7.4
          - mw: 'REL1_37'
            php: 7.4
          - mw: 'master'
            php: 7.4
    runs-on: ubuntu-latest
    steps:
      # check out the extension repository
      - name: Checkout
        uses: actions/checkout@v3
      # run the action to install MediaWiki, PHP, Composer
      # and run PHPUnit tests for the extension
      - name: Mediawiki PHPUnit
        uses: wikiteq/mediawiki-phpunit-action@v2
        with:
          php: ${{ matrix.php }}
          mwbranch: ${{ matrix.mw }}
          extension: MyExtension

Example of adding a group to your extension tests:

MyExtension/tests/phpunit/MyExtensionTest.php

/**
 * @group extension-MyExtension
 */
class MyExtensionTest extends MediaWikiIntegrationTestCase {
    // ...
}