-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
111 lines (82 loc) · 3.12 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
.PHONY: ci test prerequisites
# Use any most recent PHP version
PHP=$(shell which php)
# Default parallelism
JOBS=$(shell nproc)
# PHP CS Fixer
PHP_CS_FIXER=./.tools/php-cs-fixer
PHP_CS_FIXER_URL="https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.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
# Psalm
PSALM=vendor/bin/psalm
PSALM_ARGS=--show-info=false
# Composer
COMPOSER=$(PHP) $(shell which composer)
# Infection
INFECTION=./.tools/infection.phar
INFECTION_URL="https://github.com/infection/infection/releases/download/0.25.3/infection.phar"
MIN_MSI=68
MIN_COVERED_MSI=97
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=none --no-interaction --no-progress --show-mutations
all: test
cs:
cs: $(PHP_CS_FIXER)
$(PHP_CS_FIXER) fix -v --diff --dry-run
LC_ALL=C sort -u .gitignore -o .gitignore
phpstan:
$(PHPSTAN) $(PHPSTAN_ARGS) --no-progress
psalm:
$(PSALM) $(PSALM_ARGS) --no-cache --shepherd
static-analyze: phpstan psalm
test-unit:
$(PHPUNIT) $(PHPUNIT_ARGS)
infection: $(INFECTION)
$(INFECTION) $(INFECTION_ARGS)
##############################################################
# Development Workflow #
##############################################################
test: phpunit analyze composer-validate
.PHONY: composer-validate
composer-validate: test-prerequisites
$(COMPOSER) validate --strict
test-prerequisites: prerequisites composer.lock
phpunit: cs-fix
$(PHPUNIT) $(PHPUNIT_ARGS) --verbose
cp build/logs/junit.xml build/logs/phpunit.junit.xml
$(PHP) $(INFECTION) $(INFECTION_ARGS)
analyze: cs-fix
$(PHPSTAN) $(PHPSTAN_ARGS)
$(PSALM) $(PSALM_ARGS)
cs-fix: test-prerequisites
$(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS)
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: build/cache vendor/autoload.php composer.lock infection.json.dist .phpstan.neon
# Do install if there's no 'vendor'
vendor/autoload.php:
$(COMPOSER) install --prefer-dist
test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(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
$(COMPOSER) update && touch composer.lock
build/cache:
mkdir -p build/cache
$(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 $@