Skip to content

Commit 3bcccdc

Browse files
Add tests and CI (#4)
* chore (build): add docker compose CI * add Makefile * composer.json: - enable phpcs and linting - add phpunit.xml.dist * add JSONScript test case - add test to display form for creating new page * chg (ci): add matrix for MW 1.39 and MW 1.40 * chg (ci): add matrix for MW 1.42 * chg (ci): update CI - set coverage for MW 1.40 * JsonTestCaseScriptRunnerTest.php - add @group Database * chg (ci): add CODECOV_TOKEN * update JSONScript test case: - add more assertions - check all usage of #createpage parser function * update README.md [skip ci] * chg (ci): update CI, add comment for SMW version * chg (ci): fix SMW version for MW 1.39 --------- Co-authored-by: gesinn-it-ilm <gesinn-it-ilm@gesinn.it>
1 parent 8620992 commit 3bcccdc

File tree

12 files changed

+282
-20
lines changed

12 files changed

+282
-20
lines changed

.env-40

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# docker images
2+
MW_VERSION?=1.40
3+
PHP_VERSION?=8.1
4+
DB_TYPE?=mysql
5+
DB_IMAGE?="mariadb:11.2"
6+
7+
# extensions
8+
SMW_VERSION?=dev-master

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
12+
test:
13+
14+
runs-on: ubuntu-22.04
15+
continue-on-error: ${{ matrix.experimental }}
16+
17+
strategy:
18+
matrix:
19+
include:
20+
- mediawiki_version: '1.39'
21+
smw_version: 4.2.0 # required only for JSONScript testing
22+
php_version: 8.1
23+
database_type: mysql
24+
database_image: "mysql:8"
25+
coverage: false
26+
experimental: false
27+
- mediawiki_version: '1.40'
28+
smw_version: dev-master
29+
php_version: 8.1
30+
database_type: mysql
31+
database_image: "mariadb:11.2"
32+
coverage: true
33+
experimental: false
34+
- mediawiki_version: '1.42'
35+
smw_version: dev-master
36+
php_version: 8.2
37+
database_type: mysql
38+
database_image: "mariadb:11.2"
39+
coverage: false
40+
experimental: true
41+
42+
env:
43+
MW_VERSION: ${{ matrix.mediawiki_version }}
44+
SMW_VERSION: ${{ matrix.smw_version }}
45+
PHP_VERSION: ${{ matrix.php_version }}
46+
DB_TYPE: ${{ matrix.database_type }}
47+
DB_IMAGE: ${{ matrix.database_image }}
48+
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
with:
54+
submodules: recursive
55+
56+
- name: Update submodules
57+
run: git submodule update --init --remote
58+
59+
- name: Run tests
60+
run: make ci
61+
if: matrix.coverage == false
62+
63+
- name: Run tests with coverage
64+
run: make ci-coverage
65+
if: matrix.coverage == true
66+
67+
- name: Upload code coverage
68+
uses: codecov/codecov-action@v4
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
files: coverage/php/coverage.xml
72+
if: matrix.coverage == true

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "build"]
2+
path = build
3+
url = https://github.com/gesinn-it-pub/docker-compose-ci.git

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-include .env
2+
export
3+
4+
# setup for docker-compose-ci build directory
5+
# delete "build" directory to update docker-compose-ci
6+
7+
ifeq (,$(wildcard ./build/))
8+
$(shell git submodule update --init --remote)
9+
endif
10+
11+
12+
EXTENSION=CreatePage
13+
14+
# docker images
15+
MW_VERSION?=1.39
16+
PHP_VERSION?=8.1
17+
DB_TYPE?=mysql
18+
DB_IMAGE?="mysql:8"
19+
20+
# extensions
21+
SMW_VERSION?=4.2.0
22+
23+
# composer
24+
# Enables "composer update" inside of extension
25+
COMPOSER_EXT?=true
26+
27+
# Enables node.js related tests and "npm install"
28+
# NODE_JS?=true
29+
30+
31+
include build/Makefile
32+

README

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[![CI](https://github.com/gesinn-it-pub/CreatePage/actions/workflows/ci.yml/badge.svg)](https://github.com/gesinn-it-pub/CreatePage/actions/workflows/ci.yml)
2+
[![codecov](https://codecov.io/github/gesinn-it-pub/CreatePage/graph/badge.svg?token=O6rJr8X0m3)](https://codecov.io/github/gesinn-it-pub/CreatePage)
3+
4+
# CreatePage
5+
6+
Create Page is a MediaWiki extension that allows placing an input that takes the name of a new page into pages.
7+
8+
Extension page on mediawiki.org: https://www.mediawiki.org/wiki/Extension:Create_Page

build

Submodule build added at 0d02f49

codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fixes:
2+
- "/var/www/html/extensions/CreatePage/::"

composer.json

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
{
2+
"name": "gesinn-it-pub/create-page",
3+
"type": "mediawiki-extension",
24
"require-dev": {
35
"mediawiki/mediawiki-codesniffer": "45.0.0",
6+
"mediawiki/mediawiki-phan-config": "0.14.0",
47
"mediawiki/minus-x": "1.1.3",
58
"php-parallel-lint/php-console-highlighter": "1.0.0",
69
"php-parallel-lint/php-parallel-lint": "1.4.0"
710
},
811
"scripts": {
9-
"fix": [
10-
"minus-x fix .",
11-
"phpcbf"
12-
],
1312
"test": [
14-
"parallel-lint . --exclude vendor --exclude node_modules",
15-
"@phpcs",
16-
"minus-x check ."
13+
"@analyze",
14+
"@phpunit"
1715
],
18-
"phpcs": "phpcs -sp --cache"
19-
},
20-
"config": {
21-
"allow-plugins": {
22-
"dealerdirect/phpcodesniffer-composer-installer": true
23-
}
16+
"test-coverage": [
17+
"@analyze",
18+
"@phpunit-coverage"
19+
],
20+
"analyze": [
21+
"@lint",
22+
"@phpcs"
23+
],
24+
"fix": [
25+
"@phpcs-fix"
26+
],
27+
"lint": "parallel-lint . --exclude vendor --exclude node_modules",
28+
"phpcs": "phpcs -ps",
29+
"phpcs-fix": "phpcbf -p",
30+
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox",
31+
"phpunit-coverage": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml",
32+
"minus-x": "minus-x check ."
2433
}
2534
}

phpunit.xml.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<phpunit colors="true">
2+
<testsuites>
3+
<testsuite name="tests">
4+
<directory>tests/phpunit</directory>
5+
</testsuite>
6+
</testsuites>
7+
<filter>
8+
<whitelist addUncoveredFilesFromWhitelist="false">
9+
<directory suffix=".php">includes</directory>
10+
</whitelist>
11+
</filter>
12+
</phpunit>

0 commit comments

Comments
 (0)