From 513429a8750890954c79c645427463d33c76f426 Mon Sep 17 00:00:00 2001 From: Luke Eversfield Date: Mon, 16 Oct 2023 09:23:09 +0200 Subject: [PATCH 1/3] use build-tools --- Dockerfile | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f64248..9da353a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ARG PHP_VERSION # get needed dependencies for this extension RUN sed -i s/80/8080/g /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki ${SMW_VERSION} +RUN composer-require.sh mediawiki/semantic-media-wiki ${SMW_VERSION} RUN composer update diff --git a/Makefile b/Makefile index b2412b3..347eed4 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ IMAGE_NAME := $(extension):test-$(MW_VERSION)-$(SMW_VERSION)-$(PS_VERSION)-$(AL_ # ======== CI ENV Variables ======== MW_VERSION ?= 1.35 -SMW_VERSION ?= 4.1.0 +SMW_VERSION ?= 4.1.2 PHP_VERSION ?= 7.4 DB_TYPE ?= sqlite DB_IMAGE ?= "" From 9b8738b9fb00636080d81dc529aa640a8aaf0942 Mon Sep 17 00:00:00 2001 From: Luke Eversfield Date: Wed, 18 Oct 2023 10:10:19 +0200 Subject: [PATCH 2/3] implement new docker-compose-ci based off repository --- .github/workflows/ci.yml | 2 + .gitmodules | 3 + Dockerfile | 29 ------- Makefile | 176 +++++---------------------------------- build | 1 + composer.json | 6 ++ docker-compose-ci.yml | 4 - docker-compose-dev.yml | 8 -- docker-compose.yml | 29 ------- 9 files changed, 32 insertions(+), 226 deletions(-) create mode 100644 .gitmodules delete mode 100644 Dockerfile create mode 160000 build delete mode 100644 docker-compose-ci.yml delete mode 100644 docker-compose-dev.yml delete mode 100644 docker-compose.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1323617..5b55f94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + submodules: recursive - name: Run tests run: make ci diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8ada071 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build"] + path = build + url = git@github.com:gesinn-it-pub/docker-compose-ci.git diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9da353a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -ARG MW_VERSION -ARG PHP_VERSION -FROM gesinn/mediawiki-ci:${MW_VERSION}-php${PHP_VERSION} - -ARG MW_VERSION -ARG SMW_VERSION -ARG PHP_VERSION - -# get needed dependencies for this extension -RUN sed -i s/80/8080/g /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf - -RUN composer-require.sh mediawiki/semantic-media-wiki ${SMW_VERSION} -RUN composer update - - -RUN chown -R www-data:www-data /var/www/html/extensions/SemanticMediaWiki/ - -ENV EXTENSION=SemanticCompoundQueries -COPY composer*.json package*.json /var/www/html/extensions/$EXTENSION/ - -RUN cd extensions/$EXTENSION && composer update - -COPY . /var/www/html/extensions/$EXTENSION - -RUN echo \ - "wfLoadExtension( 'SemanticMediaWiki' );\n" \ - "enableSemantics( 'localhost' );\n" \ - "wfLoadExtension( '$EXTENSION' );\n" \ - >> __setup_extension__ diff --git a/Makefile b/Makefile index 347eed4..857b85b 100644 --- a/Makefile +++ b/Makefile @@ -1,168 +1,32 @@ -include .env export -# ======== Naming ======== -EXTENSION := SemanticCompoundQueries -EXTENSION_FOLDER := /var/www/html/extensions/$(EXTENSION) -extension := $(shell echo $(EXTENSION) | tr A-Z a-z}) -IMAGE_NAME := $(extension):test-$(MW_VERSION)-$(SMW_VERSION)-$(PS_VERSION)-$(AL_VERSION)-$(MAPS_VERSION)-$(SRF_VERSION) +# setup for docker-compose-ci build directory +# delete "build" directory to update docker-compose-ci - -# ======== CI ENV Variables ======== -MW_VERSION ?= 1.35 -SMW_VERSION ?= 4.1.2 -PHP_VERSION ?= 7.4 -DB_TYPE ?= sqlite -DB_IMAGE ?= "" - - -environment = IMAGE_NAME=$(IMAGE_NAME) \ -MW_VERSION=$(MW_VERSION) \ -SMW_VERSION=$(SMW_VERSION) \ -PHP_VERSION=$(PHP_VERSION) \ -DB_TYPE=$(DB_TYPE) \ -DB_IMAGE=$(DB_IMAGE) \ -EXTENSION_FOLDER=$(EXTENSION_FOLDER) - - -ifneq (,$(wildcard ./docker-compose.override.yml)) - COMPOSE_OVERRIDE=-f docker-compose.override.yml +ifeq (,$(wildcard ./build/)) + $(shell git submodule update --init --remote) endif +EXTENSION=SemanticCompoundQueries -compose = $(environment) docker-compose $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS) -compose-ci = $(environment) docker-compose -f docker-compose.yml -f docker-compose-ci.yml $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS) -compose-dev = $(environment) docker-compose -f docker-compose.yml -f docker-compose-dev.yml $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS) - -compose-run = $(compose) run -T --rm -compose-exec-wiki = $(compose) exec -T wiki - -show-current-target = @echo; echo "======= $@ ========" - -# ======== CI ======== -# ======== Global Targets ======== - -.PHONY: ci -ci: install composer-test - -.PHONY: ci-coverage -ci-coverage: install composer-test-coverage - -.PHONY: install -install: destroy up .install - -.PHONY: up -up: .init .build .up - -.PHONY: down -down: .init .down - -.PHONY: destroy -destroy: .init .destroy - -.PHONY: bash -bash: up .bash - -# ======== General Docker-Compose Helper Targets ======== +# docker images +MW_VERSION?=1.35 +PHP_VERSION?=7.4 +DB_TYPE?=sqlite +DB_IMAGE?="" -.PHONY: .build -.build: - $(show-current-target) - $(compose-ci) build wiki -.PHONY: .up -.up: - $(show-current-target) - $(compose-ci) up -d +# extensions +SMW_VERSION?=4.1.2 -.PHONY: .install -.install: .wait-for-db - $(show-current-target) - $(compose-exec-wiki) bash -c "sudo -u www-data \ - php maintenance/install.php \ - --pass=wiki4everyone --server=http://localhost:8080 --scriptpath='' \ - --dbname=wiki --dbuser=wiki --dbpass=wiki $(WIKI_DB_CONFIG) wiki WikiSysop && \ - cat __setup_extension__ >> LocalSettings.php && \ - sudo -u www-data php maintenance/update.php --skip-external-dependencies --quick \ - " +# composer +# Enables "composer update" inside of extension +COMPOSER_EXT?=true -.PHONY: .down -.down: - $(show-current-target) - $(compose-ci) down +# nodejs +# Enables node.js related tests and "npm install" +# NODE_JS?=true -.PHONY: .destroy -.destroy: - $(show-current-target) - $(compose-ci) down -v - -.PHONY: .bash -.bash: .init - $(show-current-target) - $(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && bash" - -# ======== Test Targets ======== - -.PHONY: composer-test -composer-test: - $(show-current-target) - $(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer phpunit" - -.PHONY: composer-test-coverage -composer-test-coverage: - $(show-current-target) - $(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer phpunit-coverage" - -# ======== Dev Targets ======== - -.PHONY: dev-bash -dev-bash: .init - $(compose-dev) run -it wiki bash -c 'service apache2 start && bash' - -.PHONY: run -run: - $(compose-dev) -f docker-compose-dev.yml run -it wiki - -# ======== Releasing ======== -VERSION = `node -e 'console.log(require("./extension.json").version)'` - -.PHONY: release -release: ci git-push gh-login - gh release create $(VERSION) - -.PHONY: git-push -git-push: - git diff --quiet || (echo 'git directory has changes'; exit 1) - git push - -.PHONY: gh-login -gh-login: require-GH_API_TOKEN - gh config set prompt disabled - @echo $(GH_API_TOKEN) | gh auth login --with-token - -.PHONY: require-GH_API_TOKEN -require-GH_API_TOKEN: -ifndef GH_API_TOKEN - $(error GH_API_TOKEN is not set) -endif - - -# ======== Helpers ======== -.PHONY: .init -.init: - $(show-current-target) - $(eval COMPOSE_ARGS = --project-name ${extension}-$(DB_TYPE) --profile $(DB_TYPE)) -ifeq ($(DB_TYPE), sqlite) - $(eval WIKI_DB_CONFIG = --dbtype=$(DB_TYPE) --dbpath=/tmp/sqlite) -else - $(eval WIKI_DB_CONFIG = --dbtype=$(DB_TYPE) --dbserver=$(DB_TYPE) --installdbuser=root --installdbpass=database) -endif - @echo "COMPOSE_ARGS: $(COMPOSE_ARGS)" +# check for build dir and git submodule init if it does not exist +include build/Makefile -.PHONY: .wait-for-db -.wait-for-db: - $(show-current-target) -ifeq ($(DB_TYPE), mysql) - $(compose-run) wait-for $(DB_TYPE):3306 -t 120 -else ifeq ($(DB_TYPE), postgres) - $(compose-run) wait-for $(DB_TYPE):5432 -t 120 -endif \ No newline at end of file diff --git a/build b/build new file mode 160000 index 0000000..423c351 --- /dev/null +++ b/build @@ -0,0 +1 @@ +Subproject commit 423c35148a54ade29df68023386a448877880afc diff --git a/composer.json b/composer.json index 9d8a4db..cb0f37f 100644 --- a/composer.json +++ b/composer.json @@ -51,6 +51,12 @@ "process-timeout": 0 }, "scripts": { + "test": [ + "@phpunit" + ], + "test-coverage": [ + "@phpunit-coverage" + ], "phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist", "phpunit-coverage": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml", "unit": [ diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml deleted file mode 100644 index 9f4a0e0..0000000 --- a/docker-compose-ci.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: - wiki: - volumes: - - ./coverage:${EXTENSION_FOLDER}/coverage diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml deleted file mode 100644 index e09dcb6..0000000 --- a/docker-compose-dev.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - wiki: - volumes: - - ./:${EXTENSION_FOLDER} - - ${EXTENSION_FOLDER}/vendor/ - ports: - - 8080:8080 - \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 06eeeee..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -services: - wiki: - build: - context: . - args: - MW_VERSION: ${MW_VERSION} - SMW_VERSION: ${SMW_VERSION} - PHP_VERSION: ${PHP_VERSION} - image: ${IMAGE_NAME} - - mysql: - image: ${DB_IMAGE:-mysql:5} - environment: - - MYSQL_ROOT_PASSWORD=database - profiles: - - mysql - - postgres: - image: ${DB_IMAGE:-postgres:15} - environment: - - POSTGRES_USER=root - - POSTGRES_PASSWORD=database - profiles: - - postgres - - wait-for: - image: mintel/docker-wait-for-it - profiles: - - no-up From c060750b577d1d7a6206c1bcab728bd34e45567d Mon Sep 17 00:00:00 2001 From: Luke Eversfield Date: Wed, 18 Oct 2023 22:04:04 +0200 Subject: [PATCH 3/3] update submodule --- .vscode/settings.json | 7 ------- build | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 95e1ba7..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "workbench.colorCustomizations": { - "activityBar.background": "#173325", - "titleBar.activeBackground": "#204833", - "titleBar.activeForeground": "#F8FCFA" - } -} \ No newline at end of file diff --git a/build b/build index 423c351..91d0052 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 423c35148a54ade29df68023386a448877880afc +Subproject commit 91d00523e3a9e5b7b334562d6a7aed5a300c3787