-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Makefile
431 lines (355 loc) · 13.8 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# Main Makefile for ownCloud development
#
# Requirements to run make here:
# - composer
# - node
# - yarn
#
# Installing composer can be done via https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
#
# Node/Yarn can be installed following e.g. the Debian/Ubuntu instructions at
# https://nodejs.org/en/download/package-manager/
#
# curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
# sudo apt-get install -y nodejs build-essential
#
# (installation from distro packages is not recommended, often old versions)
#
#
# Usage:
#
# make
# - prepare everything
# make clean
# - clean up
# make test-php
# make test-js
# - testing targets
# Detailed documentation in https://github.com/owncloud/documentation:
# - https://doc.owncloud.com/server/latest/developer_manual/general/devenv.html#check-out-the-code
# - https://doc.owncloud.com/server/latest/developer_manual/testing/unit-testing.html#running-unit-tests-for-owncloud-core
#
NODE_PREFIX=build
SHELL=/bin/bash
#
# Define YARN and check if it is available on the system.
#
YARN := $(shell command -v yarn 2> /dev/null)
KARMA=$(NODE_PREFIX)/node_modules/.bin/karma
PHPUNIT="$(shell pwd)/lib/composer/phpunit/phpunit/phpunit"
COMPOSER_BIN := $(shell command -v composer 2> /dev/null)
# bin file definitions
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
PHP_CODESNIFFER=vendor-bin/php_codesniffer/vendor/bin/phpcs
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan
TEST_DATABASE=sqlite
TEST_EXTERNAL_ENV=smb-silvershell
TEST_PHP_SUITE=
DOC_LINK_VERSION=
# Acceptance test flags (for shells supporting autocompletion of makefiles, eg: zsh)
TEST_SERVER_URL?=
TEST_SERVER_FED_URL?=
TEST_WITH_LDAP?=
BEHAT_FEATURE?=
NORERUN?=
BEHAT_RERUN_TIMES?=
# set TESTING_REMOTE_SYSTEM to default=true and make it a system env. variable
export TESTING_REMOTE_SYSTEM?=true
RELEASE_CHANNEL=git
# internal aliases
composer_deps=lib/composer
composer_dev_deps=lib/composer/phpunit
acceptance_test_deps=vendor-bin/behat/vendor
nodejs_deps=build/node_modules
core_vendor=core/vendor
core_doc_files=AUTHORS COPYING README.md CHANGELOG.md
core_src_files=$(wildcard *.php) index.html db_structure.xml .htaccess .user.ini robots.txt
core_src_dirs=apps core l10n lib occ ocs ocs-provider ocm-provider resources settings
core_test_dirs=tests
core_all_src=$(core_src_files) $(core_src_dirs) $(core_doc_files)
core_config_files=config/config.sample.php config/config.apps.sample.php
dist_dir=build/dist
work_dir=${shell pwd}
#
# Catch-all rules
#
.PHONY: all
all: help-hint $(composer_dev_deps) $(nodejs_deps)
.PHONY: clean
clean: clean-composer-deps clean-nodejs-deps clean-test clean-dist
.PHONY: help-hint
help-hint:
@echo "Building core"
@echo
@echo "Note: You can type 'make help' for more targets"
@echo
.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of the following:"
@echo
@echo -e "Dependencies:\n"
@echo -e "make clean\t\t\tclean everything"
@echo -e "make install-composer-deps\tinstall composer dependencies"
@echo -e "make update-composer\t\tupdate composer.lock"
@echo -e "make install-nodejs-deps\tinstall Node JS and Javascript dependencies"
@echo
@echo -e "Note that running 'make' without arguments already installs all required dependencies"
@echo
@echo -e "Testing:\n"
@echo -e "make test\t\t\trun all tests"
@echo -e "make test-php-unit\t\trun all PHP tests"
@echo -e "make test-php-style\t\trun PHP code style checks"
@echo -e "make test-php-phan\t\trun PHP phan static code analyzer"
@echo -e "make test-php-phpstan\t\trun PHP phpstan static code analyzer"
@echo -e "make test-js\t\t\trun Javascript tests"
@echo -e "make test-js-debug\t\trun Javascript tests in debug mode (continuous)"
@echo -e "make test-acceptance-api\trun API acceptance tests"
@echo -e "make test-acceptance-cli\trun CLI acceptance tests"
@echo -e "make test-acceptance-webui\trun webUI acceptance tests"
@echo -e "make clean-test\t\t\tclean test results"
@echo
@echo It is also possible to run individual PHP test files with the following command:
@echo -e "make test-php-unit TEST_DATABASE=mysql TEST_PHP_SUITE=path/to/testfile.php"
@echo
@echo -e "Tools:\n"
@echo -e "make test-php-style-fix\t\trun PHP code style checks and fix any issues found"
@echo -e "make update-php-license-header\tUpdate license headers"
@echo -e "make changelog\t\t\tGenerate the CHANGELOG.md file for testing"
@echo
@echo -e "make test-doc-links\t\tTest if the doc links are valid"
@echo
@echo It is also possible to specify the ownCloud version to look for in the docs:
@echo -e "make test-doc-links DOC_LINK_VERSION=10.7"
#
# ownCloud core PHP dependencies
#
$(composer_deps): composer.json composer.lock
php $(COMPOSER_BIN) install --no-dev
$(composer_dev_deps): composer.json composer.lock
php $(COMPOSER_BIN) install
.PHONY: install-composer-release-deps
install-composer-release-deps: $(composer_deps)
.PHONY: install-composer-dev-deps
install-composer-dev-deps: $(composer_dev_deps)
.PHONY: install-composer-deps
install-composer-deps: install-composer-dev-deps
.PHONY: update-composer
update-composer:
rm -f composer.lock
php $(COMPOSER_BIN) install --prefer-dist
.PHONY: clean-composer-deps
clean-composer-deps:
rm -Rf lib/composer
rm -Rf vendor-bin/**/vendor vendor-bin/**/composer.lock
#
# Node JS dependencies for tools
#
$(nodejs_deps): build/package.json
@test -x "$(YARN)" || { echo "yarn is not available on your system, please install yarn (npm install -g yarn)" && exit 1; }
cd $(NODE_PREFIX) && $(YARN) install
touch $@
# alias for core deps
$(core_vendor): $(nodejs_deps)
.PHONY: install-nodejs-deps
install-nodejs-deps: $(nodejs_deps)
.PHONY: clean-nodejs-deps
clean-nodejs-deps:
rm -Rf $(core_vendor)
rm -Rf $(nodejs_deps)
##---------------------
## Tests
##---------------------
.PHONY: test-php-unit
test-php-unit: $(composer_dev_deps)
PHPUNIT=$(PHPUNIT) build/autotest.sh $(TEST_DATABASE) $(TEST_PHP_SUITE)
.PHONY: test-external
test-external: $(composer_dev_deps)
PHPUNIT=$(PHPUNIT) build/autotest-external.sh $(TEST_DATABASE) $(TEST_EXTERNAL_ENV) $(TEST_PHP_SUITE)
.PHONY: test-js
test-js: $(nodejs_deps)
NODE_PATH='$(NODE_PREFIX)/node_modules' $(KARMA) start tests/karma.config.js --single-run
.PHONY: test-js-debug
test-js-debug: $(nodejs_deps)
NODE_PATH='$(NODE_PREFIX)/node_modules' $(KARMA) start tests/karma.config.js
.PHONY: test-acceptance-api
test-acceptance-api: $(acceptance_test_deps)
./tests/acceptance/run.sh --type api
.PHONY: test-acceptance-cli
test-acceptance-cli: $(acceptance_test_deps)
./tests/acceptance/run.sh --type cli
.PHONY: test-acceptance-webui
test-acceptance-webui: $(acceptance_test_deps)
./tests/acceptance/run.sh --type webUI
.PHONY: test-php-style
test-php-style: vendor-bin/owncloud-codestyle/vendor vendor-bin/php_codesniffer/vendor
$(PHP_CS_FIXER) fix -vv --diff --allow-risky yes --dry-run
$(PHP_CODESNIFFER) --cache --runtime-set ignore_warnings_on_exit --standard=phpcs.xml tests/acceptance tests/TestHelpers
php build/OCPSinceChecker.php
.PHONY: test-php-style-fix
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -vv --diff --allow-risky yes
.PHONY: test-php-phan
test-php-phan: vendor-bin/phan/vendor
$(PHAN) --config-file .phan/config.php --require-config-exists -p
.PHONY: test-php-phpstan
test-php-phpstan: vendor-bin/phpstan/vendor
$(PHPSTAN) analyse --memory-limit=2G --configuration=./phpstan.neon --level=0 apps core settings lib/private lib/public ocs ocs-provider
.PHONY: test
test: test-php-style test-php-unit test-js test-acceptance-api test-acceptance-cli test-acceptance-webui
.PHONY: clean-test-acceptance
clean-test-acceptance:
$(MAKE) -C tests/acceptance clean
.PHONY: clean-test-results
clean-test-results:
rm -Rf tests/autotest-*results*.xml
$(MAKE) -C tests/acceptance clean
.PHONY: clean-test
clean-test: clean-test-acceptance clean-test-results
#
# Documentation
#
.PHONY: test-doc-links
test-doc-links:
php tests/docs/DocLinksTest.php $(DOC_LINK_VERSION)
#
# Build distribution
#
$(dist_dir)/owncloud: $(composer_deps) $(core_vendor) $(core_all_src)
cd $(NODE_PREFIX) && $(YARN) run clean-modules
rm -Rf $@; mkdir -p $@/config
cp -RL $(core_all_src) $@
cp -R $(core_config_files) $@/config
find $@ -name .gitkeep -delete
find $@ -name .gitignore -delete
find $@ -name no-php -delete
rm -Rf $@/core/js/tests
rm -Rf $@/settings/tests
rm -Rf $@/core/vendor/*/{.bower.json,bower.json,package.json,testem.json}
rm -Rf $@/l10n/
find $@/core/ -iname \*.sh -delete
find $@/{apps/,lib/composer/,core/vendor/} \( \
-name bin -o \
-name test -o \
-name tests -o \
-name examples -o \
-name demo -o \
-name demos -o \
-name doc -o \
-name travis -o \
-iname \*.sh \
\) -print | xargs rm -Rf
find $@/{apps/,lib/composer/} -iname \*.exe -delete
# Set build
$(eval _BUILD="$(shell date -u --iso-8601=seconds) $(shell git rev-parse HEAD)")
# Replace channel in version.php
sed -i \
-e 's/$$OC_Channel.*$$/$$OC_Channel = '"'"$(RELEASE_CHANNEL)"'"';/g' \
-e 's/$$OC_Build.*$$/$$OC_Build = '"'"$(_BUILD)"'"';/g' \
$(dist_dir)/owncloud/version.php
$(dist_dir)/owncloud-core.tar.bz2: $(dist_dir)/owncloud
cd $(dist_dir) && tar cjf owncloud-core.tar.bz2 owncloud --format=gnu
$(dist_dir)/owncloud-core.zip: $(dist_dir)/owncloud
cd $(dist_dir) && zip -rq9 owncloud-core.zip owncloud
.PHONY: dist
dist: $(dist_dir)/owncloud-core.tar.bz2 $(dist_dir)/owncloud-core.zip
.PHONY: dist-dir
dist-dir: $(dist_dir)/owncloud
.PHONY: clean-dist
clean-dist:
rm -Rf $(dist_dir)
#
# Build qa distribution
#
$(dist_dir)/qa/owncloud: $(composer_dev_deps) $(core_vendor) $(core_all_src) $(core_test_dirs)
cd $(NODE_PREFIX) && $(YARN) run clean-modules
rm -Rf $@; mkdir -p $@/config
cp -RL $(core_all_src) $@
cp -Rf $(core_test_dirs) $@
cp -R $(core_config_files) $@/config
rm -Rf $@/lib/composer/bin; cp -R lib/composer/bin $@/lib/composer/bin
find $@ -name .gitkeep -delete
find $@ -name .gitignore -delete
find $@ -name no-php -delete
rm -Rf $@/core/vendor/*/{.bower.json,bower.json,package.json,testem.json}
rm -Rf $@/l10n/
find $@/core/ -iname \*.sh -delete
find $@/{apps/,lib/composer/,core/vendor/} \( \
-name test -o \
-name examples -o \
-name demo -o \
-name demos -o \
-name doc -o \
-name travis -o \
-iname \*.sh \
\) -print | xargs rm -Rf
find $@/{apps/,lib/composer/} -iname \*.exe -delete
# Set build
$(eval _BUILD="$(shell date -u --iso-8601=seconds) $(shell git rev-parse HEAD)")
# Replace channel in version.php
sed -i \
-e 's/$$OC_Channel.*$$/$$OC_Channel = '"'"$(RELEASE_CHANNEL)"'"';/g' \
-e 's/$$OC_Build.*$$/$$OC_Build = '"'"$(_BUILD)"'"';/g' \
$(dist_dir)/qa/owncloud/version.php
$(dist_dir)/owncloud-qa-core.tar.bz2: $(dist_dir)/qa/owncloud
cd $(dist_dir)/qa && tar cjf owncloud-qa-core.tar.bz2 owncloud --format=gnu
.PHONY: dist-qa
dist-qa: $(dist_dir)/owncloud-qa-core.tar.bz2
.PHONY: dist-dir-qa
dist-dir-qa: $(dist_dir)/qa/owncloud
#
# Miscellaneous tools
#
.PHONY: update-php-license-header
update-php-license-header:
php build/license.php
.PHONY: changelog
changelog:
@echo ======================================================================
@echo WARNING: Please do NOT commit changes in the CHANGELOG.md file to git!
@echo This file is autogenerated on the master branch.
@echo Committing changes to this file will result in merge conflicts.
@echo ======================================================================
docker run --rm -v $(work_dir):$(work_dir) -w $(work_dir) toolhippie/calens calens >| CHANGELOG.md
docker run --rm -v $(work_dir):$(work_dir) -w $(work_dir) toolhippie/calens calens -t changelog/CHANGELOG-html.tmpl >| CHANGELOG.html
#
# Dependency management
#--------------------------------------
composer.lock: composer.json
@echo composer.lock is not up to date.
vendor: composer.lock
composer install --no-dev
vendor/bamarni/composer-bin-plugin: composer.lock
composer install
.PHONY: vendor-bin-deps
vendor-bin-deps: vendor-bin/owncloud-codestyle/vendor vendor-bin/php_codesniffer/vendor vendor-bin/phan/vendor vendor-bin/phpstan/vendor vendor-bin/behat/vendor
.PHONY: vendor-bin-codestyle
vendor-bin-codestyle: vendor-bin/owncloud-codestyle/vendor
.PHONY: vendor-bin-codesniffer
vendor-bin-codesniffer: vendor-bin/php_codesniffer/vendor
.PHONY: vendor-bin-phan
vendor-bin-phan: vendor-bin/phan/vendor
.PHONY: vendor-bin-phpstan
vendor-bin-phpstan: vendor-bin/phpstan/vendor
.PHONY: vendor-bin-behat
vendor-bin-behat: vendor-bin/behat/vendor
vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock
composer bin owncloud-codestyle install --no-progress
vendor-bin/owncloud-codestyle/composer.lock: vendor-bin/owncloud-codestyle/composer.json
@echo owncloud-codestyle composer.lock is not up to date.
vendor-bin/php_codesniffer/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/php_codesniffer/composer.lock
composer bin php_codesniffer install --no-progress
vendor-bin/php_codesniffer/composer.lock: vendor-bin/php_codesniffer/composer.json
@echo php_codesniffer composer.lock is not up to date.
vendor-bin/phan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phan/composer.lock
composer bin phan install --no-progress
vendor-bin/phan/composer.lock: vendor-bin/phan/composer.json
@echo phan composer.lock is not up to date.
vendor-bin/phpstan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phpstan/composer.lock
composer bin phpstan install --no-progress
vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo phpstan composer.lock is not up to date.
vendor-bin/behat/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/behat/composer.lock
composer bin behat install --no-progress
vendor-bin/behat/composer.lock: vendor-bin/behat/composer.json
@echo behat composer.lock is not up to date.