-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
230 lines (183 loc) · 6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# ======== Naming ========
EXTENSION_FOLDER := /var/www/html/extensions/$(EXTENSION)
extension := $(shell echo $(EXTENSION) | tr A-Z a-z})
IMAGE_NAME := $(extension):test-$(MW_VERSION)-$(SMW_VERSION) # ggf hier Timestamp
# ======== CI ENV Variables ========
DB_TYPE ?= sqlite
DB_IMAGE ?= ""
MW_INSTALL_PATH ?= /var/www/html
environment = \
AL_VERSION=$(AL_VERSION) \
CHAMELEON_VERSION=$(CHAMELEON_VERSION) \
COMPOSER_EXT=$(COMPOSER_EXT) \
DB_IMAGE=$(DB_IMAGE) \
DB_TYPE=$(DB_TYPE) \
DT_VERSION=$(DT_VERSION) \
EXTENSION=$(EXTENSION) \
EXTENSION_FOLDER=$(EXTENSION_FOLDER) \
IMAGE_NAME=$(IMAGE_NAME) \
MAPS_VERSION=$(MAPS_VERSION) \
LINGO_VERSION=${LINGO_VERSION} \
SCRIBUNTO_VERSION=${SCRIBUNTO_VERSION} \
MM_VERSION=$(MM_VERSION) \
MW_INSTALL_PATH=$(MW_INSTALL_PATH) \
MW_VERSION=$(MW_VERSION) \
NODE_JS=$(NODE_JS) \
PF_REPO=$(PF_REPO) \
PF_VERSION=$(PF_VERSION) \
PHP_EXTENSIONS=$(PHP_EXTENSIONS) \
OS_PACKAGES=$(OS_PACKAGES) \
PHP_VERSION=$(PHP_VERSION) \
PS_VERSION=$(PS_VERSION) \
SMW_VERSION=$(SMW_VERSION) \
SRF_VERSION=$(SRF_VERSION) \
ifneq (,$(wildcard ./build/docker-compose.override.yml))
COMPOSE_OVERRIDE=-f build/docker-compose.override.yml
endif
compose = $(environment) docker compose -f build/docker-compose.yml $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS)
compose-ci = $(environment) docker compose -f build/docker-compose.yml -f build/docker-compose-ci.yml $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS)
compose-dev = $(environment) docker compose -f build/docker-compose.yml -f build/docker-compose-dev.yml $(COMPOSE_OVERRIDE) $(COMPOSE_ARGS)
compose-run = $(compose) run -T --rm
compose-exec-wiki = $(compose) exec -T wiki
compose-exec-wiki-ci = $(compose-ci) exec -T wiki
show-current-target = @echo; echo "======= $@ ========"
# ======== CI ========
# ======== Global Targets ========
.PHONY: analyze
analyze: install composer-analyze
.PHONY: ci
ci: install composer-test npm-test
.PHONY: ci-coverage
ci-coverage: install composer-test-coverage npm-test-coverage
.PHONY: fix
fix: install composer-fix
.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: .bash
# ======== General Docker-Compose Helper Targets ========
.PHONY: .build
.build:
$(show-current-target)
$(compose-ci) build --no-cache wiki
.PHONY: .up
.up:
$(show-current-target)
$(compose-ci) up -d
$(compose-exec-wiki-ci) bash -c "rm -r -f coverage"
.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"
# ======== Analyze Targets ========
.PHONY: composer-analyze
composer-analyze: .init
ifdef COMPOSER_EXT
$(show-current-target)
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer analyze $(COMPOSER_PARAMS)"
endif
# ======== Test Targets ========
.PHONY: composer-test
composer-test: .init
ifdef COMPOSER_EXT
$(show-current-target)
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer test $(COMPOSER_PARAMS)"
endif
.PHONY: composer-test-coverage
composer-test-coverage: .init
ifdef COMPOSER_EXT
$(show-current-target)
$(compose-exec-wiki-ci) bash -c "cd $(EXTENSION_FOLDER) && composer test-coverage $(COMPOSER_PARAMS) && composer post-test-coverage > /dev/null 2>&1 || true"
endif
.PHONY: composer-fix
composer-fix: .init
ifdef COMPOSER_EXT
$(show-current-target)
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && composer fix $(COMPOSER_PARAMS)"
endif
.PHONY: npm-test
npm-test: .init
ifdef NODE_JS
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && npm run test"
endif
.PHONY: npm-test-coverage
npm-test-coverage: .init
ifdef NODE_JS
$(compose-exec-wiki) bash -c "cd $(EXTENSION_FOLDER) && npm run test-coverage"
endif
# ======== 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
# ======== Develop ========
.PHONY: prepare-dev
prepare-dev: .init
$(show-current-target)
$(compose-exec-wiki) bash -c "sed -i 's|/var/www/html/\(.*\)|$(EXTENSION_FOLDER)/|' /tools/prepare-dev.sh"
$(compose-exec-wiki) bash -c "sed -i 's|/var/www/html\(.*\)|${EXTENSION_FOLDER}\1|' /tools/files/.vscode/launch.json"
$(compose-exec-wiki) bash -c "bash prepare-dev.sh"
@echo "Xdebug has been configured successfully."
# ======== 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)"
.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