My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?xml version="1.0" ?>
<!--
*
* Copyright (c) FaZend.com
* All rights reserved.
*
* You can use this product "as is" without any warranties from authors.
* You can change the product only through Google Code repository
* at http://code.google.com/p/fazend
* If you have any questions about privacy, please email privacy@fazend.com
*
* @copyright Copyright (c) FaZend.com
* @version $Id$
* @category FaZend
*
* This Phing build file. For more information see this document:
* http://phing.info/docs/guide/current/
*
-->

<project basedir="." default="main">

<!-- Sets the DSTAMP, TSTAMP and TODAY properties -->
<tstamp/>

<!-- all php scripts should be able to include files from these dirs -->
<includepath classpath="${project.basedir}/src/library" />
<includepath classpath="${project.basedir}/test" />

<!-- this is where CC home is located -->
<property name="cc.root" value="/home/cc" />

<!-- main task, executed by the project -->
<target name="main"
depends="svn, lint, phpcs, phpmd, test, deploy, phprack, clean"
description="Validate, compile, deploy and clean">
</target>

<!-- get revision number -->
<svnlastrevision
workingcopy="${project.basedir}"
propertyname="svn.revision"/>
<echo msg="SVN revision: ${svn.revision}" />

<target name="svn" description="Get all necessary information about current build" >
<!--
{to.deploy} asks the builder to deploy everything created to the
target directories in the CruiseControl environment.
-->
<if>
<not><isset property="to.deploy" /></not>
<then>
<if><available file="${cc.root}" type="dir" /><then>
<!-- this property is used later in order to turn deployment ON -->
<property name="to.deploy" value="true" />
<!-- ftp uploader -->
<taskdef name="uploadByFTP" classname="src.library.FaZend.Application.Phing.UploadByFTP" />
</then><else>
<property name="to.deploy" value="false" />
<echo msg="{to.deploy} set to FALSE since it's not a CruiseControl environment" />
</else></if>
</then></if>

<!--
{to.lint} property explicitly asks the builder to validate
PHP syntax in all PHP/PHTML/HTML files and stops the process
if any problems are found
-->
<if>
<not><isset property="to.lint" /></not>
<then>
<property name="to.lint" value="${to.deploy}" />
</then></if>

<!--
{to.clean} property asks the builder to clean everything
created during building, all reports, temp files, documentation
and other information, which is present on the disc
-->
<if>
<not><isset property="to.clean" /></not>
<then>
<property name="to.clean" value="${to.deploy}" />
</then></if>

<!--
{to.coverage} property asks the builder to setup PHP coverage
database before running of PHPUnit tests and to create
coverage report when all tests are finished. xdebug PHP extension
should be loaded in order to use this feature.
-->
<if>
<not><isset property="to.coverage" /></not>
<then>
<if><isset property="to.unit" /><then>
<property name="to.coverage" value="false" />
</then><else>
<property name="to.coverage" value="${to.deploy}" />
</else></if>
</then></if>

<!--
{to.phpcs} asks the builder to validate PHP/PHTML syntax with PHPCS
PEAR package and stops building if any errors are found (warnings
are ignored). PHPCS package is mandatory to use this task.
-->
<if>
<not><isset property="to.phpcs" /></not>
<then>
<property name="to.phpcs" value="false" />
</then></if>

<!--
{to.phpmd} property explicitly asks the builder to validate
PHP code quality with PHP Mess Detector
-->
<if>
<not><isset property="to.phpmd" /></not>
<then>
<property name="to.phpmd" value="false" />
</then></if>

<!--
{to.unit} may define a mask for the test to run, all other validations
and reports will be disabled.
-->
<if>
<isset property="to.unit" />
<then>
<property name="to.deploy" value="false" override="true" />
<property name="to.phpcs" value="false" override="true" />
<property name="to.coverage" value="false" override="true" />
<property name="to.phpmd" value="false" override="true" />
</then></if>

<echo msg="{to.deploy} set to ${to.deploy}" />
<echo msg="{to.lint} set to ${to.lint}" />
<echo msg="{to.clean} set to ${to.clean}" />
<echo msg="{to.coverage} set to ${to.coverage}" />
<echo msg="{to.phpcs} set to ${to.phpcs}" />
<echo msg="{to.phpmd} set to ${to.phpmd}" />
</target>

<target name="lint" description="Run syntax check for all classes" >
<if><istrue value="${to.lint}" />
<then>
<phplint haltonfailure="yes" level="verbose">
<fileset dir="${project.basedir}/src/application">
<include name="**/*.php"/>
<include name="**/*.phtml"/>
<exclude name=".svn/**"/>
</fileset>
</phplint>
</then><else>
<echo msg="Skipped in '${phing.project.name}', since {to.lint} is FALSE" />
</else></if>
</target>

<target name="test" description="Run all existing unit-tests" >
<!-- prepare code coverage db -->
<if><istrue value="${to.coverage}" /><then>
<property name="coverage.db" value="${coverage.dir}/coverage.xml" />

<!-- make sure it exists -->
<mkdir dir="${coverage.dir}" />

<!-- create coverage database that will collect all reports -->
<coverage-setup database="${coverage.db}">
<fileset dir="${project.basedir}/src/application">
<include name="**/*.php"/>
<exclude name=".svn/**"/>
</fileset>
</coverage-setup>
</then></if>

<!-- one individual test, specified in -Dto.unit=... -->
<if><isset property="to.unit" /><then>
<phpunit haltonerror="yes" haltonfailure="yes">
<formatter type="plain" usefile="no" />
<batchtest>
<fileset dir="${project.basedir}">
<include name="${to.unit}"/>
<include name="test/${to.unit}"/>
</fileset>
<fileset dir="${project.basedir}/test">
<include name="closers/*.php"/>
<exclude name="**/Abstract*.php"/>
<exclude name="**/_*.php"/>
<exclude name=".svn/**"/>
</fileset>
</batchtest>
</phpunit>
</then><else>
<mkdir dir="${project.basedir}/reports/tests" />
<phpunit haltonerror="yes" haltonfailure="yes" codecoverage="${to.coverage}"
haltonincomplete="false" haltonskipped="false">
<formatter type="xml" usefile="true" todir="${project.basedir}/reports/tests" />
<formatter type="plain" usefile="no" />
<batchtest>
<fileset dir="${project.basedir}/test">
<include name="**/*Test.php"/>
<exclude name="**/Abstract*.php"/>
<exclude name="**/_*.php"/>
<exclude name=".svn/**"/>
</fileset>
<fileset dir="${project.basedir}/test">
<include name="closers/*.php"/>
<exclude name="**/Abstract*.php"/>
<exclude name="**/_*.php"/>
<exclude name=".svn/**"/>
</fileset>
</batchtest>
</phpunit>
</else></if>
</target>

<target name="phpcs" description="Validate the quality of PHP code with PHPCS utility">
<if><istrue value="${to.phpcs}" /><then>
<!-- see: http://pear.php.net/package/PHP_CodeSniffer/download -->
<exec command="phpcs
-n
--report=full
--standard=Zend
--ignore='.svn/*'
--extensions='php'
${project.basedir}/src/application"
escape="false"
checkreturn="true"
passthru="true" />
</then><else>
<echo msg="Skipped in '${phing.project.name}', since {to.phpcs} is FALSE" />
</else></if>
</target>

<target name="phpmd" description="PHP Mess Detection">
<if><istrue value="${to.phpmd}" /><then>
<exec command="phpmd
${project.basedir}/src/application
text
codesize,unusedcode
--extensions='php,phtml'
"
escape="false"
checkreturn="false"
passthru="true" />
</then><else>
<echo msg="Skipped in '${phing.project.name}', since {to.phpmd} is FALSE" />
</else></if>
</target>

<target name="deploy" description="Upload source files to the production FTP">
<if><istrue value="${to.deploy}" /><then>
<echo msg="${svn.revision}" file="${project.basedir}/src/application/deploy/subversion/revision.txt" />

<!-- set flag.txt for the application, to notify it that the DB should be resynchronized -->
<echo msg="${svn.revision}" file="${project.basedir}/src/application/deploy/flag.txt" />

<echo msg="Uploading revision: ${svn.revision}" />
<!-- the Task is defined as PHP class, see phings/UploadByFTP.php -->

<php expression="set_error_handler(create_function('', 'return true;'));"/>
<mkdir dir="${project.basedir}/build/ftp-upload"/>
<copy todir="${project.basedir}/build/ftp-upload" preservelastmodified="true">
<filterchain>
<expandproperties />
</filterchain>
<fileset dir="${project.basedir}/${ftp.srcdir}">
<include name="**/*.ini" />
</fileset>
</copy>
<copy todir="${project.basedir}/build/ftp-upload" preservelastmodified="true">
<filterchain>
<stripwhitespace />
</filterchain>
<fileset dir="${project.basedir}/${ftp.srcdir}">
<include name="**/*.php" />
</fileset>
</copy>
<copy todir="${project.basedir}/build/ftp-upload" preservelastmodified="true">
<fileset dir="${project.basedir}/${ftp.srcdir}">
<include name="**" />
<exclude name=".svn/**" />
<exclude name="**/*.php" />
<exclude name="**/*.ini" />
</fileset>
</copy>
<uploadByFTP server="${ftp.server}"
username="${ftp.user}"
password="${ftp.password}"
srcdir="${project.basedir}/build/ftp-upload"
destdir="${ftp.destdir}">
</uploadByFTP>
</then><else>
<echo msg="Skipped in '${phing.project.name}', since {to.deploy} is FALSE" />
</else></if>
</target>

<target name="phprack" description="Ping phpRack URL in order to run integration tests">
<if><and>
<istrue value="${to.deploy}" />
<isset property="phprack.url" />
</and><then>
<http-request
url="${phprack.url}"
responseRegex="/PHPRACK SUITE: OK/"
observerEvents="connect,receivedBody,disconnect"
verbose="true"
/>
</then><else>
<echo msg="Skipped in '${phing.project.name}', since it's not a continuous integration environment" />
</else></if>
</target>

<target name="clean" description="Remove obsolete files just created" >
<if><istrue value="${to.clean}" /><then>
<delete verbose="false" includeemptydirs="true" failonerror="false">
<fileset dir="${project.basedir}/reports">
<include name="*" />
</fileset>
<fileset dir="${project.basedir}/build">
<include name="*" />
</fileset>
</delete>
</then><else>
<echo msg="Skipped in '${phing.project.name}', since {to.clean} is set to FALSE" />
</else></if>
</target>

</project>

Change log

r2271 by yegor256 on Dec 30, 2010   Diff
include all files
Go to: 
Sign in to write a code review

Older revisions

r2268 by yegor256 on Dec 30, 2010   Diff
tighter exclude/include rules
r2267 by yegor256 on Dec 30, 2010   Diff
 preservelastmodified="true"
r2266 by yegor256 on Dec 30, 2010   Diff
ignore errors
All revisions of this file

File info

Size: 13119 bytes, 329 lines

File properties

svn:eol-style
native
svn:keywords
Id
Powered by Google Project Hosting