-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
377 lines (321 loc) · 14 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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?xml version="1.0" encoding="UTF-8"?>
<project name="%PROJECT_NAME%" default="build">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<property name="composer.path" value="/bin/composer" />
<property name="composer.json" value="${basedir}/composer.json" />
<property name="php" value="/usr/bin/php" />
<property name="codecept.phar" value="${basedir}/bin/codecept" />
<property name="symfony.console" value="${basedir}/app/console" />
<property name="project.dir-app" value="app"/>
<property name="project.dir-app-cache" value="${project.dir-app}/cache"/>
<property name="project.dir-app-logs" value="${project.dir-app}/logs"/>
<available file="${composer.json}" property="runComposerUpdate" />
<target name="build" description="Build" depends="-buildInit, -buildDevelop, -buildRelease, -buildMaster, -buildElse" />
<target name="-buildInit" description="Detect selected platform for building">
<condition property="do.Develop">
<equals arg1="${platform}" arg2="develop" />
</condition>
<condition property="do.Release">
<equals arg1="${platform}" arg2="release" />
</condition>
<condition property="do.Master">
<equals arg1="${platform}" arg2="master" />
</condition>
<condition property="do.Else">
<not>
<or>
<equals arg1="${platform}" arg2="develop" />
<equals arg1="${platform}" arg2="release" />
<equals arg1="${platform}" arg2="master" />
</or>
</not>
</condition>
</target>
<target name="-buildDevelop" if="do.Develop" description="Build develop branch">
<antcall target="-firstStep" />
<antcall target="-autoTests" />
<antcall target="-report" />
</target>
<target name="-buildRelease" if="do.Release" description="Build release branch">
<antcall target="-firstStep" />
<antcall target="-symfonyCacheWarmupProd" />
<antcall target="-propelMigrate" />
<antcall target="-mysqlCreateDump" />
<antcall target="-autoTests" />
<antcall target="-mysqlLoadDump" />
<antcall target="-elasticSearch2" />
<antcall target="-report" />
</target>
<target name="-buildMaster" if="do.Master" description="Build master branch">
<antcall target="-firstStep" />
<antcall target="-symfonyCacheWarmupProd" />
<antcall target="-propelMigrate" />
<antcall target="-mysqlCreateDump" />
<antcall target="-autoTests" />
<antcall target="-mysqlLoadDump" />
<antcall target="-elasticSearch2" />
<antcall target="-report" />
</target>
<target name="-buildElse" if="do.Else">
<fail>Invalid value of $${platfom} variable. Must be [develop|release|master]</fail>
</target>
<target name="-firstStep" description="Prepare for build">
<antcall target="-cleanDirs" />
<antcall target="-makeDirs" />
<antcall target="-composer" />
<antcall target="-propelModels" />
<antcall target="-phpLint" />
<antcall target="-twigLint" />
<antcall target="-jsHint" />
</target>
<target name="-autoTests">
<antcall target="-propelSqlGenerate" />
<antcall target="-propelSqlInsert" />
<antcall target="-propelLoadFixtures" />
<antcall target="-elasticSearch" />
<antcall target="-phantomJsRestart" />
<antcall target="-codeceptUnit" />
<antcall target="-codeceptAcceptance" />
<antcall target="-codeceptApi" />
</target>
<target name="-propelMigrate">
<antcall target="-propelMigrateGenerate" />
<antcall target="-propelMigrateApply" />
</target>
<target name="-report">
<antcall target="-phploc" />
<antcall target="-pdepend" />
<antcall target="-phpmd" />
<antcall target="-phpcs" />
<antcall target="-phpcpd" />
<antcall target="-phpdox" />
</target>
<target name="-cleanDirs" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
<delete dir="${basedir}/build/phpdox"/>
<delete dir="${basedir}/tests/_log" />
<delete dir="${basedir}/c3tmp" />
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<include name="${project.dir-app-cache}/**"/>
<exclude name="${project.dir-app-cache}/.gitkeep"/>
<exclude name="${project.dir-app-cache}/.gitignore"/>
<include name="${project.dir-app-logs}/*"/>
<exclude name="${project.dir-app-logs}/.gitkeep"/>
<exclude name="${project.dir-app-logs}/.gitignore"/>
</fileset>
</delete>
</target>
<target name="-makeDirs" description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
<mkdir dir="${basedir}/build/phpdox"/>
<mkdir dir="${basedir}/tests/_log" />
<mkdir dir="${basedir}/c3tmp" />
</target>
<target name="-phantomJsRestart" description="Restart PhantomJS service for drop cache with static files">
<exec executable="sudo">
<arg value="service" />
<arg value="phantomjs" />
<arg value="restart" />
</exec>
</target>
<target name="-symfonyCacheWarmupProd" description="Warms up an empty cache for prod environment">
<exec executable="${symfony.console}" failonerror="true">
<arg value="cache:warmup" />
<arg value="--env=prod" />
<arg value="--no-debug" />
<arg value="--no-interaction" />
</exec>
</target>
<target name="-phpLint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="-twigLint" description="Perform syntax check of Twig templates">
<apply executable="${symfony.console}" failonerror="true">
<arg value="twig:lint" />
<fileset dir="${basedir}/app">
<include name="**/*.twig" />
<modified />
</fileset>
<fileset dir="${basedir}/src">
<include name="**/*.twig" />
<modified />
</fileset>
</apply>
</target>
<target name="-jsHint" description="Perform syntax check of JavaScript">
<apply executable="jshint">
<fileset dir="${basedir}/web/resources">
<include name="**/*.js" />
<exclude name="**/*.min.js" />
<modified />
</fileset>
<fileset dir="${basedir}/src">
<include name="**/*.js" />
<exclude name="**/*.min.js" />
<modified />
</fileset>
</apply>
</target>
<target name="-phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="-pdepend" description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="-phpmd" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}/src" />
<arg value="xml" />
<arg value="${basedir}/phpmd.xml" />
<arg value="--exclude" />
<arg value="Tests/,om/,map/" />
<arg value="--reportfile" />
<arg value="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="-phpcs" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--encoding=utf-8" />
<arg value="--ignore=*/vendor/*,*/app/*,*/tests/*,*/om/*,*/map/*,*Trait.php,*Test.php" />
<arg value="--extensions=php" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="-phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd=${basedir}/build/logs/pmd-cpd.xml" />
<arg value="--exclude=om" />
<arg value="--exclude=map" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="-phpdox" description="Generate API documentation using phpDox">
<exec executable="phpdox"/>
</target>
<target name="-codeceptUnit" description="Run unit tests with Codeception">
<exec executable="${codecept.phar}" failonerror="true">
<arg value="run" />
<arg value="unit" />
<arg value="--coverage" />
<arg value="--xml" />
<arg value="--html" />
</exec>
</target>
<target name="-codeceptAcceptance" description="Run acceptance tests with Codeception">
<exec executable="${codecept.phar}" failonerror="true">
<arg value="run" />
<arg value="acceptance" />
</exec>
</target>
<target name="-codeceptApi" description="Run fuctional tests for checking API for ToolBar">
<exec executable="${codecept.phar}" failonerror="true">
<arg value="run" />
<arg value="api" />
</exec>
</target>
<target name="-composer" description="Run composer install or update">
<if>
<isset property="runComposerUpdate" />
<then>
<antcall target="-composerUpdate" />
</then>
<else>
<antcall target="-composerInstall" />
</else>
</if>
</target>
<target name="-composerUpdate" if="runComposerUpdate" description="Run composer update before each build">
<exec executable="${composer.path}" failonerror="true">
<arg value="update" />
</exec>
</target>
<target name="-composerInstall" unless="runComposerUpdate" description="Run composer install on first build">
<exec executable="${composer.path}" failonerror="true">
<arg value="install" />
</exec>
</target>
<target name="-propelModels" description="Generate Propel models">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:model:build" />
</exec>
</target>
<target name="-propelSqlGenerate" description="Generate Propel migration">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:sql:build" />
</exec>
</target>
<target name="-propelSqlInsert" description="Migrate database with generated Propel migration data">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:sql:insert" />
<arg value="--force" />
</exec>
</target>
<target name="-propelLoadFixtures" description="Load Propel fixtures into database for test">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:fixtures:load" />
<arg value="--dir=app/propel/fixtures-jenkins/" />
</exec>
</target>
<target name="-propelMigrateGenerate" description="Build migration diff for Propel migrate">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:migration:generate-diff" />
</exec>
</target>
<target name="-propelMigrateApply" description="Apply Propel migration">
<exec executable="${symfony.console}" failonerror="true">
<arg value="propel:migration:migrate" />
</exec>
</target>
<target name="-elasticSearch" description="Populate coupons data into ElasticSearch indicies">
<exec executable="${symfony.console}" failonerror="true">
<arg value="fos:elastica:populate" />
</exec>
</target>
<target name="-elasticSearch2" description="Populate coupons data into ElasticSearch indicies">
<exec executable="${symfony.console}" failonerror="true">
<arg value="fos:elastica:populate" />
</exec>
</target>
<target name="-mysqlCreateDump" description="Dump real data from DB into dump before autotests">
<exec executable="mysqldump" output="${basedir}/build/mysqldump.sql" failonerror="true">
<arg value="-u${mysqlUser}" />
<arg value="-p${mysqlPassword}" />
<arg value="${mysqlDatabase}" />
</exec>
</target>
<target name="-mysqlLoadDump" description="Restore real data from dump into DB after autotests">
<exec executable="mysql" input="${basedir}/build/mysqldump.sql" failonerror="true">
<arg value="-u${mysqlUser}" />
<arg value="-p${mysqlPassword}" />
<arg value="${mysqlDatabase}" />
</exec>
</target>
</project>