-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (92 loc) · 2.91 KB
/
Makefile
File metadata and controls
123 lines (92 loc) · 2.91 KB
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
DEV := .dev
BIN := $(DEV)/bin
BUILD := $(DEV)/build
CONFIG := $(DEV)/config
SOURCES := src
VENDORBIN := vendor/bin
PHPLOC := $(BIN)/phploc
PHPCS := $(BIN)/phpcs
PHPCS_CFG := $(CONFIG)/phpcs.xml
PHPCBF := $(BIN)/phpcbf
PHPCPD := $(BIN)/phpcpd
PHPMD := $(BIN)/phpmd
PHPMD_CFG := $(CONFIG)/phpmd.xml
PHPSTAN := $(VENDORBIN)/phpstan
PHPSTAN_CFG := $(CONFIG)/phpstan.neon
PHPUNIT := $(VENDORBIN)/phpunit
PHPUNIT_CFG := $(CONFIG)/phpunit.xml
all:
@echo "Review the file 'Makefile' to see what targets are supported."
clean:
rm -rf $(BUILD) .phpunit.result.cache
clean-all: clean
rm -rf $(BIN) vendor composer.lock
install: install-php-tools
[ ! -f composer.json ] || composer install
install-php-tools:
install -d $(BIN)
# phploc
curl -Lso $(PHPLOC) https://phar.phpunit.de/phploc.phar && chmod 755 $(PHPLOC)
# phpcs
curl -Lso $(PHPCS) https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && chmod 755 $(PHPCS)
# phpcbf
curl -Lso $(PHPCBF) https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar && chmod 755 $(PHPCBF)
# phpcpd
curl -Lso $(PHPCPD) https://phar.phpunit.de/phpcpd.phar && chmod 755 $(PHPCPD)
# phpmd
curl -Lso $(PHPMD) https://github.com/phpmd/phpmd/releases/download/2.9.1/phpmd.phar && chmod 755 $(PHPMD)
# phpstan
composer require phpstan/phpstan --dev
# phpunit
composer require phpunit/phpunit --dev
check-version:
uname -a
@which make
make --version
@which php
php --version
@which composer
composer --version
$(PHPLOC) --version
$(PHPCS) --version
$(PHPCBF) --version
$(PHPCPD) --version
$(PHPMD) --version
$(PHPSTAN) --version
$(PHPUNIT) --version
check: check-version
prepare:
[ -d $(BUILD) ] || install -d $(BUILD)
rm -rf $(BUILD)/*
phploc: prepare
[ ! -d src ] || $(PHPLOC) $(SOURCES) | tee $(BUILD)/$@
phpcs: prepare
[ ! -f $(PHPCS_CFG) ] || $(PHPCS) --standard=$(PHPCS_CFG) | tee $(BUILD)/$@
phpcbf:
[ ! -f $(PHPCS_CFG) ] || $(PHPCBF) --standard=$(PHPCS_CFG) | tee $(BUILD)/$@
phpcpd: prepare
$(PHPCPD) $(SOURCES) | tee $(BUILD)/$@
phpmd: prepare
- [ ! -f $(PHPMD_CFG) ] || $(PHPMD) . text $(PHPMD_CFG) | tee $(BUILD)/$@
phpstan: prepare
- [ ! -f $(PHPSTAN_CFG) ] || $(PHPSTAN) analyse -c $(PHPSTAN_CFG) | tee $(BUILD)/$@
phpunit: prepare
[ ! -f $(PHPUNIT_CFG) ] || XDEBUG_MODE=coverage $(PHPUNIT) --configuration $(PHPUNIT_CFG) $(options) | tee $(BUILD)/$@
cs: phpcs
lint: cs phpcpd phpmd phpstan
test: lint phpunit
composer validate
metric: phploc
#
# OLDER, clean up eventually
#
# phpcbf:
# ifneq ($(wildcard test),)
# - [ ! -f $(PHPCS_CFG) ] || $(PHPCBF) --standard=$(PHPCS_CFG)
# else
# - [ ! -f $(PHPCS_CFG) ] || $(PHPCBF) --standard=$(PHPCS_CFG) src
# endif
# phpmd: prepare
# - [ ! -f .phpmd.xml ] || [ ! -d src ] || $(PHPMD) . text .phpmd.xml | tee build/phpmd
# phpunit: prepare
# [ ! -d test ] || XDEBUG_MODE=coverage $(PHPUNIT) --configuration .phpunit.xml $(options) | tee build/phpunit