Skip to content

Commit

Permalink
Merge pull request #15 from gesinn-it-pub/master
Browse files Browse the repository at this point in the history
Modernizing towards MW 1.37
  • Loading branch information
mmarx authored Oct 31, 2024
2 parents ffcc192 + 1945b9d commit 5a4ee90
Show file tree
Hide file tree
Showing 16 changed files with 1,137 additions and 153 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:

ci:

runs-on: ubuntu-20.04
continue-on-error: ${{ matrix.experimental }}

strategy:
matrix:
include:
- mediawiki_version: '1.35'
experimental: false
- mediawiki_version: '1.36'
experimental: true
- mediawiki_version: '1.37'
experimental: true

env:
MW_VERSION: ${{ matrix.mediawiki_version }}

steps:
- uses: actions/checkout@v3
- run: make ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor
coverage
.phpunit.result.cache
.vscode
17 changes: 17 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>
<file>.</file>
<arg name="bootstrap" value="./vendor/mediawiki/mediawiki-codesniffer/utils/bootstrap-ci.php"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="UTF-8"/>
</ruleset>
10 changes: 5 additions & 5 deletions AutoCreatePage.i18n.magic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

/**
* Magic words
*
*
* @file
*/

$magicWords = array();
$magicWords = [];

/** English (English) */
$magicWords['en'] = array(
'createPage' => array( 0, 'createpageifnotex' ),
);
$magicWords['en'] = [
'createPage' => [ 0, 'createpageifnotex' ],
];
148 changes: 0 additions & 148 deletions AutoCreatePage.php

This file was deleted.

15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG MW_VERSION=1.35
FROM gesinn/docker-mediawiki-sqlite:${MW_VERSION}

ENV EXTENSION=AutoCreatePage
COPY composer*.json /var/www/html/extensions/$EXTENSION/

RUN cd extensions/$EXTENSION && \
composer update

COPY . /var/www/html/extensions/$EXTENSION

RUN sed -i s/80/8080/g /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && \
echo \
"wfLoadExtension( '$EXTENSION' );\n" \
>> LocalSettings.php
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
EXTENSION := AutoCreatePage

MW_VERSION ?= 1.35

EXTENSION_FOLDER := /var/www/html/extensions/$(EXTENSION)
IMAGE_NAME := $(shell echo $(EXTENSION) | tr A-Z a-z}):test-$(MW_VERSION)
PWD := $(shell bash -c "pwd -W 2>/dev/null || pwd")# this way it works on Windows and Linux
DOCKER_RUN_ARGS := --rm -v $(PWD)/coverage:$(EXTENSION_FOLDER)/coverage -w $(EXTENSION_FOLDER) $(IMAGE_NAME)
docker_run := docker run $(DOCKER_RUN_ARGS)

.PHONY: all
all:

# ======== CI ========

.PHONY: ci
ci: build test

.PHONY: ci-coverage
ci-coverage: build test-coverage

.PHONY: build
build:
docker build --tag $(IMAGE_NAME) \
--build-arg=MW_VERSION=$(MW_VERSION) \
.

.PHONY: test
test: composer-test

.PHONY: test-coverage
test-coverage: composer-test-coverage

.PHONY: composer-test
composer-test:
$(docker_run) composer test

.PHONY: composer-test-coverage
composer-test-coverage:
$(docker_run) composer test-coverage

.PHONY: bash
bash:
docker run -it -v $(PWD):/src $(DOCKER_RUN_ARGS) bash

.PHONY: dev-bash
dev-bash:
docker run -it --rm -p 8080:8080 \
-v $(PWD):$(EXTENSION_FOLDER) \
-v $(EXTENSION_FOLDER)/vendor/ \
-w $(EXTENSION_FOLDER) $(IMAGE_NAME) bash -c 'service apache2 start && bash'
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"require-dev": {
"mediawiki/mediawiki-codesniffer": "39.0.0",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpstan/phpstan": "^1.7"
},
"scripts": {
"test": [
"@analyze",
"@phpunit"
],
"test-coverage": [
"@analyze",
"@phpunit-coverage"
],
"analyze": [
"@lint",
"@phpcs",
"@phpstan"
],
"lint": "parallel-lint . --exclude vendor",
"phpcs": "phpcs -p -s .",
"phpcs-fix": "phpcbf .",
"phpstan": "phpstan analyse --configuration=phpstan.neon --memory-limit=2G",
"phpstan-baseline": "phpstan analyse --configuration=phpstan.neon --memory-limit=2G --generate-baseline",
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox",
"phpunit-coverage": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml"
}
}
Loading

0 comments on commit 5a4ee90

Please sign in to comment.