-
-
Notifications
You must be signed in to change notification settings - Fork 13
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 #107 from SemanticMediaWiki/docker-compose-ci
use docker-compose-ci as a git submodule
- Loading branch information
Showing
8 changed files
with
27 additions
and
239 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,178 +1,33 @@ | ||
-include .env | ||
export | ||
|
||
# ======== Naming ======== | ||
EXTENSION := SemanticFormsSelect | ||
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) | ||
|
||
|
||
# ======== CI ENV Variables ======== | ||
MW_VERSION ?= 1.35 | ||
SMW_VERSION ?= 4.1.2 | ||
PHP_VERSION ?= 7.4 | ||
PF_VERSION ?= 5.5.1 | ||
DB_TYPE ?= sqlite | ||
DB_IMAGE ?= "" | ||
|
||
|
||
environment = IMAGE_NAME=$(IMAGE_NAME) \ | ||
MW_VERSION=$(MW_VERSION) \ | ||
SMW_VERSION=$(SMW_VERSION) \ | ||
PHP_VERSION=$(PHP_VERSION) \ | ||
PF_VERSION=$(PF_VERSION) \ | ||
DB_TYPE=$(DB_TYPE) \ | ||
DB_IMAGE=$(DB_IMAGE) \ | ||
EXTENSION_FOLDER=$(EXTENSION_FOLDER) | ||
# setup for docker-compose-ci build directory | ||
# delete "build" directory to update docker-compose-ci | ||
|
||
|
||
ifneq (,$(wildcard ./docker-compose.override.yml)) | ||
COMPOSE_OVERRIDE=-f docker-compose.override.yml | ||
ifeq (,$(wildcard ./build/)) | ||
$(shell git submodule update --init --remote) | ||
endif | ||
|
||
EXTENSION := SemanticFormsSelect | ||
|
||
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 npm-test | ||
|
||
.PHONY: ci-coverage | ||
ci-coverage: install composer-test-coverage npm-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 ======== | ||
|
||
.PHONY: .build | ||
.build: | ||
$(show-current-target) | ||
$(compose-ci) build wiki | ||
.PHONY: .up | ||
.up: | ||
$(show-current-target) | ||
$(compose-ci) up -d | ||
|
||
.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 \ | ||
" | ||
|
||
.PHONY: .down | ||
.down: | ||
$(show-current-target) | ||
$(compose-ci) down | ||
|
||
.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" | ||
|
||
.PHONY: npm-test | ||
npm-test: | ||
$(compose-exec-wiki) bash -c "cd ${EXTENSION_FOLDER} && npm run test" | ||
|
||
.PHONY: npm-test-coverage | ||
npm-test-coverage: | ||
$(compose-exec-wiki) bash -c "cd ${EXTENSION_FOLDER} && npm run test-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 | ||
# docker images | ||
MW_VERSION?=1.35 | ||
PHP_VERSION?=7.4 | ||
DB_TYPE?=sqlite | ||
DB_IMAGE?="" | ||
|
||
.PHONY: gh-login | ||
gh-login: require-GH_API_TOKEN | ||
gh config set prompt disabled | ||
@echo $(GH_API_TOKEN) | gh auth login --with-token | ||
# extensions | ||
SMW_VERSION?=4.1.2 | ||
PF_VERSION?=5.5.1 | ||
|
||
.PHONY: require-GH_API_TOKEN | ||
require-GH_API_TOKEN: | ||
ifndef GH_API_TOKEN | ||
$(error GH_API_TOKEN is not set) | ||
endif | ||
# composer | ||
# Enables "composer update" inside of extension | ||
COMPOSER_EXT?=true | ||
|
||
# nodejs | ||
# Enables node.js related tests and "npm install" | ||
NODE_JS?=true | ||
|
||
# ======== 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.