-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.backend
169 lines (138 loc) · 6.04 KB
/
Makefile.backend
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
#------------------------------------------------------------------------------
# include platform make defs - so we can override them
#------------------------------------------------------------------------------
SHELL := /bin/bash
# If BUILD_NUMBER is not set, set it to 0
BUILD_NUMBER ?= 0
RESULTS_PHP_CODE_COVERAGE = docs/results/code-coverage
RESULTS_PHP_UNIT_TESTS = docs/results/unit-tests
DOXYGEN_CONF = build/doxygen.conf
SYNTAX_CHECKS :=
ifneq (,$(PHP_FILES))
SYNTAX_CHECKS += php-syntax-check
endif
UNIT_TESTS :=
ifneq (,$(PHP_UNIT_TESTS))
UNIT_TESTS += php-unit-test
endif
#------------------------------------------------------------------------------
# Syntax Checking
#------------------------------------------------------------------------------
php-syntax-check:
@$(PRE_PHP_SYNTAX_CHECK) \
set -e ; \
for FILE in $(shell find . -name '*.php' -o -name '*.inc' -o -name '*.shtml'); do \
php -l $$FILE; \
done \
$(POST_PHP_SYNTAX_CHECK)
php-syntax-check-dev:
@echo "Checking syntax for modified project files...";
# are we in a git repo or subversion?
@if [ -d .git ]; then \
for FILE in `git status | egrep '(modified|new file).*\.(php|inc|shtml)$$' | awk '{print $$NF}'`; do \
php -l $$FILE; \
done; \
elif [ -d .svn ]; then \
for FILE in `svn status | egrep '^(M|A)' | egrep '\.(php|inc|shtml)$$' | awk '{print $$NF}'`; do \
php -l $$FILE; \
done; \
fi
@echo "";
.PHONY: php-syntax-check php-syntax-check-dev
#------------------------------------------------------------------------------
# Unit Tests and Code Coverage
#------------------------------------------------------------------------------
php-unit-test-code-coverage: php-results-directories
phpunit \
--coverage-clover $(RESULTS_PHP_CODE_COVERAGE)/clover.xml \
--coverage-html $(RESULTS_PHP_CODE_COVERAGE) \
--log-junit $(RESULTS_PHP_UNIT_TESTS)/$(BUILD_DIR).xml \
--bootstrap $(PHP_UNIT_TEST_BOOTSTRAP) \
-d memory_limit=1G \
$(PHP_UNIT_TEST_DIR)
php-unit-test-dev:
@ $(CURDIR)/app/Console/cakeshell test app all -cli /opt/local/bin \
-console $(CURDIR)/lib/Cake/Console -app $(CURDIR)/app
@ echo
# shortcut
phpunit: php-unit-test-dev
php-results-directories:
mkdir -p $(RESULTS_PHP_CODE_COVERAGE)
mkdir -p $(RESULTS_PHP_UNIT_TESTS)
.PHONY: php-unit-test php-unit-test-dev php-results-directories
#------------------------------------------------------------------------------
# Frontend tests
#------------------------------------------------------------------------------
frontend-test-local:
@php app/Test/Functional/frontend.php -e local
frontend-test-dev:
@php app/Test/Functional/frontend.php -e dev
frontend-test-stage:
@php app/Test/Functional/frontend.php -e stage
#------------------------------------------------------------------------------
# Doxygen PHP docs
#------------------------------------------------------------------------------
doxygen-phpdocs:
rm -rf app/tmp/docs/doxygen
mkdir -p app/tmp/docs
doxygen $(DOXYGEN_CONF)
echo "DirectoryIndex index.html" > app/tmp/docs/doxygen/html/.htaccess
rm -rf debug.txt app/webroot/docs/doxygen
mv app/tmp/docs/doxygen/html app/webroot/docs/doxygen
.PHONY: doxygen-phpdocs
#------------------------------------------------------------------------------
# PHP Code Sniffer
#------------------------------------------------------------------------------
# The " || exit 0" is a hack to force phpcs to run properly since it always exits 1 with warnings
# or errors. This should be revisited in the future and see if we really want to always force this
# to succeed if there are errors in the job running.
# @todo -- increase memory limit, figure out custom phpcs standard
php_cs:
mkdir -p results; \
touch results/checkstyle.xml; \
phpcs --standard=Media --ignore=*/thirdparty/* --report=checkstyle --report-file=results/checkstyle.xml app || exit 0;\
#------------------------------------------------------------------------------
# default build
#------------------------------------------------------------------------------
all:: build-test-package
#------------------------------------------------------------------------------
# data import/export
#------------------------------------------------------------------------------
import: import-data clean
import-data:
@bash app/Scripts/import.sh
export:
@bash app/Scripts/export.sh
#------------------------------------------------------------------------------
# general project tasks
#------------------------------------------------------------------------------
ctp-to-twig:
for i in `git status --porcelain -u | grep "ctp$$" | awk '{print $$NF}'`; \
do FILE=`echo $$i | cut -f1 -d. -`; mv -f $$FILE".ctp" $$FILE".twig"; done
#------------------------------------------------------------------------------
# clean
#------------------------------------------------------------------------------
clean:
@echo "Making clean cache"
@echo "When prompted, enter your sudo password..."
@sudo app/Scripts/init.sh
#------------------------------------------------------------------------------
# documentation
#------------------------------------------------------------------------------
documentation: doxygen-phpdocs
docs: documentation
#------------------------------------------------------------------------------
# build-test-package
#------------------------------------------------------------------------------
build-test-package: $(SYNTAX_CHECKS) $(UNIT_TESTS) frontend-test-local
#------------------------------------------------------------------------------
# build-release-package
#------------------------------------------------------------------------------
build-release-package: $(SYNTAX_CHECKS) $(UNIT_TESTS) frontend-test-local
#------------------------------------------------------------------------------
# pre-commit build, quicker for devs
# -- only run syntax checks on changed files in repo
# -- don't build code coverage metrics for phpunit
#------------------------------------------------------------------------------
# @todo add php-unit-test-dev
pre-commit: php-syntax-check-dev php-unit-test-dev frontend-test-local