|
| 1 | +# If the first argument is one of the supported commands... |
| 2 | +SUPPORTED_COMMANDS := "install" |
| 3 | +SUPPORTS_MAKE_ARGS := $(findstring $(firstword $(MAKECMDGOALS)), $(SUPPORTED_COMMANDS)) |
| 4 | +ifneq "$(SUPPORTS_MAKE_ARGS)" "" |
| 5 | + # use the rest as arguments for the command |
| 6 | + COMMAND_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) |
| 7 | + # ...and turn them into do-nothing targets |
| 8 | + $(eval $(COMMAND_ARGS):;@:) |
| 9 | +endif |
| 10 | + |
| 11 | +test: phpunit phpcs bugfree phpmd |
| 12 | +test-analysis: phpcs bugfree phpmd |
| 13 | +test-upload: scrutinizer |
| 14 | + |
| 15 | +install: |
| 16 | + make -f Makefile.docker -- composer install $(COMMAND_ARGS) |
| 17 | + |
| 18 | +update: |
| 19 | + |
| 20 | +.PHONY: test test-analysis test-upload pretest phpunit phpcs phpmd bugfree ocular scrutinizer clean clean-env clean-deps |
| 21 | + |
| 22 | +pretest: |
| 23 | + composer install --dev |
| 24 | + |
| 25 | +phpunit: pretest |
| 26 | + [ ! -d tests/output ] || mkdir -p tests/output |
| 27 | + vendor/bin/phpunit --coverage-text --coverage-clover=tests/output/coverage.clover |
| 28 | + |
| 29 | +ifndef STRICT |
| 30 | +STRICT = 0 |
| 31 | +endif |
| 32 | + |
| 33 | +ifeq "$(STRICT)" "1" |
| 34 | +phpcs: pretest |
| 35 | + vendor/bin/phpcs --standard=PSR2 src |
| 36 | +else |
| 37 | +phpcs: pretest |
| 38 | + vendor/bin/phpcs --standard=PSR2 -n src |
| 39 | +endif |
| 40 | + |
| 41 | +phpcbf: pretest |
| 42 | + vendor/bin/phpcbf --standard=PSR2 src |
| 43 | + |
| 44 | +bugfree: pretest |
| 45 | + [ ! -f bugfree.json ] || vendor/bin/bugfree generateConfig |
| 46 | + vendor/bin/bugfree lint src -c bugfree.json |
| 47 | + |
| 48 | +phpmd: pretest |
| 49 | + vendor/bin/phpmd src/ text design,naming,cleancode,codesize,controversial,unusedcode |
| 50 | + |
| 51 | +ocular: |
| 52 | + [ ! -f ocular.phar ] && wget https://scrutinizer-ci.com/ocular.phar |
| 53 | + |
| 54 | +ifdef OCULAR_TOKEN |
| 55 | +scrutinizer: ocular |
| 56 | + @php ocular.phar code-coverage:upload --format=php-clover tests/output/coverage.clover --access-token=$(OCULAR_TOKEN); |
| 57 | +else |
| 58 | +scrutinizer: ocular |
| 59 | + php ocular.phar code-coverage:upload --format=php-clover tests/output/coverage.clover; |
| 60 | +endif |
| 61 | + |
| 62 | +clean: clean-env clean-deps |
| 63 | + |
| 64 | +clean-env: |
| 65 | + rm -rf coverage.clover |
| 66 | + rm -rf ocular.phar |
| 67 | + rm -rf tests/output/ |
| 68 | + |
| 69 | +clean-deps: |
| 70 | + rm -rf vendor/ |
0 commit comments