-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Makefile
281 lines (221 loc) · 8.08 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# See https://tech.davis-hansson.com/p/make/
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
SRC_FILES := $(shell find bin/ src/ vendor-hotfix/ -type f)
PHP_SCOPER_PHAR_BIN = bin/php-scoper.phar
PHP_SCOPER_PHAR = $(PHP_SCOPER_PHAR_BIN)
COMPOSER_BIN_PLUGIN_VENDOR = vendor/bamarni/composer-bin-plugin
PHPSTAN_BIN = vendor-bin/phpstan/vendor/bin/phpstan
PHPSTAN = $(PHPSTAN_BIN) analyze src tests --level max --memory-limit=-1
BOX_BIN = bin/box
BOX = $(BOX_BIN)
COVERAGE_DIR = build/coverage
COVERAGE_XML = $(COVERAGE_DIR)/xml
COVERAGE_HTML = $(COVERAGE_DIR)/html
PHPUNIT_BIN = bin/phpunit
PHPUNIT = $(PHPUNIT_BIN)
PHPUNIT_COVERAGE_INFECTION = XDEBUG_MODE=coverage $(PHPUNIT) --coverage-xml=$(COVERAGE_XML) --log-junit=$(COVERAGE_DIR)/phpunit.junit.xml
PHPUNIT_COVERAGE_HTML = XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html=$(COVERAGE_HTML)
RECTOR_BIN = vendor-bin/rector/vendor/bin/rector
RECTOR = $(RECTOR_BIN)
PHP_CS_FIXER_BIN = vendor-bin/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
PHP_CS_FIXER = $(PHP_CS_FIXER_BIN) fix
BLACKFIRE = blackfire
.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}'
#
# Commands
#---------------------------------------------------------------------------
.PHONY: check
check: ## Runs all checks
check: composer_root_version_lint cs autoreview test composer_root_version_check
.PHONY: build
build: ## Builds the PHAR
build:
rm $(PHP_SCOPER_PHAR_BIN) || true
$(MAKE) $(PHP_SCOPER_PHAR_BIN)
.PHONY: fixtures_composer_outdated
fixtures_composer_outdated: ## Reports outdated dependencies
fixtures_composer_outdated:
@find fixtures -name 'composer.json' -type f -depth 2 -exec dirname '{}' \; | xargs -I % sh -c 'printf "Installing dependencies for %;\n" $$(composer install --working-dir=% --ansi)'
@find fixtures -name 'composer.json' -type f -depth 2 -exec dirname '{}' \; | xargs -I % sh -c 'printf "Checking dependencies for %;\n" $$(composer outdated --direct --working-dir=% --ansi)'
.PHONY: cs
cs: ## Fixes CS
cs: gitignore_sort composer_normalize php_cs_fixer
.PHONY: cs_lint
cs_lint: ## Checks CS
cs_lint: composer_normalize_lint php_cs_fixer_lint
.PHONY: php_cs_fixer
php_cs_fixer: $(PHP_CS_FIXER_BIN)
$(PHP_CS_FIXER)
.PHONY: php_cs_fixer_lint
php_cs_fixer_lint: $(PHP_CS_FIXER_BIN)
$(PHP_CS_FIXER) --dry-run --diff
.PHONY: composer_normalize
composer_normalize: composer.json vendor
composer normalize
.PHONY: composer_normalize_lint
composer_normalize_lint: composer.json vendor
composer normalize --dry-run
.PHONY: gitignore_sort
gitignore_sort:
LC_ALL=C sort -u .gitignore -o .gitignore
.PHONY: phpstan
phpstan: $(PHPSTAN_BIN)
$(PHPSTAN)
.PHONY: autoreview
autoreview: ## Runs the AutoReview checks
autoreview: cs_lint phpstan rector_lint
.PHONY: test
test: ## Runs all the tests
test: validate_package phpunit e2e
.PHONY: validate_package
validate_package:
composer validate --strict
.PHONY: composer_root_version_check
composer_root_version_check: ## Runs all checks for the ComposerRootVersion app
composer_root_version_check:
cd composer-root-version-checker; $(MAKE) --file Makefile check
.PHONY: composer_root_version_lint
composer_root_version_lint: ## Checks that the COMPOSER_ROOT_VERSION is up to date
composer_root_version_lint: .composer-root-version
cd composer-root-version-checker; $(MAKE) --makefile Makefile check_root_version
.PHONY: composer_root_version_update
composer_root_version_update: ## Updates the COMPOSER_ROOT_VERSION
composer_root_version_update:
rm .composer-root-version || true
$(MAKE) .composer-root-version
.PHONY: phpunit
phpunit: $(PHPUNIT_BIN) vendor
$(PHPUNIT)
.PHONY: phpunit_coverage_infection
phpunit_coverage_infection: $(PHPUNIT_BIN) vendor
$(PHPUNIT_COVERAGE_INFECTION)
.PHONY: phpunit_coverage_html
phpunit_coverage_html: ## Runs PHPUnit with code coverage with HTML report
phpunit_coverage_html: $(PHPUNIT_BIN) vendor
$(PHPUNIT_COVERAGE_HTML)
.PHONY: infection
infection: $(COVERAGE_XML) vendor
#infection: $(INFECTION_BIN) $(COVERAGE_XML) vendor
if [ -d $(COVERAGE_XML) ]; then $(INFECTION); fi
include .makefile/e2e.file
.PHONY: e2e
e2e: ## Runs end-to-end tests
e2e: e2e_004 \
e2e_005 \
e2e_011 \
e2e_013 \
e2e_014 \
e2e_015 \
e2e_016 \
e2e_017 \
e2e_018 \
e2e_019 \
e2e_020 \
e2e_024 \
e2e_025 \
e2e_027 \
e2e_028 \
e2e_029 \
e2e_030 \
e2e_031 \
e2e_032 \
e2e_033 \
e2e_034 \
e2e_035 \
e2e_036 \
e2e_037 \
e2e_038 \
e2e_039 \
e2e_040
.PHONY: blackfire
blackfire: ## Runs Blackfire profiling
blackfire: vendor
@echo "By https://blackfire.io"
@echo "This might take a while (~2min)"
$(BLACKFIRE) run php bin/php-scoper add-prefix --output-dir=build/php-scoper --force --quiet
.PHONY: clean
clean: ## Cleans all created artifacts
clean:
git clean --exclude=.idea/ -ffdx
.PHONY: rector
rector: $(RECTOR_BIN) vendor
$(RECTOR)
.PHONY: rector_lint
rector_lint: $(RECTOR_BIN) vendor
$(RECTOR) --dry-run
#
# Rules from files
#---------------------------------------------------------------------------
.composer-root-version:
cd composer-root-version-checker; $(MAKE) --makefile Makefile dump_root_version
touch -c $@
vendor: composer.lock .composer-root-version
$(MAKE) vendor_install
# Sometimes we need to re-install the vendor. Since it has a few dependencies
# we do not want to check over and over, as unlike re-installing dependencies
# which is fast, those might have a significant overhead (e.g. checking the
# composer root version), we do not want to repeat the step of checking the
# vendor dependencies.
.PHONY: vendor_install
vendor_install:
/bin/bash -c 'source .composer-root-version && composer install'
touch -c vendor
touch -c $(COMPOSER_BIN_PLUGIN_VENDOR)
touch -c $(PHPUNIT_BIN)
touch -c $(BOX_BIN)
composer.lock: composer.json
@echo "$(@) is not up to date. You may want to run the following command:"
@echo "$$ composer update --lock && touch -c $(@)"
vendor-hotfix: vendor
composer dump-autoload
touch -c $@
$(COMPOSER_BIN_PLUGIN_VENDOR): composer.lock .composer-root-version
$(MAKE) --always-make vendor_install
touch -c $@
$(PHPUNIT_BIN): composer.lock .composer-root-version
$(MAKE) --always-make vendor_install
touch -c $@
$(BOX_BIN): composer.lock .composer-root-version
$(MAKE) --always-make vendor_install
touch -c $@
.PHONY: php_cs_fixer_install
php_cs_fixer_install: $(PHP_CS_FIXER_BIN)
$(PHP_CS_FIXER_BIN): vendor-bin/php-cs-fixer/vendor
touch -c $@
vendor-bin/php-cs-fixer/vendor: vendor-bin/php-cs-fixer/composer.lock $(COMPOSER_BIN_PLUGIN_VENDOR)
composer bin php-cs-fixer install
touch -c $@
vendor-bin/php-cs-fixer/composer.lock: vendor-bin/php-cs-fixer/composer.json
@echo "$(@) is not up to date. You may want to run the following command:"
@echo "$$ composer bin php-cs-fixer update --lock && touch -c $(@)"
.PHONY: phpstan_install
phpstan_install: $(PHPSTAN_BIN)
$(PHPSTAN_BIN): vendor-bin/phpstan/vendor
touch -c $@
vendor-bin/phpstan/vendor: vendor-bin/phpstan/composer.lock $(COMPOSER_BIN_PLUGIN_VENDOR)
composer bin phpstan install
touch -c $@
vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo "$(@) is not up to date. You may want to run the following command:"
@echo "$$ composer bin phpstan update --lock && touch -c $(@)"
.PHONY: rector_install
rector_install: $(RECTOR_BIN)
$(RECTOR_BIN): vendor-bin/rector/vendor
touch -c $@
vendor-bin/rector/vendor: vendor-bin/rector/composer.lock $(COMPOSER_BIN_PLUGIN_VENDOR)
composer bin rector install
touch -c $@
vendor-bin/rector/composer.lock: vendor-bin/rector/composer.json
@echo "$(@) is not up to date. You may want to run the following command:"
@echo "$$ composer bin rector update --lock && touch -c $(@)"
$(PHP_SCOPER_PHAR_BIN): $(BOX) bin/php-scoper $(SRC_FILES) vendor scoper.inc.php box.json.dist
$(BOX) compile --no-parallel
touch -c $@
$(COVERAGE_XML): $(PHPUNIT_BIN) $(SRC_FILES)
$(MAKE) phpunit_coverage_infection
touch -c "$@"