From 3e2141713501436cd2aac402034910ec7b696506 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 10:36:18 +0200 Subject: [PATCH 01/12] chore (build): add CI --- .gitmodules | 3 +++ build | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2d846d0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build"] + path = build + url = https://github.com/gesinn-it-pub/docker-compose-ci.git diff --git a/build b/build new file mode 160000 index 0000000..3c2344c --- /dev/null +++ b/build @@ -0,0 +1 @@ +Subproject commit 3c2344c631a9023b228fd9970c8daf0583b333e1 From 6801cf7fcb4ddf5da09aa6f1b79b33c3e40c056a Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 10:48:07 +0200 Subject: [PATCH 02/12] Makefile: update file to use docker-compose CI approach --- Makefile | 68 ++++++++++++++++++-------------------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 98daee9..8c2ce58 100644 --- a/Makefile +++ b/Makefile @@ -1,54 +1,30 @@ -EXTENSION := QRLite +export -MW_VERSION ?= 1.35 +# setup for docker-compose-ci build directory +# delete "build" directory to update docker-compose-ci -EXTENSION_FOLDER := /var/www/html/extensions/$(EXTENSION) -IMAGE_NAME := $(shell echo $(EXTENSION) | tr A-Z a-z}):test-$(MW_VERSION)-$(SMW_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) +ifeq (,$(wildcard ./build/Makefile)) + $(shell git submodule update --init --remote) +endif -.PHONY: all -all: +EXTENSION=qrlite -# ======== CI ======== +# docker images +MW_VERSION?=1.35 +PHP_VERSION?=7.4 +DB_TYPE?=mysql +DB_IMAGE?="mysql:5.7" -.PHONY: ci -ci: build test +# extensions +SMW_VERSION?=4.2.0 -.PHONY: ci-coverage -ci-coverage: build test-coverage +# composer +# Enables "composer update" inside of extension +COMPOSER_EXT?=true -.PHONY: build -build: - docker build --tag $(IMAGE_NAME) \ - --build-arg=MW_VERSION=$(MW_VERSION) \ - . +# nodejs +# Enables node.js related tests and "npm install" +# NODE_JS?=true -.PHONY: test -test: composer-test npm-test - -.PHONY: test-coverage -test-coverage: composer-test-coverage - -.PHONY: composer-test -composer-test: - $(docker_run) composer test - -.PHONY: npm-test -npm-test: - $(docker_run) npm run 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 \ - -v $(PWD):$(EXTENSION_FOLDER) -v $(EXTENSION_FOLDER)/node_modules -v $(EXTENSION_FOLDER)/vendor \ - -w $(EXTENSION_FOLDER) $(IMAGE_NAME) bash +# check for build dir and git submodule init if it does not exist +include build/Makefile \ No newline at end of file From 6234c97e74f28eddb7e25e61c67decf2fcc22848 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 10:48:49 +0200 Subject: [PATCH 03/12] composer.json: add linting and phpcs, update scripts part --- composer.json | 33 +++++++++++++++++++++++---------- phpunit.xml.dist | 12 ++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 phpunit.xml.dist diff --git a/composer.json b/composer.json index 2f4072d..1f72026 100644 --- a/composer.json +++ b/composer.json @@ -17,25 +17,38 @@ "endroid/qr-code": "^4.6" }, "require-dev": { - "php-parallel-lint/php-parallel-lint": "1.3.2", - "mediawiki/mediawiki-codesniffer": "41.0.0", + "mediawiki/mediawiki-codesniffer": "43.0.0", + "mediawiki/mediawiki-phan-config": "0.14.0", + "mediawiki/minus-x": "1.1.3", "php-parallel-lint/php-console-highlighter": "1.0.0", - "mediawiki/minus-x": "1.1.1" + "php-parallel-lint/php-parallel-lint": "1.4.0" }, "scripts": { "test": [ - "parallel-lint . --exclude vendor --exclude node_modules", - "phpcs -p -s", - "minus-x check ." + "@analyze", + "@phpunit" + ], + "test-coverage": [ + "@analyze", + "@phpunit-coverage" + ], + "analyze": [ + "@lint", + "@phpcs" ], "fix": [ - "minus-x fix .", - "phpcbf" - ] + "@phpcs-fix" + ], + "lint": "parallel-lint . --exclude vendor --exclude node_modules", + "phpcs": "phpcs -ps", + "phpcs-fix": "phpcbf -p", + "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", + "minus-x": "minus-x check ." }, "config": { "allow-plugins": { - "composer/installers": true + "dealerdirect/phpcodesniffer-composer-installer": true } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..1cf9dd9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,12 @@ + + + + tests + + + + + src + + + \ No newline at end of file From ecbe620081e397b5245d10265ad2a21af30316db Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 11:02:59 +0200 Subject: [PATCH 04/12] chg (ci.yml): update CI - update ubuntu version - update matrix - update steps part --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++---- Makefile | 1 - 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c44ae..cee2867 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,26 +11,43 @@ jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 continue-on-error: ${{ matrix.experimental }} strategy: matrix: include: - mediawiki_version: '1.35' + php_version: 8.1 + database_type: mysql + database_image: "mysql:5.7" coverage: false experimental: false - mediawiki_version: '1.39' + php_version: 8.1 + database_type: mysql + database_image: "mysql:8" coverage: false - experimental: true + experimental: false + - mediawiki_version: '1.39' + php_version: 8.1 + database_type: mysql + database_image: "mariadb:10" + coverage: false + experimental: false env: MW_VERSION: ${{ matrix.mediawiki_version }} steps: - name: Checkout - uses: actions/checkout@v3 - + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Update submodules + run: git submodule update --init --remote + - name: Run tests run: make ci if: matrix.coverage == false @@ -38,3 +55,10 @@ jobs: - name: Run tests with coverage run: make ci-coverage if: matrix.coverage == true + + - name: Upload code coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/php/coverage.xml + if: matrix.coverage == true diff --git a/Makefile b/Makefile index 8c2ce58..550ee2e 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,6 @@ DB_TYPE?=mysql DB_IMAGE?="mysql:5.7" # extensions -SMW_VERSION?=4.2.0 # composer # Enables "composer update" inside of extension From c4edfbbbdab022963a736ab0aff90a74fec0cc72 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 11:08:06 +0200 Subject: [PATCH 05/12] chg (ci.yml): update environments variables --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cee2867..127348c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,9 @@ jobs: env: MW_VERSION: ${{ matrix.mediawiki_version }} + PHP_VERSION: ${{ matrix.php_version }} + DB_TYPE: ${{ matrix.database_type }} + DB_IMAGE: ${{ matrix.database_image }} steps: - name: Checkout From 01f1e0bab47d084d32fdb8ff4cd2e9470876be08 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 11:16:45 +0200 Subject: [PATCH 06/12] chg (ci.yml): add matrix for MW 1.43 --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 127348c..1091372 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,10 @@ jobs: database_image: "mysql:8" coverage: false experimental: false - - mediawiki_version: '1.39' - php_version: 8.1 + - mediawiki_version: '1.43' + php_version: 8.2 database_type: mysql - database_image: "mariadb:10" + database_image: "mysql:8" coverage: false experimental: false @@ -42,6 +42,7 @@ jobs: DB_TYPE: ${{ matrix.database_type }} DB_IMAGE: ${{ matrix.database_image }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -64,4 +65,4 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage/php/coverage.xml - if: matrix.coverage == true + if: matrix.coverage == true \ No newline at end of file From 8e6e5240b848869e61e7324bd280241764e4fdf1 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 11:23:31 +0200 Subject: [PATCH 07/12] composer.json: fix Composer plugin blocked error for QRLite extension - Added "composer/installers" to "allow-plugins" in composer.json to allow MediaWiki extension installation during composer update. --- .github/workflows/ci.yml | 2 +- composer.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1091372..a06cadc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: include: - mediawiki_version: '1.35' - php_version: 8.1 + php_version: 7.4 database_type: mysql database_image: "mysql:5.7" coverage: false diff --git a/composer.json b/composer.json index 1f72026..3742fb0 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,8 @@ }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "composer/installers": true } } } From c8d2682825fdc9d21b1a539156dfcdbdf1805291 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 12:19:58 +0200 Subject: [PATCH 08/12] update phpcs.xml and phpunit.xml.dist --- .phpcs.xml | 10 ++++++---- phpunit.xml.dist | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index ba94844..2322368 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,7 +1,9 @@ - + . - lib/ - vendor/ - + /(vendor|conf)/ + extensions/* + + + \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1cf9dd9..f22effa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - tests + tests/phpunit/Unit From 201b7a4d55bc537bb41bd3a0d6f4077851b55d4b Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 12:31:08 +0200 Subject: [PATCH 09/12] phpunit.xml.dist: update testsuites --- phpunit.xml.dist | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f22effa..3894fc2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,12 @@ - + tests/phpunit/Unit - - src + + src \ No newline at end of file From 7dffdf9a600d72d709a7e155cb83ddbc6e84612e Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Fri, 12 Sep 2025 12:46:06 +0200 Subject: [PATCH 10/12] tests: add Unit folder for PHPUnit --- tests/phpunit/Unit/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/phpunit/Unit/.gitkeep diff --git a/tests/phpunit/Unit/.gitkeep b/tests/phpunit/Unit/.gitkeep new file mode 100644 index 0000000..e69de29 From 8c91ec543b6defe9df48592ec08925de85c9b46a Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Mon, 15 Sep 2025 10:57:37 +0200 Subject: [PATCH 11/12] QRLiteFunctions: add Unit tests --- Makefile | 5 +++ tests/phpunit/Unit/QRLiteFunctionsTest.php | 44 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/phpunit/Unit/QRLiteFunctionsTest.php diff --git a/Makefile b/Makefile index 550ee2e..e1a4e8d 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,11 @@ DB_TYPE?=mysql DB_IMAGE?="mysql:5.7" # extensions +# Enables installation of apt packages for gd extension +OS_PACKAGES?="zlib1g-dev libpng-dev" + +# Enables installation of gd extension +PHP_EXTENSIONS?=gd # composer # Enables "composer update" inside of extension diff --git a/tests/phpunit/Unit/QRLiteFunctionsTest.php b/tests/phpunit/Unit/QRLiteFunctionsTest.php new file mode 100644 index 0000000..dd878f3 --- /dev/null +++ b/tests/phpunit/Unit/QRLiteFunctionsTest.php @@ -0,0 +1,44 @@ + 'TestSVG', + 'format' => 'svg', + ]; + + $html = QRLiteFunctions::generateQRCode( $params ); + + $this->assertStringContainsString( 'assertStringContainsString( ' 'TestPNG', + 'format' => 'png', + ]; + + $html = QRLiteFunctions::generateQRCode( $params ); + + // Ovde očekujemo tag, ne + $this->assertStringContainsString( 'assertStringContainsString( 'src="data:image/png;base64', $html ); + $this->assertStringContainsString( 'title="TestPNG"', $html ); + } +} From 3e486b081e3dee2be0e5d5cd29c2df88995ce7b5 Mon Sep 17 00:00:00 2001 From: gesinn-it-ilm Date: Mon, 15 Sep 2025 11:00:39 +0200 Subject: [PATCH 12/12] chg (ci.yml): add support for MW 1.44 --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06cadc..6fe0c6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,12 @@ jobs: database_image: "mysql:8" coverage: false experimental: false + - mediawiki_version: '1.44' + php_version: 8.3 + database_type: mysql + database_image: "mysql:8" + coverage: false + experimental: true env: MW_VERSION: ${{ matrix.mediawiki_version }}