Skip to content

Instantly share code, notes, and snippets.

@patrickjahns
Created August 21, 2018 07:57
Show Gist options
  • Save patrickjahns/9d925cde469dda5c44fa8b9df5125e51 to your computer and use it in GitHub Desktop.
Save patrickjahns/9d925cde469dda5c44fa8b9df5125e51 to your computer and use it in GitHub Desktop.
Example app setup
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
# bin file definitions
PHPUNIT=php -d zend.enable_gc=0 vendor/bin/phpunit
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "./vendor/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
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
##
## Tests
##--------------------------------------
.PHONY: test-php-unit
test-php-unit: ## Run php unit tests
test-php-unit: vendor/bin/phpunit
$(PHPUNIT) --configuration ./phpunit-unit.xml --testsuite sentry-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-unit.xml --testsuite sentry-unit
.PHONY: test-php-integration
test-php-integration: ## Run php integration tests
test-php-integration: vendor/bin/phpunit
$(PHPUNIT) --configuration ./phpunit-unit.xml --testsuite sentry-integration
.PHONY: test-php-integration-dbg
test-php-integration-dbg: ## Run php integration tests via phpdbg
test-php-integration-dbg: vendor/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit-unit.xml --testsuite sentry-integration
.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
#
# Dependencie 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment