-
Notifications
You must be signed in to change notification settings - Fork 78
/
Makefile
122 lines (96 loc) · 3.51 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
#
# Makefile
# Licence: MIT
# Original: https://github.com/polypodes/Build-and-Deploy/blob/master/build/Makefile
# Usage:
# me@myserver$~: make
# me@myserver$~: make help
# me@myserver$~: make tests
# me@myserver$~: make quality
# etc.
############################################################################
# Vars
# some lines may be useless for now, but these are nice tricks:
PWD := $(shell pwd)
VENDOR_PATH := $(PWD)/vendor
BIN_PATH := $(PWD)/bin
BUILD_PATH := $(PWD)/build
NOW := $(shell date +%Y-%m-%d--%H-%M-%S)
REPO := "https://github.com/ronanguilloux/php-gpio"
BRANCH := 'master'
PHP_CS_OPTS := '$()'
# Colors
YELLOW := $(shell tput bold ; tput setaf 3)
GREEN := $(shell tput bold ; tput setaf 2)
RESETC := $(shell tput sgr0)
############################################################################
# Mandatory tasks:
all: build .git/hook/pre-commit vendor/autoload.php help done
build:
@mkdir -p build/cov
@mkdir -p build/logs
vendor/autoload.php:
@composer self-update
@composer install --optimize-autoloader
install:
@composer self-update
@composer install --optimize-autoloader
update:
@composer install --optimize-autoloader
.git/hook/pre-commit:
@cp pre-commit .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
############################################################################
# Generic sf2 tasks:
help:
@echo "\n${GREEN}Usual tasks:${RESETC}\n"
@echo "\tTo initialize:\t\tmake"
@echo "\tTo check code quality:\tmake quality"
@echo "\tTo run tests suite:\tmake tests"
@echo "\tTo fix code style:\tmake cs-fix"
@echo "\n${GREEN}Other specific tasks:${RESETC}\n"
@echo "\tTo run a simple continuous tests server:\tmake continuous"
@echo "\tTo dry-fix code style issues:\t\t\tmake dry-fix"
@echo "\tTo evaluate code quality stats:\t\t\tmake stats"
@echo "\tTo update vendors using Composer:\t\tmake update\n"
unit: vendor/autoload.php
@echo "Run unit tests..."
@php bin/phpunit -v
continuous: vendor/autoload.php
@echo "Starting continuous tests..."
@while true; do bin/phpunit -v; done
sniff: vendor/autoload.php
@bin/phpcs --standard=PSR2 src -n
@bin/phpcs --standard=PSR2 tests -n
dry-fix:
@bin/php-cs-fixer fix --config=.php_cs.php --dry-run --stop-on-violation --using-cache=no -vv
cs-fix:
@bin/phpcbf --standard=PSR2 src
@bin/phpcbf --standard=PSR2 tests
@bin/php-cs-fixer fix --config=.php_cs.php --using-cache=no -vv
#quality must remain quiet, as far as it's used in a pre-commit hook validation
quality: sniff dry-fix
# packagist-based dev tools to add to your composer.json. See http://phpqatools.org
stats: build quality done
@echo "Some stats about code quality"
@bin/phploc src
@bin/phploc tests
@bin/phpcpd src
@bin/phpcpd tests
@bin/pdepend --summary-xml=./build/summary.xml --jdepend-chart=./build/jdepend.svg --overview-pyramid=./build/pyramid.svg src
@bin/phpmd src text codesize,unusedcode
done:
@echo
@echo "${GREEN}Done.${RESETC}"
tests: vendor/autoload.php
@echo "Run tests & build code coverage report..."
@bin/phpunit -v --coverage-html ./build/codecoverage
@echo "\n${GREEN}Check code coverage:${RESETC}\n"
@echo "\t(OS X)\t\topen build/codecoverage/index.html"
@echo "\t(Linux)\t\txdg-open build/codecoverage/index.html"
@echo "\t(available only if a code coverage driver was available)\n"
############################################################################
# .PHONY tasks list
.PHONY: all install update help unit codecoverage continuous
.PHONY: sniff dry-fix cs-fix quality stats done tests
# vim:ft=make