-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
168 lines (124 loc) · 4.48 KB
/
Makefile
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
.PHONY: ci test prerequisites
# Use any most recent PHP version
PHP=$(shell which php)
PHPDBG=$(shell which phpdbg && echo -qrr || echo php)
# Default parallelism
JOBS=$(shell nproc)
# Default silencer if installed
SILENT=$(shell which chronic)
# PHP CS Fixer
PHP_CS_FIXER=vendor/bin/php-cs-fixer
PHP_CS_FIXER_ARGS=--cache-file=build/cache/.php_cs.cache --verbose
export PHP_CS_FIXER_IGNORE_ENV=1
# PHPUnit
PHPUNIT=vendor/bin/phpunit
PHPUNIT_COVERAGE_CLOVER=--coverage-clover=build/logs/clover.xml
PHPUNIT_GROUP=default
PHPUNIT_ARGS=--coverage-xml=build/logs/coverage-xml --log-junit=build/logs/junit.xml $(PHPUNIT_COVERAGE_CLOVER)
# Phan
PHAN=vendor/bin/phan
PHAN_ARGS=-j $(JOBS) --allow-polyfill-parser
PHAN_PHP_VERSION=7.3
export PHAN_DISABLE_XDEBUG_WARN=1
# PHPStan
PHPSTAN=vendor/bin/phpstan
PHPSTAN_ARGS=analyse src tests --level=2 -c .phpstan.neon
# Psalm
PSALM=vendor/bin/psalm
PSALM_ARGS=--show-info=false
PSALM_PHP_VERSION="PHP 7.3"
# Composer
COMPOSER=$(PHP) $(shell which composer)
# Infection
INFECTION=vendor/bin/infection
MIN_MSI=90
MIN_COVERED_MSI=90
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --coverage=build/logs --log-verbosity=default --show-mutations --no-interaction --only-covered
INFECTION_PHP_VERSION="PHP 7.3"
all: test
##############################################################
# Continuous Integration #
##############################################################
ci-test: SILENT=
ci-test: prerequisites
$(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_COVERAGE_CLOVER) --verbose --group=$(PHPUNIT_GROUP)
ci-analyze: SILENT=
ci-analyze: prerequisites ci-phpunit ci-infection ci-phan ci-phpstan ci-psalm
ci-phpunit: ci-cs
$(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_ARGS)
ci-infection: ci-phpunit
$(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)
ci-phan: ci-cs
$(SILENT) $(PHP) $(PHAN) $(PHAN_ARGS)
ci-phpstan: ci-cs
$(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS) --no-progress || true
ci-psalm: ci-cs
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS) --no-cache
ci-cs: prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --dry-run --stop-on-violation fix
##############################################################
# Development Workflow #
##############################################################
.PHONY: test
test: analyze phpunit composer-validate yamllint
.PHONY: composer-validate
composer-validate: test-prerequisites
$(SILENT) $(COMPOSER) validate --strict
.PHONY: test-prerequisites
test-prerequisites: prerequisites composer.lock
.PHONY: phpunit
phpunit: cs
$(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_ARGS) --verbose
CI=true $(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)
.PHONY: analyze
analyze: phan phpstan psalm
.PHONY: phan
phan: cs
$(SILENT) $(PHP) $(PHAN) $(PHAN_ARGS) --color
.PHONY: phpstan
phpstan: cs
$(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS)
.PHONY: psalm
psalm: cs
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS)
.PHONY: cs
cs: test-prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --diff fix
##############################################################
# Prerequisites Setup #
##############################################################
# We need both vendor/autoload.php and composer.lock being up to date
.PHONY: prerequisites
prerequisites: report-php-version build/cache vendor/autoload.php .phan composer.lock
# Do install if there's no 'vendor'
vendor/autoload.php:
$(SILENT) $(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
$(SILENT) $(COMPOSER) update && touch composer.lock
.phan:
$(PHP) $(PHAN) --init --init-level=1 --init-overwrite --target-php-version=$(PHAN_PHP_VERSION) > /dev/null
build/cache:
mkdir -p build/cache
.PHONY: report-php-version
report-php-version:
# Using $(PHP)
.PHONY: yamllint
yamllint:
find .github/workflows/ -name \*.y*ml -print0 | xargs -n 1 -0 yamllint --no-warnings
##############################################################
# Quick development testing procedure #
##############################################################
PHP_VERSIONS=php7.3 php7.4
.PHONY: quick
quick:
make --no-print-directory -j test-all
.PHONY: test-all
test-all: $(PHP_VERSIONS)
.PHONY: $(PHP_VERSIONS)
$(PHP_VERSIONS): cs
@make --no-print-directory PHP=$@ PHP_CS_FIXER=/bin/true
.PHONY: docs
docs:
mkdocs serve