-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
202 lines (158 loc) · 6.15 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#
# Makefile
# Les Polypodes, 2014
# Licence: MIT
# Source: https://github.com/polypodes/Build-and-Deploy/blob/master/build/Makefile
# To enable this quality-related tasks, add these dependencies to your composer.json:
# they'll be available in the ./bin dir :
#
# "require-dev": {
# (...)
# "phpunit/phpunit": "~3.7",
# "squizlabs/php_codesniffer": "2.0.x-dev",
# "sebastian/phpcpd": "*",
# "phploc/phploc" : "*",
# "phpmd/phpmd" : "2.0.*",
# "pdepend/pdepend" : "2.0.*",
# "fabpot/php-cs-fixer": "@stable"
# },
# Usage:
# me@myserver$~: make help
# me@myserver$~: make install
# me@myserver$~: make reinstall
# me@myserver$~: make update
# 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)
# Retrieve db connection params, triming white spaces
DB_USER := $(shell if [ -f app/config/parameters.yml ] ; then cat app/config/parameters.yml | grep 'database_user' | sed 's/database_user: //' | sed 's/^ *//;s/ *$$//' ; fi)
DB_PASSWORD := $(shell if [ -f app/config/parameters.yml ] ; then cat app/config/parameters.yml | grep 'database_password' | sed 's/database_password: //' | sed 's/null//' | sed 's/^ *//;s/ *$$//' ; fi)
DB_NAME := $(shell if [ -f app/config/parameters.yml ] ; then cat app/config/parameters.yml | grep 'database_name' | sed 's/database_name: //' | sed 's/^ *//;s/ *$$//' ; fi)
VENDOR_PATH := $(PWD)/vendor
BIN_PATH := $(PWD)/bin
WEB_PATH := $(PWD)/web
NOW := $(shell date +%Y-%m-%d--%H-%M-%S)
REPO := "https://github.com/polypodes/GoogleDrive-based-DMS.git"
BRANCH := 'master'
# Colors
YELLOW := $(shell tput bold ; tput setaf 3)
GREEN := $(shell tput bold ; tput setaf 2)
RESETC := $(shell tput sgr0)
# Custom MAKE options
ifndef VERBOSE
MAKEFLAGS += --no-print-directory
endif
############################################################################
# Mandatory tasks:
all: .git/hook/pre-commit vendor/autoload.php integration/node_modules check help
vendor/autoload.php:
@composer install --optimize-autoloader
.git/hook/pre-commit:
@curl -s -o .git/hooks/pre-commit https://raw.githubusercontent.com/polypodes/Build-and-Deploy/master/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
install: all assets app/Resources/index.html clear done
############################################################################
# Specific, front-related tasks:
integration/node_modules:
@cd integration; npm install; bower install; cd ../
# We sleep 5 seconds to let bower end its own build
web/css:
@sleep 5;
@cd web; ln -s ../integration/public/css css; \
ln -s ../integration/public/fonts fonts; \
ln -s ../integration/public/images images; \
ln -s ../integration/public/js js; cd ../
app/Resources/index.html: web/css
@cd app/Resources; ln -s ../../integration/public/index.html index.html; cd ../../
front_remove:
@rm -rf integration/node_modules
@rm web/css web/js web/fonts web/images app/Resources/index.html
############################################################################
# Generic sf2 tasks:
help:
@echo "\n${GREEN}Usual tasks:${RESETC}\n"
@echo "\tTo prepare install:\tmake"
@echo "\tTo install:\t\tmake install"
@echo "\tTo update from git:\tmake update"
@echo "\tTo reinstall:\t\tmake reinstall (will erase all your datas)\n\n"
@echo "${GREEN}Other specific tasks:${RESETC}\n"
@echo "\tTo check code quality:\tmake quality"
@echo "\tTo fix code style:\tmake cs-fix"
@echo "\tTo clear all caches:\tmake clear"
@echo "\tTo run tests:\t\tmake tests (will erase all your datas)\n"
check:
@php app/check.php
pull:
@git pull origin $(BRANCH)
assets:
@echo "\nPublishing assets..."
@php app/console assets:install --symlink
clear: vendor/autoload.php
@echo
@echo "Resetting caches..."
@php app/console cache:clear --env=prod --no-debug
@php app/console cache:clear --env=dev
explain:
@echo "git pull origin master + build integration + copy new assets + rebuild prod cache"
@echo "Note you can change the git remote repo username in .git/config"
behavior: vendor/autoload.php
# @echo "Run behavior tests..."
# @bin/behat --lang=fr "@AcmeDemoBundle"
unit: vendor/autoload.php
@echo "Run unit tests..."
@php bin/phpunit -c app -v
codecoverage: vendor/autoload.php
@echo "Run coverage tests..."
@bin/phpunit -c app -v --coverage-html ./build/codecoverage
continuous: vendor/autoload.php
@echo "Starting continuous tests..."
@while true; do bin/phpunit -c build/phpunit.xml -v; done
sniff: vendor/autoload.php
@bin/phpcs --standard=PSR2 src -n
dry-fix:
@bin/php-cs-fixer fix . --config=sf23 --dry-run -vv
cs-fix:
@bin/phpcbf --standard=PSR2 src
@bin/php-cs-fixer fix . --config=sf23 -vv
#quality must remain quiet, as far as it's used in a pre-commit hook validation
quality: sniff dry-fix
build:
@mkdir -p build/pdepend
# packagist-based dev tools to add to your composer.json. See http://phpqatools.org
stats: quality build
@echo "Some stats about code quality"
@bin/phploc src
@bin/phpcpd src
@bin/phpmd src text codesize,unusedcode
@bin/pdepend --summary-xml=build/pdepend/summary.xml --jdepend-chart=build/pdepend/jdepend.svg --overview-pyramid=build/pdepend/pyramid.svg src
update: vendor/autoload.php
@$(MAKE) explain
@$(MAKE) pull
@$(MAKE) clear
@$(MAKE) done
robot:
@echo "User-agent: *" > $(WEB_PATH)/robots.txt
@echo "Disallow: " >> $(WEB_PATH)/robots.txt
unrobot:
@echo "User-agent: *" > $(WEB_PATH)/robots.txt
@echo "Disallow: /" >> $(WEB_PATH)/robots.txt
done:
@echo
@echo "${GREEN}Done.${RESETC}"
tests: behavior unit codecoverage
deploy: vendor/autoload.php
@$(MAKE) explain
@$(MAKE) pull
@$(MAKE) clear
@$(MAKE) done
############################################################################
# .PHONY tasks list
.PHONY: data fixtures help check all pull front_remove
.PHONY: assets clear explain behavior unit codecoverage
.PHONY: continuous sniff dry-fix cs-fix quality stats deploy done
.PHONY: install reinstall test update robot unrobot
# vim:ft=make