-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (77 loc) · 2.76 KB
/
Copy pathMakefile
File metadata and controls
101 lines (77 loc) · 2.76 KB
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
# See https://tech.davis-hansson.com/p/make/
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.DEFAULT_GOAL := help
.PHONY: help
help:
@printf "\033[33mUsage:\033[0m\n make TARGET\n\n\033[32m#\n# Commands\n#---------------------------------------------------------------------------\033[0m\n\n"
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | awk 'BEGIN {FS = ":"}; {printf "\033[33m%s:\033[0m%s\n", $$1, $$2}'
# PHP CS Fixer
PHP_CS_FIXER=./.tools/php-cs-fixer
PHP_CS_FIXER_URL="https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.95.1/php-cs-fixer.phar"
# PHPUnit
PHPUNIT=vendor/bin/phpunit
PHPUNIT_COVERAGE_CLOVER=--coverage-clover=build/logs/clover.xml
PHPUNIT_ARGS=--coverage-xml=build/logs/coverage-xml --log-junit=build/logs/junit.xml $(PHPUNIT_COVERAGE_CLOVER)
# PHPStan
PHPSTAN=vendor/bin/phpstan
PHPSTAN_ARGS=analyse src tests/phpunit -c .phpstan.neon
# Infection
INFECTION=./.tools/infection.phar
INFECTION_URL="https://github.com/infection/infection/releases/download/0.27.4/infection.phar"
MIN_MSI=78
MIN_COVERED_MSI=82
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=max --log-verbosity=none --no-interaction --no-progress --show-mutations
.PHONY: all
all: ## Executes all checks
all: cs-lint test
.PHONY: cs
cs: ## Apply CS fixes
cs: gitignore composer-validate php-cs-fixer
.PHONY: cs-lint
cs-lint: ## Run CS checks
cs-lint: composer-validate php-cs-fixer-lint
.PHONY: gitignore
gitignore:
LC_ALL=C sort -u .gitignore -o .gitignore
.PHONY: composer-validate
composer-validate: vendor/autoload.php
composer validate --strict
.PHONY: php-cs-fixer
php-cs-fixer: $(PHP_CS_FIXER) vendor/autoload.php
$(PHP_CS_FIXER) fix --verbose --diff
.PHONY: php-cs-fixer-lint
php-cs-fixer-lint: $(PHP_CS_FIXER) vendor/autoload.php
$(PHP_CS_FIXER) fix --verbose --diff --dry-run
composer validate --strict
.PHONY: test
test: ## Executes the tests
test: phpstan test-unit infection test-e2e
.PHONY: phpstan
phpstan:
$(PHPSTAN) $(PHPSTAN_ARGS) --no-progress
.PHONY: test-unit
test-unit: vendor/autoload.php
$(PHPUNIT) $(PHPUNIT_ARGS)
.PHONY: test-e2e
test-e2e: vendor/autoload.php
tests/e2e_tests
.PHONY: infection
infection: $(INFECTION)
$(INFECTION) $(INFECTION_ARGS)
# Do install if there's no 'vendor'
vendor/autoload.php:
composer install --prefer-dist
# If composer.lock is older than `composer.json`, do update,
# and touch composer.lock because composer not always does that
composer.lock: composer.json
composer update
touch -c $@
$(INFECTION): Makefile
wget -q $(INFECTION_URL) --output-document=$(INFECTION)
chmod a+x $(INFECTION)
touch $@
$(PHP_CS_FIXER): Makefile
wget -q $(PHP_CS_FIXER_URL) --output-document=$(PHP_CS_FIXER)
chmod a+x $(PHP_CS_FIXER)
touch $@