-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
244 lines (198 loc) · 13.3 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
231
232
233
234
235
236
237
238
239
240
241
242
243
EXT_NAME=sn_webservice
EXT_VERSION=2.0.2
GIT_VERSION=$(shell git log --format='%h %D' | grep 'tag: ' | sed 's/.*tag: //g' | head -n 1)
NEXTPATCHVERSION=$(shell php -r 'list($$a,$$b,$$c) = (explode(".","$(EXT_VERSION)", 3)); echo "$$a.$$b.".($$c+1);')
NEXTMINORVERSION=$(shell php -r 'list($$a,$$b,$$c) = (explode(".","$(EXT_VERSION)", 3)); echo "$$a.".($$b+1).".0";')
NEXTMAJORVERSION=$(shell php -r 'list($$a,$$b,$$c) = (explode(".","$(EXT_VERSION)", 3)); echo ($$a + 1).".0.0";')
COMMIT_MESSAGE=$(shell git tag -l $(EXT_VERSION) -n99 | sed "s/^$(EXT_VERSION)[ ]*//g" | sed "s/^[ ]*//g" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/<br>/g")
INTERNAL=1
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# macos does not know how to handle getent
REPO_IP=131.188.205.253
WWW_IP=131.188.205.253
else
REPO_IP=$(shell getent hosts repo.scoutnet.de | awk '{ print $$1 }')
WWW_IP=$(shell getent hosts www.scoutnet.de | awk '{ print $$1 }')
endif
HAS_UNIT_TESTS=$(shell find Tests/Unit -name '*.php')
HAS_FUNCTIONAL_TESTS=$(shell find Tests/Functional -name '*.php')
HAS_ACCEPTANCE_TESTS=$(shell find Tests/Acceptance/Tests -name '*.php')
RELEASE_BUILD_FOLDER=.Build/Release
TEST_ROOT_FOLDER=.Build/Test
PHP_XDEBUG_ON ?= 0
PHP_XDEBUG_PORT ?= 9000
SCRIPT_VERBOSE ?= 0
PHP_VERSIONS ?= 8.1 8.2 8.3
COMPOSE_PROJECT_NAME_PREFIX=local-$(JOB_NAME)-$(BUILD_ID)-$(EXT_NAME)-
export GITHUB_USER=scoutnet
export GITHUB_REPO=plugins.$(EXT_NAME)
default: zip
zip: $(RELEASE_BUILD_FOLDER)/$(EXT_NAME)_$(EXT_VERSION).zip
$(RELEASE_BUILD_FOLDER)/%.zip: checkVersion
-@[ -d $(RELEASE_BUILD_FOLDER) ] || mkdir -p $(RELEASE_BUILD_FOLDER)
git archive -o "$(RELEASE_BUILD_FOLDER)/$(EXT_NAME)_$(EXT_VERSION).zip" $(EXT_VERSION)
$(TEST_ROOT_FOLDER)/docker-%/.env:
@echo "Generating env file for $*"
-@[ -d $(TEST_ROOT_FOLDER)/docker-$* ] || mkdir -p $(TEST_ROOT_FOLDER)/docker-$*
@echo "COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)$*" > $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "CGLCHECK_DRY_RUN=''" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "HOST_UID=`id -u`" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "HOST_HOME=$(HOME)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "ROOT_DIR=`pwd`" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "HOST_USER=$(USER)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "TEST_FILE=`pwd`/Tests/$(shell php -r 'echo ucfirst("$(word 2,$(subst -, ,$*))");')" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "EXT_NAME=$(EXT_NAME)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "PHP_XDEBUG_ON=$(PHP_XDEBUG_ON)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "PHP_XDEBUG_PORT=$(PHP_XDEBUG_PORT)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "DOCKER_PHP_IMAGE=$(word 1,$(subst -, ,$*))" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "PHP_VERSION=$(word 1,$(subst -, ,$*))" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "EXTRA_TEST_OPTIONS=$(EXTRA_TEST_OPTIONS) --coverage-filter $(shell pwd)/Classes --coverage-clover coverage-$*.xml" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "SCRIPT_VERBOSE=$(SCRIPT_VERBOSE)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "PREFIX=$*" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "TYPO3_CONTEXT=Testing" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "REPO_IP=$(REPO_IP)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
@echo "WWW_IP=$(WWW_IP)" >> $(TEST_ROOT_FOLDER)/docker-$*/.env
# create .env for phpstorm debuger
.PHONY: phpStormDockerDotEnv
phpStormDockerDotEnv: Tests/Build/.env
Tests/Build/.env: $(TEST_ROOT_FOLDER)/docker-php81-php_storm/.env
@cp $(TEST_ROOT_FOLDER)/docker-php81-php_storm/.env $@
$(TEST_ROOT_FOLDER)/docker-%/docker-compose.yaml:
@echo "Generating docker-compose file for $*"
-@[ -d $(TEST_ROOT_FOLDER)/docker-$* ] || mkdir -p $(TEST_ROOT_FOLDER)/docker-$*
cp Tests/Build/docker-compose.yml $@
# TODO: replace the internal ip with the external if we do not run on jenkins (better replace with external in config and update if we run on jenkins)
stepPatchVersion:
@cat ext_emconf.php | sed "s/'version' => '$(EXT_VERSION)'/'version' => '$(NEXTPATCHVERSION)'/g" > ext_emconf_new.php && mv ext_emconf_new.php ext_emconf.php
@git add ext_emconf.php && git commit -m "new patch $(NEXTPATCHVERSION)"
@echo "* Start Development of the new Version: $(NEXTPATCHVERSION). After feature freeze, use make tag to tag this release"
stepMinorVersion:
@cat ext_emconf.php | sed "s/'version' => '$(EXT_VERSION)'/'version' => '$(NEXTMINORVERSION)'/g" > ext_emconf_new.php && mv ext_emconf_new.php ext_emconf.php
@git add ext_emconf.php && git commit -m "new minor Version $(NEXTMINORVERSION)"
@echo "* Start Development of the new Version: $(NEXTMINORVERSION). After feature freeze, use make tag to tag this release"
stepMajorVersion:
@cat ext_emconf.php | sed "s/'version' => '$(EXT_VERSION)'/'version' => '$(NEXTMAJORVERSION)'/g" > ext_emconf_new.php && mv ext_emconf_new.php ext_emconf.php
@git add ext_emconf.php && git commit -m "new Version $(NEXTMAJORVERSION)"
@echo "* Start Development of the new Version: $(NEXTMAJORVERSION). After feature freeze, use make tag to tag this release"
tag: test
@if [ ! -n "$$(git tag -l $(EXT_VERSION))" ]; then git tag -a $(EXT_VERSION); fi
@echo You can now use git push --tags to push all changes to github
@echo To step development Version use make stepPatchVersion, make stepMinorVersion or make stepMajorVersion
release: checkVersion $(RELEASE_BUILD_FOLDER)/$(EXT_NAME)_$(EXT_VERSION).zip
@if [ -z "$(GITHUB_TOKEN)" ]; then echo "Please Set ENV GITHUB_TOKEN"; exit 2; fi
@echo "* Generate Release $(EXT_VERSION) on Github"
@github-release release -t $(EXT_VERSION) -d "Release of version $(EXT_VERSION)<br><br>$(COMMIT_MESSAGE)"
@echo "* Wait for Release to be created on Github"
@sleep 3
@echo "* Upload Release $(EXT_VERSION) to Github"
@github-release upload -t $(EXT_VERSION) -f $(RELEASE_BUILD_FOLDER)/$(EXT_NAME)_$(EXT_VERSION).zip -n "$(EXT_NAME)_$(EXT_VERSION).zip"
@echo "* Upload Done"
.PHONY: clean
clean:
-rm -rf $(RELEASE_BUILD_FOLDER)
-rm -rf $(TEST_ROOT_FOLDER)
-rm -rf .Build/
-rm -f composer.lock
-rm -rf Tests/Acceptance/Support/_generated
-rm -rf Tests/Build/.env
-rm -rf Resources/Public/JavaScript/node_modules
-rm -rf Resources/Public/JavaScript/package-lock.json
.PHONY: cleanDocker
cleanDocker: $(TEST_ROOT_FOLDER)/docker-php81-composer/.env $(TEST_ROOT_FOLDER)/docker-php81-composer/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php81-lint/.env $(TEST_ROOT_FOLDER)/docker-php81-lint/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php81-cgl/.env $(TEST_ROOT_FOLDER)/docker-php81-cgl/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php81-unit/.env $(TEST_ROOT_FOLDER)/docker-php81-unit/docker-compose.yaml\
$(TEST_ROOT_FOLDER)/docker-php82-lint/.env $(TEST_ROOT_FOLDER)/docker-php82-lint/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php82-cgl/.env $(TEST_ROOT_FOLDER)/docker-php82-cgl/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php82-unit/.env $(TEST_ROOT_FOLDER)/docker-php82-unit/docker-compose.yaml\
$(TEST_ROOT_FOLDER)/docker-php83-lint/.env $(TEST_ROOT_FOLDER)/docker-php83-lint/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php83-cgl/.env $(TEST_ROOT_FOLDER)/docker-php83-cgl/docker-compose.yaml \
$(TEST_ROOT_FOLDER)/docker-php83-unit/.env $(TEST_ROOT_FOLDER)/docker-php83-unit/docker-compose.yaml\
# Composer
-cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_install; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_update; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_validate; docker-compose down
# PHP 8.1
-cd $(TEST_ROOT_FOLDER)/docker-php81-lint && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php81-lint; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php81-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php81-cgl; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php81-unit && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php81-unit; docker-compose down
# PHP 8.2
-cd $(TEST_ROOT_FOLDER)/docker-php82-lint && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php82-lint; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php82-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php82-cgl; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php82-unit && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php82-unit; docker-compose down
# PHP 8.3
-cd $(TEST_ROOT_FOLDER)/docker-php83-lint && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php83-lint; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php83-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php83-cgl; docker-compose down
-cd $(TEST_ROOT_FOLDER)/docker-php83-unit && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php83-unit; docker-compose down
checkVersion:
@echo GIT_VERSION: $(GIT_VERSION)
@echo TYPO3_VERSION: $(EXT_VERSION)
@[ "$(GIT_VERSION)" = "$(EXT_VERSION)" ]
@echo "* All Versions correct"
.PHONY: init
init: clean composerInstall phpStormDockerDotEnv
.PHONY: composerInstall
composerInstall: $(TEST_ROOT_FOLDER)/docker-php81-composer/.env $(TEST_ROOT_FOLDER)/docker-php81-composer/docker-compose.yaml
@mkdir -p /tmp/.composer
@mkdir -p /tmp/.cache
@mkdir -p /tmp/.npm
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_install; docker-compose run composer_install
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_install; docker-compose down
.PHONY: composerUpdate
composerUpdate: $(TEST_ROOT_FOLDER)/docker-php81-composer/.env $(TEST_ROOT_FOLDER)/docker-php81-composer/docker-compose.yaml
@mkdir -p /tmp/.composer
@mkdir -p /tmp/.cache
@mkdir -p /tmp/.npm
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_update; docker-compose run composer_update
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_update; docker-compose down
.PHONY: composerValidate
composerValidate: $(TEST_ROOT_FOLDER)/docker-php81-composer/.env $(TEST_ROOT_FOLDER)/docker-php81-composer/docker-compose.yaml
@mkdir -p /tmp/.composer
@mkdir -p /tmp/.cache
@mkdir -p /tmp/.npm
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_validate; docker-compose run composer_validate
@cd $(TEST_ROOT_FOLDER)/docker-php81-composer && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)composer_validate; docker-compose down
.PHONY: test
test: lintTest cglTest unitTest
@echo "done"
# Availbable Tests
ALL_TESTS = $(foreach ver,$(subst .,,$(PHP_VERSIONS)),test-php$(ver))
.PHONY: $(ALL_TESTS)
$(ALL_TESTS): test-php%: lintTest-php% cglTest-php% unitTest-php%
# Available PHPVersions
.PHONY: lintTest
lintTest: %Test: $(foreach ver,$(subst .,,$(PHP_VERSIONS)),%Test-php$(ver))
LINT_TESTS = $(foreach ver,$(subst .,,$(PHP_VERSIONS)),lintTest-php$(ver))
.PHONY: $(LINT_TESTS)
$(LINT_TESTS): lintTest-php%: $(TEST_ROOT_FOLDER)/docker-php%-lint/.env $(TEST_ROOT_FOLDER)/docker-php%-lint/docker-compose.yaml
# Lint Test for php$*
@cd $(TEST_ROOT_FOLDER)/docker-php$*-lint && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-lint; docker-compose run lint
@cd $(TEST_ROOT_FOLDER)/docker-php$*-lint && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-lint; docker-compose down
.PHONY: cglTest
cglTest: cglTest-php83
CGL_TESTS = $(foreach ver,$(subst .,,$(PHP_VERSIONS)),cglTest-php$(ver))
.PHONY: $(CGL_TESTS)
$(CGL_TESTS): cglTest-php%: $(TEST_ROOT_FOLDER)/docker-php%-cgl/.env $(TEST_ROOT_FOLDER)/docker-php%-cgl/docker-compose.yaml
# CGL Test using php$*
@cd $(TEST_ROOT_FOLDER)/docker-php$*-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-cgl && export CGLCHECK_DRY_RUN="--dry-run --diff"; docker-compose run cgl
@cd $(TEST_ROOT_FOLDER)/docker-php$*-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-cgl && export CGLCHECK_DRY_RUN=""; docker-compose down
.PHONY: cglFix
cglFix: cglFix-php83
CGL_FIX = $(foreach ver,$(subst .,,$(PHP_VERSIONS)),cglFix-php$(ver))
.PHONY: $(CGL_FIX)
$(CGL_FIX): cglFix-php%: $(TEST_ROOT_FOLDER)/docker-php%-cgl/.env $(TEST_ROOT_FOLDER)/docker-php%-cgl/docker-compose.yaml
# CGL Fix using php$*
@cd $(TEST_ROOT_FOLDER)/docker-php$*-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-cgl && export CGLCHECK_DRY_RUN=""; docker-compose run cgl
@cd $(TEST_ROOT_FOLDER)/docker-php$*-cgl && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-cgl && export CGLCHECK_DRY_RUN=""; docker-compose down
@git commit -am "cglFix"
.PHONY: unitTest
unitTest: %Test: $(foreach ver,$(subst .,,$(PHP_VERSIONS)),%Test-php$(ver))
UNIT_TESTS = $(foreach ver,$(subst .,,$(PHP_VERSIONS)),unitTest-php$(ver))
.PHONY: $(UNIT_TESTS)
$(UNIT_TESTS): unitTest-php%: $(TEST_ROOT_FOLDER)/docker-php%-unit/.env $(TEST_ROOT_FOLDER)/docker-php%-unit/docker-compose.yaml
ifneq ($(strip $(HAS_UNIT_TESTS)),)
# Unit Test for php$*
@cd $(TEST_ROOT_FOLDER)/docker-php$*-unit && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-unit; docker-compose run unit
@cd $(TEST_ROOT_FOLDER)/docker-php$*-unit && export COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME_PREFIX)php$*-unit; docker-compose down
endif