-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from SemanticMediaWiki/docker-compose-ci
Docker compose ci
- Loading branch information
Showing
9 changed files
with
33 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "build"] | ||
path = build | ||
url = [email protected]:gesinn-it-pub/docker-compose-ci.git |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,168 +1,32 @@ | ||
-include .env | ||
export | ||
|
||
# ======== Naming ======== | ||
EXTENSION := Mermaid | ||
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=Mermaid | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.