forked from nixsolutions/zfcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
271 lines (237 loc) · 11.3 KB
/
build.xml
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<project name="ZFCore" default="build">
<property name="appDir" value="${basedir}/application" />
<property name="testsDir" value="${basedir}/tests" />
<property name="coreDir" value="${basedir}/library/Core" />
<property name="buildDir" value="${basedir}/build" />
<property name="logsDir" value="${buildDir}/logs" />
<target name="clean" description="Cleanup build artifacts">
<delete dir="${buildDir}"/>
<delete>
<fileset dir="${basedir}/data/cache" excludes=".empty"/>
<fileset dir="${basedir}/data/logs" excludes=".empty"/>
<fileset dir="${basedir}/data/session" excludes=".empty"/>
</delete>
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.phar"/>
<delete file="${basedir}/composer.lock"/>
</target>
<target name="prepare" depends="clean">
<mkdir dir="${buildDir}"/>
<mkdir dir="${logsDir}" />
<mkdir dir="${buildDir}/logs"/>
<mkdir dir="${buildDir}/logs/clover"/>
<mkdir dir="${buildDir}/docs"/>
<mkdir dir="${buildDir}/coverage"/>
<mkdir dir="${buildDir}/phpcb"/>
<mkdir dir="${buildDir}/pdepend"/>
<!--Requirements-->
<chmod dir="${basedir}/data/cache" perm="777"/>
<chmod dir="${basedir}/data/logs" perm="777"/>
<chmod dir="${basedir}/data/session" perm="777"/>
<chmod dir="${basedir}/data/uploads" perm="777"/>
<chmod dir="${basedir}/public/captcha" perm="777"/>
<chmod dir="${basedir}/public/uploads" perm="777"/>
<!-- Install composer -->
<exec executable="wget" failonerror="true">
<arg value="-nc"/>
<arg value="http://getcomposer.org/composer.phar"/>
</exec>
<exec executable="php" failonerror="true">
<arg value="composer.phar"/>
<arg value="install"/>
</exec>
<!--Configuration-->
<copy file="${appDir}/configs/application.yaml.dist" tofile="${appDir}/configs/application.yaml" />
</target>
<!--<target name="phpdoc">
<exec dir="${basedir}" executable="phpdoc" failonerror="false">
<arg line="-t build/docs
- -directory '${basedir}/application,${basedir}/library/Core'
-ti 'ZFCore Docs'
- -parseprivate on
- -undocumentedelements on
- -output HTML:Smarty:PHP
- -ignore '*.phtml'
- -sourcecode on"/>
</exec>
</target>-->
<target name="phploc" depends="prepare">
<exec dir="${basedir}" executable="phploc" output="${logsDir}/phploc.log">
<arg line="--count-tests" />
<arg line="--log-xml ${logsDir}/phploc.xml" />
<arg line="." />
</exec>
<echo message="##teamcity[publishArtifacts '${logsdDir}/phploc.xml']" />
</target>
<target name="phpcpd" depends="prepare">
<exec dir="${basedir}" executable="phpcpd" failonerror="false" output="${logsDir}/phpcpd.log">
<arg line="--log-pmd ${logsDir}/phpcpd.xml" />
<arg line="${appDir}" />
<arg line="${coreDir}" />
</exec>
<echo message="##teamcity[importData type='pmd' path='${logsDir}/phpcpd.xml']"/>
<echo message="##teamcity[publishArtifacts '${logsDir}/phpcpd.xml']" />
</target>
<target name="phpmd" depends="prepare">
<exec dir="${basedir}" executable="phpmd" failonerror="false" output="${logsDir}/phpmd.log">
<arg line="${basedir}" />
<arg line="xml" />
<arg line="naming,unusedcode,codesize" />
<arg line="--reportfile ${logsDir}/pmd.xml" />
<arg line="--exclude bin,data,library/Zend,library/elFinder,library/Facebook,migrations,public,tests,vendor" />
</exec>
<echo message="##teamcity[importData type='pmd' path='${logsDir}/phpmd.log']"/>
</target>
<target name="pdepend" depends="prepare" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
<exec dir="${basedir}" executable="pdepend" failonerror="false" output="${logsDir}/pdepend.log">
<arg line="--jdepend-xml=${logsDir}/jdepend.xml" />
<arg line="--jdepend-chart=${logsDir}/dependencies.png" />
<arg line="--overview-pyramid=${logsDir}/overview-pyramid.png" />
<arg line="--phpunit-xml=${logsDir}/pdepend.phpunit.xml"></arg>
<arg line="--summary-xml=${logsDir}/pdepend.summary.xml"></arg>
<arg line="--coverage-report=${logsDir}/phpunit.clover.xml"></arg>
<arg line="--coderank-mode=inheritance,property,method"></arg>
<arg line="--exclude=bin,data,library/Zend,library/elFinder,library/Facebook,migrations,public,tests,vendor"/>
<arg line="${basedir}"/>
</exec>
<echo message="##teamcity[publishArtifacts '${logsDir}/pdepend.jdepend.chart.png']" />
<echo message="##teamcity[publishArtifacts '${logsDir}/pdepend.jdepend.xml']" />
<echo message="##teamcity[publishArtifacts '${logsDir}/pdepend.overview.pyramid.png']" />
<echo message="##teamcity[publishArtifacts '${logsDir}/pdepend.phpunit.xml']" />
<echo message="##teamcity[publishArtifacts '${logsDir}/pdepend.summary.xml']" />
<echo message="##teamcity[publishArtifacts '${logsDir}/phpunit.clover.xml']" />
</target>
<target name="phpcs" depends="prepare">
<exec dir="${basedir}" executable="phpcs" failonerror="false" output="${logsDir}/phpcs.log">
<arg line="--report=full" />
<arg line="--extensions=php"/>
<arg line="--standard=Zend"/>
<arg line="--report-file=${logsDir}/checkstyle.xml" />
<arg line="${appDir}"/>
<arg line="${coreDir}"/>
<arg line="${testsDir}"/>
</exec>
<echo message="##teamcity[publishArtifacts '${logsDir}/checkstyle.xml']" />
</target>
<target name="phpunit" depends="prepare" description="Run unit tests with PHPUnit">
<exec dir="${basedir}/tests" executable="${basedir}/vendor/bin/phpunit" output="${logsDir}/phpunit.log">
<!--<env key="APP_ENV" value="ci"/>-->
<arg line="--verbose"/>
<arg line="--log-junit '${logsDir}/junit.xml'"/>
<arg line="--coverage-clover '${logsDir}/clover.xml'"/>
<arg line="--coverage-html '${logsDir}/clover'"/>
<arg line="TestSuite.php"/>
</exec>
<echo message="##teamcity[importData type='junit' path='${logsDir/phpunit.xml}']" />
</target>
<target name="phpcb" depends="phpcpd, phpmd, phpcs">
<exec executable="phpcb" output="${logsDir}/phpcb.log">
<arg line="--log ${logsDir}" />
<arg line="--output ${buildDir}/phpcb" />
</exec>
<zip destfile="${buildDir}/phpcb/phpcb.zip" basedir="${buildDir}/phpcb" />
<echo message="##teamcity[publishArtifacts '${buildDir}/phpcb/phpcb.zip']" />
</target>
<target name="build" depends="phploc, pdepend, phpunit, phpcb"/>
<target name="update-source" depends="prepare">
<exec dir="${basedir}" executable="hg" output="${logsDir}/hg.log">
<arg line="pull" />
</exec>
<exec dir="${basedir}" executable="hg" output="${logsDir}/hg.log">
<arg line="update" />
</exec>
</target>
<target name="clean-db">
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration blog" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration faq" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration feedback" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration forum" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration menu" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration pages" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration users" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="down migration" />
</exec>
</target>
<target name="recreate-db" depends="clean-db">
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration blog" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration faq" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration feedback" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration forum" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration menu" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration pages" />
</exec>
<exec dir="${basedir}/bin" executable="./zfc.sh">
<arg line="up migration users" />
</exec>
</target>
<target name="load-test-data" depends="recreate-db">
<!-- Add here any test data (may be provided with custom migrations) -->
</target>
<target name="show-maintanance-page">
<copy file="${basedir}/public/robots.txt"
tofile="${basedir}/public/original-robots.txt"
overwrite="true" failonerror="false" />
<copy file="${basedir}/public/maintenance-robots.txt"
tofile="${basedir}/public/robots.txt"
overwrite="true" />
<copy file="${basedir}/public/.htaccess"
tofile="${basedir}/public/original.htaccess"
overwrite="true" />
<copy file="${basedir}/public/maintenance.htaccess"
tofile="${basedir}/public/.htaccess"
overwrite="true" />
</target>
<target name="remove-maintanance-page">
<copy file="${basedir}/public/original.htaccess"
tofile="${basedir}/public/.htaccess"
overwrite="true" />
<copy file="${basedir}/public/original-robots.txt"
tofile="${basedir}/public/robots.txt"
overwrite="true" failonerror="false" />
</target>
<target name="reset-demo" depends="show-maintanance-page,update-source,load-test-data,remove-maintanance-page"/>
<target name="nightly" depends="update-nightly, build, save-nightly"/>
<target name="update-nightly">
<exec dir="${basedir}" executable="hg" output="${logsDir}/hg.log" failonerror="true">
<arg line="up -C nightly" />
</exec>
<exec dir="${basedir}" executable="hg" output="${logsDir}/hg.log" failonerror="true">
<arg line="merge default" />
</exec>
</target>
<target name="save-nightly">
<tstamp/>
<exec dir="${basedir}" executable="hg" output="${logsDir}/hg.log" failonerror="true">
<arg line="commit -m '${DSTAMP}'" />
</exec>
</target>
</project>