-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
131 lines (97 loc) · 3.91 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
.PHONY: ci test prerequisites
# Use any most recent PHP version
PHP=$(shell which php)
PHPDBG=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)
PHAN_PHP_VERSION=7.2
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
# Composer
COMPOSER=$(PHP) $(shell which composer)
# Infection
INFECTION=vendor/bin/infection
MIN_MSI=60
MIN_COVERED_MSI=60
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --coverage=build/logs --log-verbosity=default --show-mutations
all: test
##############################################################
# Continuous Integration #
##############################################################
ci-test: SILENT=
ci-test: prerequisites
$(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_COVERAGE_CLOVER) --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)
cp build/logs/junit.xml build/logs/phpunit.junit.xml
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
ci-psalm: ci-cs
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS) --no-cache --shepherd
ci-cs: prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --dry-run --stop-on-violation fix
##############################################################
# Development Workflow #
##############################################################
test: phpunit analyze composer-validate
.PHONY: composer-validate
composer-validate: test-prerequisites
$(SILENT) $(COMPOSER) validate --strict
test-prerequisites: prerequisites composer.lock
phpunit: cs
$(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_ARGS) --verbose
cp build/logs/junit.xml build/logs/phpunit.junit.xml
$(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)
analyze: cs
$(SILENT) $(PHP) $(PHAN) $(PHAN_ARGS) --color
$(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS)
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS)
cs: test-prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --diff fix
LC_ALL=C sort -u .gitignore -o .gitignore
##############################################################
# 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 infection.json.dist .phpstan.neon
# Do install if there's no 'vendor'
vendor/autoload.php:
$(SILENT) $(COMPOSER) install --prefer-dist
test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(SILENT) $(COMPOSER) dump-autoload || true
# 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)