-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vincent Petry
committed
Apr 4, 2019
1 parent
960de33
commit fbfeb1e
Showing
2 changed files
with
184 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
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,183 @@ | ||
SHELL := /bin/bash | ||
|
||
COMPOSER_BIN := $(shell command -v composer 2> /dev/null) | ||
ifndef COMPOSER_BIN | ||
$(error composer is not available on your system, please install composer) | ||
endif | ||
|
||
NPM := $(shell command -v npm 2> /dev/null) | ||
ifndef NPM | ||
$(error npm is not available on your system, please install npm) | ||
endif | ||
|
||
NODE_PREFIX=$(shell pwd) | ||
BOWER=$(NODE_PREFIX)/node_modules/bower/bin/bower | ||
JSDOC=$(NODE_PREFIX)/node_modules/.bin/jsdoc | ||
|
||
app_name=$(notdir $(CURDIR)) | ||
doc_files=README.md CHANGELOG.md | ||
src_dirs=appinfo img lib | ||
all_src=$(src_dirs) $(doc_files) | ||
build_dir=$(CURDIR)/build | ||
dist_dir=$(build_dir)/dist | ||
|
||
# dependency folders (leave empty if not required) | ||
composer_deps= | ||
composer_dev_deps= | ||
nodejs_deps= | ||
bower_deps= | ||
|
||
# signing | ||
occ=$(CURDIR)/../../occ | ||
private_key=$(HOME)/.owncloud/certificates/$(app_name).key | ||
certificate=$(HOME)/.owncloud/certificates/$(app_name).crt | ||
sign=$(occ) integrity:sign-app --privateKey="$(private_key)" --certificate="$(certificate)" | ||
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or occ can not be found at $(occ)" | ||
ifneq (,$(wildcard $(private_key))) | ||
ifneq (,$(wildcard $(certificate))) | ||
ifneq (,$(wildcard $(occ))) | ||
CAN_SIGN=true | ||
endif | ||
endif | ||
endif | ||
|
||
# bin file definitions | ||
PHPUNIT=php -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit" | ||
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit" | ||
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer | ||
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 | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
# start with displaying help | ||
help: | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | ||
|
||
# | ||
# Node dependencies | ||
# | ||
$(nodejs_deps): package.json | ||
$(NPM) install --prefix $(NODE_PREFIX) && touch $@ | ||
|
||
$(BOWER): $(nodejs_deps) | ||
$(JSDOC): $(nodejs_deps) | ||
|
||
$(bower_deps): $(BOWER) | ||
$(BOWER) install && touch $@ | ||
|
||
# | ||
# dist | ||
# | ||
$(dist_dir)/$(app_name): $(composer_deps) $(bower_deps) | ||
rm -Rf $@; mkdir -p $@ | ||
cp -R $(all_src) $@ | ||
rm -Rf $@/l10n/{.git*,.tx*} | ||
|
||
ifdef CAN_SIGN | ||
$(sign) --path="$(dist_dir)/$(app_name)" | ||
else | ||
@echo $(sign_skip_msg) | ||
endif | ||
tar --format=gnu --owner=nobody --group=nogroup -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name) | ||
|
||
.PHONY: dist | ||
dist: $(dist_dir)/$(app_name) | ||
|
||
.PHONY: clean-dist | ||
clean-dist: | ||
rm -Rf $(dist_dir) | ||
|
||
.PHONY: clean-build | ||
clean-build: | ||
rm -Rf $(build_dir) | ||
|
||
.PHONY: clean-deps | ||
clean-deps: | ||
rm -Rf $(nodejs_deps) $(bower_deps) | ||
|
||
.PHONY: clean | ||
clean: clean-deps clean-dist clean-build | ||
|
||
## | ||
## Tests | ||
##-------------------------------------- | ||
|
||
.PHONY: test-php-unit | ||
test-php-unit: ## Run php unit tests | ||
test-php-unit: vendor/bin/phpunit | ||
$(PHPUNIT) --configuration ./phpunit.xml --testsuite unit | ||
|
||
.PHONY: test-php-unit-dbg | ||
test-php-unit-dbg: ## Run php unit tests using phpdbg | ||
test-php-unit-dbg: vendor/bin/phpunit | ||
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite unit | ||
|
||
.PHONY: test-php-style | ||
test-php-style: ## Run php-cs-fixer and check owncloud code-style | ||
test-php-style: vendor-bin/owncloud-codestyle/vendor | ||
$(PHP_CS_FIXER) fix -v --diff --diff-format udiff --allow-risky yes --dry-run | ||
|
||
.PHONY: test-php-style-fix | ||
test-php-style-fix: ## Run php-cs-fixer and fix code style issues | ||
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor | ||
$(PHP_CS_FIXER) fix -v --diff --diff-format udiff --allow-risky yes | ||
|
||
.PHONY: test-php-phan | ||
test-php-phan: ## Run phan | ||
test-php-phan: vendor-bin/phan/vendor | ||
$(PHAN) --config-file .phan/config.php --require-config-exists | ||
|
||
.PHONY: test-php-phpstan | ||
test-php-phpstan: ## Run phpstan | ||
test-php-phpstan: vendor-bin/phpstan/vendor | ||
$(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib | ||
|
||
.PHONY: test-acceptance-api | ||
test-acceptance-api: ## Run API acceptance tests | ||
test-acceptance-api: vendor/bin/phpunit | ||
../../tests/acceptance/run.sh --remote --type api | ||
|
||
.PHONY: test-acceptance-cli | ||
test-acceptance-cli: ## Run CLI acceptance tests | ||
test-acceptance-cli: vendor/bin/phpunit | ||
../../tests/acceptance/run.sh --remote --type cli | ||
|
||
.PHONY: test-acceptance-webui | ||
test-acceptance-webui: ## Run webUI acceptance tests | ||
test-acceptance-webui: vendor/bin/phpunit | ||
../../tests/acceptance/run.sh --remote --type webUI | ||
|
||
# | ||
# Dependency management | ||
#-------------------------------------- | ||
|
||
composer.lock: composer.json | ||
@echo composer.lock is not up to date. | ||
|
||
vendor: composer.lock | ||
composer install --no-dev | ||
|
||
vendor/bin/phpunit: composer.lock | ||
composer install | ||
|
||
vendor/bamarni/composer-bin-plugin: composer.lock | ||
composer install | ||
|
||
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/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. |