forked from Enalean/tuleap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
273 lines (208 loc) · 10.2 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# How to:
# Run the rest tests in Jenkins: make -C tuleap BUILD_ENV=ci ci_api_test
# Run the phpunit tests in Jenkins: make -C tuleap BUILD_ENV=ci ci_phpunit
# Run docker as a priviledged user: make SUDO=sudo ... or make SUDO=pkexec ...
TULEAP_INCLUDE_PATH=$(CURDIR)/src/www/include:$(CURDIR)/src:/usr/share/codendi/src/www/include:/usr/share/codendi/src
PHP_INCLUDE_PATH=/usr/share/php:/usr/share/pear:$(TULEAP_INCLUDE_PATH):/usr/share/jpgraph:.
PHP=php -q -d date.timezone=Europe/Paris -d include_path=$(PHP_INCLUDE_PATH) -d memory_limit=256M -d display_errors=On
DOCKER_REST_TESTS_IMAGE=enalean/tuleap-test-rest
DOCKER_REST_TESTS_IMGINIT=$(DOCKER_REST_TESTS_IMAGE)-init
ifeq ($(BUILD_ENV),ci)
OUTPUT_DIR=$(WORKSPACE)
SIMPLETEST_OPTIONS=-x
REST_TESTS_OPTIONS=--log-junit $(OUTPUT_DIR)/rest_tests.xml
SOAP_TESTS_OPTIONS=--log-junit $(OUTPUT_DIR)/soap_tests.xml
PHPUNIT_TESTS_OPTIONS=--log-junit $(OUTPUT_DIR)/phpunit_tests.xml --coverage-html $(OUTPUT_DIR)/phpunit_coverage --coverage-clover $(OUTPUT_DIR)/phpunit_coverage/coverage.xml
PHPUNIT_OPTIONS=
TULEAP_LOCAL_INC=$(WORKSPACE)/etc/integration_tests.inc
COMPOSER=/usr/local/bin/composer.phar
else
SIMPLETEST_OPTIONS=
REST_TESTS_OPTIONS=
SOAP_TESTS_OPTIONS=
PHPUNIT_TESTS_OPTIONS=
PHPUNIT_OPTIONS=--color
TULEAP_LOCAL_INC=/etc/codendi/conf/integration_tests.inc
COMPOSER=$(CURDIR)/composer.phar
endif
OS := $(shell uname)
ifeq ($(OS),Darwin)
DOCKER_COMPOSE_FILE=-f docker-compose.yml -f docker-compose-mac.yml
else
DOCKER_COMPOSE_FILE=-f docker-compose.yml
endif
SUDO=
DOCKER=$(SUDO) docker
DOCKER_COMPOSE=$(SUDO) docker-compose $(DOCKER_COMPOSE_FILE)
# Export
export TULEAP_LOCAL_INC
PHPUNIT=$(PHP) vendor/phpunit/phpunit/phpunit.php $(PHPUNIT_OPTIONS)
SIMPLETEST=$(PHP) tests/bin/simpletest $(SIMPLETEST_OPTIONS)
AUTOLOAD_EXCLUDES=mediawiki|tests|template
default:
@echo "possible targets: 'doc' 'test' 'autoload' 'less' 'less-dev' 'api_test' 'api_test_group'"
#
# Utilities
#
doc:
$(MAKE) -C documentation all
autoload:
@echo "Generate core"
@(cd src/common; phpab -q --compat -o autoload.php --exclude "./wiki/phpwiki/*" .)
@echo "Generate tests"
@(cd tests/lib; phpab -q --compat -o autoload.php .)
@for path in `ls plugins | egrep -v "$(AUTOLOAD_EXCLUDES)"`; do \
echo "Generate plugin $$path"; \
(cd "plugins/$$path/include"; phpab -q --compat -o autoload.php .) \
done;
autoload-with-userid:
@echo "Generate core"
@(cd src/common; phpab -q --compat -o autoload.php --exclude "./wiki/phpwiki/*" .;chown $(USER_ID):$(USER_ID) autoload.php)
@echo "Generate tests"
@(cd tests/lib; phpab -q --compat -o autoload.php .;chown $(USER_ID):$(USER_ID) autoload.php)
@for path in `ls plugins | egrep -v "$(AUTOLOAD_EXCLUDES)"`; do \
echo "Generate plugin $$path"; \
(cd "plugins/$$path/include"; phpab -q --compat -o autoload.php .;chown $(USER_ID):$(USER_ID) autoload.php) \
done;
autoload-docker:
@$(DOCKER) run --rm=true -v $(CURDIR):/tuleap -e USER=`id -u` -e GROUP=`id -g` enalean/tuleap-dev-swissarmyknife:2 --autoload
autoload-dev:
@tools/utils/autoload.sh
less:
@tools/utils/less.sh less `pwd`
less-dev:
@tools/utils/less.sh watch `pwd`
less-docker:
@$(DOCKER) run --rm=true -v $(CURDIR):/tuleap -e USER=`id -u` -e GROUP=`id -g` enalean/tuleap-dev-swissarmyknife:2 --less
## RNG generation
rnc2rng-docker: clean-rng
@$(DOCKER) run --rm=true -v $(CURDIR):/tuleap -e USER=`id -u` -e GROUP=`id -g` enalean/tuleap-dev-swissarmyknife:2 --rnc2rng
rnc2rng: src/common/xml/resources/project/project.rng \
src/common/xml/resources/users.rng \
src/common/xml/resources/svn.rng \
src/common/xml/resources/ugroups.rng \
plugins/tracker/www/resources/tracker.rng \
plugins/tracker/www/resources/trackers.rng \
plugins/tracker/www/resources/artifacts.rng \
plugins/agiledashboard/www/resources/xml_project_agiledashboard.rng \
plugins/cardwall/www/resources/xml_project_cardwall.rng
src/common/xml/resources/project/project.rng: src/common/xml/resources/project/project.rnc plugins/tracker/www/resources/tracker-definition.rnc src/common/xml/resources/ugroups-definition.rnc src/common/xml/resources/svn-definition.rnc src/common/xml/resources/frs-definition.rnc src/common/xml/resources/mediawiki-definition.rnc src/common/xml/resources/project-definition.rnc
src/common/xml/resources/svn.rng: src/common/xml/resources/svn.rnc src/common/xml/resources/svn-definition.rnc
src/common/xml/resources/ugroups.rng: src/common/xml/resources/ugroups.rnc src/common/xml/resources/ugroups-definition.rnc
plugins/tracker/www/resources/trackers.rng: plugins/tracker/www/resources/trackers.rnc plugins/tracker/www/resources/tracker-definition.rnc plugins/tracker/www/resources/artifact-definition.rnc plugins/tracker/www/resources/triggers.rnc
plugins/tracker/www/resources/tracker.rng: plugins/tracker/www/resources/tracker.rnc plugins/tracker/www/resources/tracker-definition.rng
plugins/tracker/www/resources/artifacts.rng: plugins/tracker/www/resources/artifacts.rnc plugins/tracker/www/resources/artifact-definition.rng
%.rng: %.rnc
trang -I rnc -O rng $< $@
clean-rng:
find . -type f -name "*.rng" | xargs rm -f
#
# Tests and all
#
composer_update:
cp tests/rest/bin/composer.json .
php $(COMPOSER) install
soap_composer_update:
cp tests/soap/bin/composer.json .
php $(COMPOSER) install
local_composer_install:
curl -k -sS https://getcomposer.org/installer | php
api_test_setup: local_composer_install composer_update
cp tests/rest/bin/integration_tests.inc.dist /etc/codendi/conf/integration_tests.inc
cp tests/rest/bin/dbtest.inc.dist /etc/codendi/conf/dbtest.inc
api_test_bootstrap:
php tests/lib/rest/init_db.php
$(PHP) tests/lib/rest/init_data.php
soap_test_bootstrap:
php tests/lib/soap/init_db.php
$(PHP) tests/lib/soap/init_data.php
soap_test: composer_update soap_test_bootstrap
$(PHPUNIT) $(SOAP_TESTS_OPTIONS) tests/soap
api_test: composer_update api_test_bootstrap
$(PHPUNIT) $(REST_TESTS_OPTIONS) tests/rest
@for restpath in `\ls -d plugins/*/tests/rest`; do \
$(PHPUNIT) $(REST_TESTS_OPTIONS) "$$restpath"; \
done;
ci_api_test_setup: composer_update
mkdir -p $(WORKSPACE)/etc
cat tests/rest/bin/integration_tests.inc.dist | perl -pe "s%/usr/share/codendi%$(CURDIR)%" > $(TULEAP_LOCAL_INC)
cp tests/rest/bin/dbtest.inc.dist $(WORKSPACE)/etc/dbtest.inc
mkdir -p /tmp/run
php tests/bin/generate-phpunit-testsuite.php /tmp/run $(OUTPUT_DIR)
ci_soap_test_setup: soap_composer_update
mkdir -p $(WORKSPACE)/etc
cat tests/soap/bin/integration_tests.inc.dist | perl -pe "s%/usr/share/codendi%$(CURDIR)%" > $(TULEAP_LOCAL_INC)
cp tests/soap/bin/dbtest.inc.dist $(WORKSPACE)/etc/dbtest.inc
mkdir -p /tmp/run
php tests/bin/generate-phpunit-testsuite-soap.php /tmp/run $(OUTPUT_DIR)
ci_api_test: ci_api_test_setup api_test
docker_api_all:
$(PHP) /tmp/run/vendor/phpunit/phpunit/phpunit.php --configuration /tmp/run/suite.xml
docker_api_partial:
$(PHP) /tmp/run/vendor/phpunit/phpunit/phpunit.php $(REST_TESTS_OPTIONS)
tests_php51:
$(DOCKER) run --rm=true -v $(CURDIR):/tuleap enalean/tuleap-test-ut-c5-php51
tests_php53:
$(DOCKER) run --rm=true -v $(CURDIR):/tuleap enalean/tuleap-test-ut-c6-php53
tests_phpunit:
$(DOCKER) run -ti --rm=true -v $(CURDIR):/tuleap enalean/tuleap-test-phpunit-c6-php53
phpunit:
$(PHPUNIT) $(PHPUNIT_TESTS_OPTIONS) --bootstrap tests/phpunit_boostrap.php plugins/proftpd/phpunit
ci_phpunit: composer_update phpunit
simpletest:
$(SIMPLETEST) $(SIMPLETEST_OPTIONS) tests/simpletest plugins tests/integration
ci_simpletest: simpletest
test: simpletest phpunit api_test
rest_docker_snapshot:
@$(DOCKER) run -ti --name=rest-init -v $(CURDIR):/tuleap $(DOCKER_REST_TESTS_IMAGE) --init
@$(DOCKER) commit rest-init $(DOCKER_REST_TESTS_IMGINIT)
@$(DOCKER) rm -f rest-init
@echo "Image ready: $(DOCKER_REST_TESTS_IMGINIT)"
@echo "You can use it like:"
@echo "# docker run --rm=true -v $(CURDIR):/tuleap $(DOCKER_REST_TESTS_IMGINIT) --run"
@echo "# docker run --rm=true -v $(CURDIR):/tuleap $(DOCKER_REST_TESTS_IMGINIT) --run tests/rest/ArtifactsTest.php"
rest_docker_clean:
@$(DOCKER) rmi $(DOCKER_REST_TESTS_IMGINIT)
rest_docker_snap_run:
@echo "Once inside the container, just run:"
@echo "# ./run.sh --run tests/rest/UsersTest.php"
@$(DOCKER) run -ti --rm=true -v $(CURDIR):/tuleap --entrypoint=/bin/bash $(DOCKER_REST_TESTS_IMGINIT) +x
#
# Start development enviromnent with Docker Compose
#
.env:
@echo "MYSQL_ROOT_PASSWORD=`env LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32`" > .env
@echo "LDAP_ROOT_PASSWORD=`env LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32`" >> .env
@echo "LDAP_MANAGER_PASSWORD=`env LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32`" >> .env
@echo VIRTUAL_HOST=tuleap_web_1.tuleap-aio-dev.docker >> .env
dev-setup: .env
@echo "Create all data containers"
@$(DOCKER) inspect tuleap_ldap_data > /dev/null 2>&1 || $(DOCKER) run -t --name=tuleap_ldap_data -v /data busybox true
@$(DOCKER) inspect tuleap_db_data > /dev/null 2>&1 || $(DOCKER) run -t --name=tuleap_db_data -v /var/lib/mysql busybox true
@$(DOCKER) inspect tuleap_es_data > /dev/null 2>&1 || $(DOCKER) run -t --name=tuleap_es_data -v /data busybox true
@$(DOCKER) inspect tuleap_data > /dev/null 2>&1 || $(DOCKER) run -t --name=tuleap_data -v /data busybox true
@$(DOCKER) inspect tuleap_reverseproxy_data > /dev/null 2>&1 || $(DOCKER) run -t --name=tuleap_reverseproxy_data -v /reverseproxy_data busybox true
show-passwords:
@$(DOCKER) run --rm --volumes-from tuleap_data busybox cat /data/root/.tuleap_passwd
dev-forgeupgrade:
@$(DOCKER) exec tuleap_web_1 /usr/lib/forgeupgrade/bin/forgeupgrade --config=/etc/tuleap/forgeupgrade/config.ini update
dev-clear-cache:
@$(DOCKER) exec tuleap_web_1 /usr/share/tuleap/src/utils/tuleap --clear-caches
start-dns:
@$(DOCKER) stop dnsdock || true
@$(DOCKER) rm dnsdock || true
@$(DOCKER) run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.0.1:53:53/udp tonistiigi/dnsdock
start-rp:
@echo "Start reverse proxy"
@$(DOCKER_COMPOSE) up -d rp
start:
@echo "Start Tuleap Web + LDAP + DB"
@$(DOCKER_COMPOSE) up -d web
@echo -n "Your instance will be soon available: http://"
@grep VIRTUAL_HOST .env | cut -d= -f2
@echo "You might want to type 'make show-passwords' to see site default passwords"
start-es:
@$(DOCKER_COMPOSE) up -d es
start-all:
echo "Start all containers (Web, LDAP, DB, Elasticsearch)"
@$(DOCKER_COMPOSE) up -d