forked from infection/infection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
158 lines (112 loc) · 5.53 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
PHP_CS_FIXER_FUTURE_MODE=1
PHPSTAN=./phpstan.phar
PHP-CS-FIXER=./php-cs-fixer-v2.phar
PHPUNIT=vendor/bin/phpunit
INFECTION=build/bin/infection.phar
# URLs to download all tools
BOX_URL="https://github.com/humbug/box/releases/download/3.0.0-alpha.5/box.phar"
PHP-CS-FIXER_URL="https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar"
PHPSTAN_URL="https://github.com/phpstan/phpstan/releases/download/0.9.1/phpstan.phar"
FLOCK=./devTools/flock
DOCKER_RUN=docker run -t --rm -v "$$PWD":/opt/infection -w /opt/infection
DOCKER_RUN_70=$(FLOCK) devTools/*php70*.json $(DOCKER_RUN) infection_php70
DOCKER_RUN_71=$(FLOCK) devTools/*php71*.json $(DOCKER_RUN) infection_php71
DOCKER_RUN_72=$(FLOCK) devTools/*php72*.json $(DOCKER_RUN) infection_php72
.PHONY: all
#Run all checks, default when running 'make'
all: analyze test
#Non phony targets for phars etc.
vendor: composer.json composer.lock
composer install
build/cache:
mkdir -p build/cache
./php-cs-fixer-v2.phar:
wget $(PHP-CS-FIXER_URL)
chmod a+x ./php-cs-fixer-v2.phar
./phpstan.phar:
wget $(PHPSTAN_URL)
chmod a+x ./phpstan.phar
#All tests, (infection itself, phpunit, e2e) for different php version/ environments (xdebug or phpdbg)
.PHONY: test test-unit test-infection-phpdbg test-e2e-phpdbg test-infection-xdebug test-e2e-xdebug
test: test-unit test-infection-phpdbg test-e2e-phpdbg test-infection-xdebug test-e2e-xdebug
# All tests finished without errors
.PHONY: test-unit test-unit-70 test-unit-71 test-unit-72
#php unit tests
test-unit: test-unit-70 test-unit-71 test-unit-72
test-unit-70: build-xdebug-70
$(DOCKER_RUN_70) $(PHPUNIT)
test-unit-71: build-xdebug-71
$(DOCKER_RUN_71) $(PHPUNIT)
test-unit-72: build-xdebug-72
$(DOCKER_RUN_72) $(PHPUNIT)
.PHONY: test-infection-phpdbg test-infection-phpdbg-70 test-infection-phpdbg-71 test-infection-phpdbg-72
#infection with phpdbg
test-infection-phpdbg: test-infection-phpdbg-70 test-infection-phpdbg-71 test-infection-phpdbg-72
test-infection-phpdbg-70: build-xdebug-70
$(DOCKER_RUN_70) phpdbg -qrr bin/infection --threads=4
test-infection-phpdbg-71: build-xdebug-71
$(DOCKER_RUN_71) phpdbg -qrr bin/infection --threads=4
test-infection-phpdbg-72: build-xdebug-72
$(DOCKER_RUN_72) phpdbg -qrr bin/infection --threads=4
.PHONY: test-e2e-phpdbg test-e2e-phpdbg-70 test-e2e-phpdbg-71 test-e2e-phpdbg-72
#e2e tests with phpdbg
test-e2e-phpdbg: test-e2e-phpdbg-70 test-e2e-phpdbg-71 test-e2e-phpdbg-72
test-e2e-phpdbg-70: build-xdebug-70 $(INFECTION)
$(DOCKER_RUN_70) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)
test-e2e-phpdbg-71: build-xdebug-71 $(INFECTION)
$(DOCKER_RUN_71) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)
test-e2e-phpdbg-72: build-xdebug-72 $(INFECTION)
$(DOCKER_RUN_72) env PHPDBG=1 ./tests/e2e_tests $(INFECTION)
.PHONY: test-infection-xdebug test-infection-xdebug-70 test-infection-xdebug-71 test-infection-xdebug-72
#infection with xdebug
test-infection-xdebug: test-infection-xdebug-70 test-infection-xdebug-71 test-infection-xdebug-72
test-infection-xdebug-70: build-xdebug-70
$(DOCKER_RUN_70) php bin/infection --threads=4
test-infection-xdebug-71: build-xdebug-71
$(DOCKER_RUN_71) php bin/infection --threads=4
test-infection-xdebug-72: build-xdebug-72
$(DOCKER_RUN_72) php bin/infection --threads=4
.PHONY: test-e2e-xdebug test-e2e-xdebug-70 test-e2e-xdebug-71 test-e2e-xdebug-72
#e2e tests with xdebug
test-e2e-xdebug: test-e2e-xdebug-70 test-e2e-xdebug-71 test-e2e-xdebug-72
test-e2e-xdebug-70: build-xdebug-70 $(INFECTION)
$(DOCKER_RUN_70) ./tests/e2e_tests $(INFECTION)
test-e2e-xdebug-71: build-xdebug-71 $(INFECTION)
$(DOCKER_RUN_71) ./tests/e2e_tests $(INFECTION)
test-e2e-xdebug-72: build-xdebug-72 $(INFECTION)
$(DOCKER_RUN_72) ./tests/e2e_tests $(INFECTION)
.PHONY: build-xdebug-70 build-xdebug-71 build-xdebug-72
#Building images with xdebug
build-xdebug-70: vendor devTools/Dockerfile-php70-xdebug.json
devTools/Dockerfile-php70-xdebug.json: devTools/Dockerfile-php70-xdebug
docker build -t infection_php70 -f devTools/Dockerfile-php70-xdebug .
docker image inspect infection_php70 >> devTools/Dockerfile-php70-xdebug.json
build-xdebug-71: vendor devTools/Dockerfile-php71-xdebug.json
devTools/Dockerfile-php71-xdebug.json: devTools/Dockerfile-php71-xdebug
docker build -t infection_php71 -f devTools/Dockerfile-php71-xdebug .
docker image inspect infection_php71 >> devTools/Dockerfile-php71-xdebug.json
build-xdebug-72: vendor devTools/Dockerfile-php72-xdebug.json
devTools/Dockerfile-php72-xdebug.json: devTools/Dockerfile-php72-xdebug
docker build -t infection_php72 -f devTools/Dockerfile-php72-xdebug .
docker image inspect infection_php72 >> devTools/Dockerfile-php72-xdebug.json
#style checks/ static analysis
.PHONY: analyze cs-fix cs-check phpstan validate auto-review
analyze: cs-check phpstan validate
cs-fix: build/cache $(PHP-CS-FIXER)
$(PHP-CS-FIXER) fix -v --cache-file=build/cache/.php_cs.cache
cs-check: build/cache $(PHP-CS-FIXER)
$(PHP-CS-FIXER) fix -v --cache-file=build/cache/.php_cs.cache --dry-run --stop-on-violation
phpstan: vendor $(PHPSTAN)
$(PHPSTAN) analyse src --level=max -c ./devTools/phpstan-src.neon --no-interaction --no-progress
$(PHPSTAN) analyse tests --level=2 -c ./devTools/phpstan-tests.neon --no-interaction --no-progress
validate:
composer validate --strict
auto-review: vendor
vendor/bin/phpunit --group=auto-review
build/bin/infection.phar: $(shell find bin/ src/ -type f) box.phar box.json .git/HEAD
php box.phar compile
box.json: box.json.dist
cat box.json.dist | sed -E 's/\"key\": \".+\",//g' | sed -E 's/\"algorithm\": \".+\",//g' > box.json
box.phar:
wget $(BOX_URL)
chmod a+x box.phar