|
| 1 | +COLOR_ENABLED ?= true |
| 2 | +TEST_OUTPUT_STYLE ?= dot |
| 3 | +COVERAGE_OUTPUT_STYLE ?= html |
| 4 | + |
| 5 | +## DIRECTORY AND FILE |
| 6 | +BUILD_DIRECTORY ?= build |
| 7 | +REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports |
| 8 | +COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage |
| 9 | +COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml |
| 10 | + |
| 11 | +## Commands options |
| 12 | +### Composer |
| 13 | +#COMPOSER_OPTIONS= |
| 14 | +### Phpcs |
| 15 | +PHPCS_REPORT_STYLE ?= full |
| 16 | +PHPCS_DISABLE_WARNING ?= "false" |
| 17 | +#PHPCS_REPORT_FILE= |
| 18 | +#PHPCS_REPORT_FILE_OPTION= |
| 19 | + |
| 20 | +# Enable/Disable color ouput |
| 21 | +ifeq ("${COLOR_ENABLED}","true") |
| 22 | + PHPUNIT_COLOR_OPTION ?= --colors=always |
| 23 | + BEHAT_COLOR_OPTION ?= --colors |
| 24 | + PHPCS_COLOR_OPTION ?= --colors |
| 25 | + COMPOSER_COLOR_OPTION ?= --ansi |
| 26 | +else |
| 27 | + PHPUNIT_COLOR_OPTION ?= --colors=never |
| 28 | + PHPCS_COLOR_OPTION ?= --no-colors |
| 29 | + BEHAT_COLOR_OPTION ?= --no-colors |
| 30 | + COMPOSER_COLOR_OPTION ?= --no-ansi |
| 31 | +endif |
| 32 | + |
| 33 | +ifeq ("${TEST_OUTPUT_STYLE}","pretty") |
| 34 | + PHPUNIT_OUTPUT_STYLE_OPTION ?= --testdox |
| 35 | + BEHAT_OUTPUT_STYLE_OPTION ?= --format pretty |
| 36 | +else |
| 37 | + PHPUNIT_OUTPUT_STYLE_OPTION ?= |
| 38 | + BEHAT_OUTPUT_STYLE_OPTION ?= --format progress |
| 39 | +endif |
| 40 | + |
| 41 | +ifeq ("${COVERAGE_OUTPUT_STYLE}","clover") |
| 42 | + PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH} |
| 43 | +else |
| 44 | + ifeq ("${COVERAGE_OUTPUT_STYLE}","html") |
| 45 | + PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY} |
| 46 | + else |
| 47 | + PHPUNIT_COVERAGE_OPTION ?= --coverage-text |
| 48 | + endif |
| 49 | +endif |
| 50 | + |
| 51 | +ifneq ("${PHPCS_REPORT_FILE}","") |
| 52 | + PHPCS_REPORT_FILE_OPTION ?= --report-file=${PHPCS_REPORT_FILE} |
| 53 | +endif |
| 54 | + |
| 55 | +ifneq ("${PHPCS_DISABLE_WARNING}","true") |
| 56 | + PHPCS_DISABLE_WARNING_OPTION= |
| 57 | +else |
| 58 | + PHPCS_DISABLE_WARNING_OPTION=-n |
| 59 | +endif |
| 60 | + |
| 61 | + |
| 62 | +## Project build (install and configure) |
| 63 | +build: install configure |
| 64 | + |
| 65 | +## Project installation |
| 66 | +install: |
| 67 | + composer install ${COMPOSER_COLOR_OPTION} ${COMPOSER_OPTIONS} --prefer-dist --no-suggest --no-interaction |
| 68 | + |
| 69 | +## project Configuration |
| 70 | +configure: |
| 71 | + |
| 72 | +# Project tests |
| 73 | +test: |
| 74 | + make test-functional |
| 75 | + make test-technical |
| 76 | + make codestyle |
| 77 | + |
| 78 | +test-technical: |
| 79 | + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical |
| 80 | + |
| 81 | +test-functional: |
| 82 | + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite functional |
| 83 | + ./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets |
| 84 | + |
| 85 | +codestyle: create-reports-directory |
| 86 | + ./vendor/bin/phpcs ${PHPCS_DISABLE_WARNING_OPTION} --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE} |
| 87 | + |
| 88 | +coverage: create-coverage-directory |
| 89 | + ./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION} |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +# Internal commands |
| 94 | +create-coverage-directory: |
| 95 | + mkdir -p ${COVERAGE_DIRECTORY} |
| 96 | + |
| 97 | +create-reports-directory: |
| 98 | + mkdir -p ${REPORTS_DIRECTORY} |
| 99 | + |
| 100 | + |
| 101 | +.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory |
| 102 | +.DEFAULT: build |
0 commit comments