forked from akeneo/pim-community-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
476 lines (424 loc) · 21.7 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<?xml version="1.0" encoding="UTF-8"?>
<project name="pim" default="build"
>
<property name="symfony.catalog.storage.dir" value="catalog" />
<target name="build" depends="prepare,composer,vendors,setupdb,fixtures,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpunit,phpspec,phpcb"/>
<target name="build-phpunit" depends="prepare,composer,vendors-no-scripts,phpunit,phpspec,phpspec-junit"/>
<target name="build-coverage" depends="prepare,composer,coverage"/>
<target name="build-behat" depends="prepare,composer,vendors,install-all-behat,behat"/>
<target name="build-behat-deprecated" depends="prepare-deprecated-behat,prepare,composer,vendors,install-all-behat,behat"/>
<target name="build-behat-mongo" depends="prepare,composer,activate-mongo,vendors,install-all-behat,behat"/>
<target name="build-code-quality" depends="prepare,lint,phploc,pdepend,phpmd-ci,php-cs-fixer,phpcpd,phpdoc"/>
<target name="prepare-deprecated-behat" description="Build deprecated behats">
<!--
In order to keep old import behats with deprecated processor, writer, and reader, we delete
the new config file and replace this one with the old one, and we also delete the one in
connector bundle to avoid this one to be also called.
-->
<delete file="${basedir}/src/Pim/Bundle/ConnectorBundle/Resources/config/batch_jobs.yml" />
<delete file="${basedir}/src/Pim/Bundle/BaseConnectorBundle/Resources/config/batch_jobs.yml" />
<copy file="${basedir}/features/Context/fixtures/base_connector_deprecated_batch_jobs.yml" tofile="${basedir}/src/Pim/Bundle/BaseConnectorBundle/Resources/config/batch_jobs.yml" />
<copy file="${basedir}/features/Context/fixtures/connector_deprecated_batch_jobs.yml" tofile="${basedir}/src/Pim/Bundle/ConnectorBundle/Resources/config/batch_jobs.yml" />
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/app/build/api"/>
<delete dir="${basedir}/app/build/code-browser"/>
<delete dir="${basedir}/app/build/coverage"/>
<delete dir="${basedir}/app/build/coverage-parts"/>
<delete dir="${basedir}/app/build/logs"/>
<delete dir="${basedir}/app/build/pdepend"/>
<delete file="${basedir}/composer.phar" />
<delete file="${basedir}/app/config/parameters.yml" />
<delete file="${basedir}/app/config/parameters_test.yml" />
<delete dir="${basedir}/app/cache" />
</target>
<target name="prepare" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/app/build/api"/>
<mkdir dir="${basedir}/app/build/code-browser"/>
<mkdir dir="${basedir}/app/build/coverage"/>
<mkdir dir="${basedir}/app/build/coverage-parts"/>
<mkdir dir="${basedir}/app/build/logs"/>
<mkdir dir="${basedir}/app/build/logs/phpunit"/>
<mkdir dir="${basedir}/app/build/logs/phpspec"/>
<mkdir dir="${basedir}/app/build/logs/behat"/>
<mkdir dir="${basedir}/app/build/logs/phpdoc"/>
<mkdir dir="${basedir}/app/build/pdepend"/>
<mkdir dir="${basedir}/app/build/phpdox"/>
<mkdir dir="${basedir}/app/cache" />
<!--
We still need a parameters.yml otherwise composer will create it without comments,
thus raising a "You have requested a non-existent parameter "mongodb_database"." error.
-->
<copy file="${basedir}/app/config/parameters.yml.dist" tofile="${basedir}/app/config/parameters.yml" />
<copy file="${basedir}/app/config/parameters.yml.dist" tofile="${basedir}/app/config/parameters_test.yml" />
<replaceregexp match="database_name:.*$" replace="database_name: %database.name%" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="parameters*.yml" />
</fileset>
</replaceregexp>
<replaceregexp match="database_user:.*$" replace="database_user: %database.user%" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="parameters*.yml" />
</fileset>
</replaceregexp>
<replaceregexp match="database_password:.*$" replace="database_password: %database.password%" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="parameters*.yml" />
</fileset>
</replaceregexp>
<replaceregexp match="catalog_storage_dir:.*$" replace="catalog_storage_dir: %kernel.root_dir%/file_storage/%catalog.storage.dir%" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="pim_parameters.yml" />
</fileset>
</replaceregexp>
<replaceregexp match="installer_data:.*$" replace="installer_data: PimInstallerBundle:minimal" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="pim_parameters.yml" />
</fileset>
</replaceregexp>
<copy file="${basedir}/behat.yml.dist" tofile="${basedir}/behat.yml" overwrite="true"/>
<replaceregexp match="pim-behat" replace="${behat.base_url}" byline="true">
<fileset dir="${basedir}">
<include name="behat.yml" />
</fileset>
</replaceregexp>
<replaceregexp match="tags: .*$" replace="tags: ${behat.tags}" byline="true">
<fileset dir="${basedir}">
<include name="behat.yml" />
</fileset>
</replaceregexp>
<condition property="hasBuildTags">
<and>
<isset property="buildTags" />
<length string="${buildTags}" trim="true" when="greater" length="0"/>
</and>
</condition>
<replaceregexp match="tags: (.*)$" replace="tags: \1&&${buildTags}" byline="true">
<fileset dir="${basedir}">
<include name="behat.yml" if="hasBuildTags" />
</fileset>
</replaceregexp>
<copy file="${basedir}/phpdoc.xml.dist" tofile="${basedir}/phpdoc.xml" />
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
</fileset>
</apply>
</target>
<target name="check-interfaces" description="Check if the interfaces are being used">
<exec executable="${basedir}/app/Resources/jenkins/interface_check.sh" failonerror="true">
<arg value="${basedir}/src" />
</exec>
<exec executable="${basedir}/app/Resources/jenkins/interface_check.sh" failonerror="false">
<arg value="${basedir}/spec" />
</exec>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/app/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}/app/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/app/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/app/build/pdepend/overview-pyramid.svg" />
<arg value="--ignore=Tests" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpmd" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${basedir}/app/Resources/jenkins/phpmd_akeneo">
<arg path="${basedir}/src,${basedir}/features" />
<arg value="text" />
</exec>
</target>
<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="${basedir}/app/Resources/jenkins/phpmd_akeneo">
<arg path="${basedir}/src" />
<arg value="xml" />
<arg value="--reportfile" />
<arg value="${basedir}/app/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${basedir}/bin/phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg path="${basedir}/src" />
<arg path="${basedir}/features" />
</exec>
</target>
<target name="php-cs-fixer" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="bash">
<arg value="-c"/>
<arg value="curl http://get.sensiolabs.org/php-cs-fixer.phar -o ${basedir}/bin/php-cs-fixer"/>
</exec>
<exec executable="bash">
<arg value="-c"/>
<arg value="chmod a+x ${basedir}/bin/php-cs-fixer"/>
</exec>
<exec executable="${basedir}/bin/php-cs-fixer" failonerror="true">
<arg value="fix" />
<arg path="${basedir}/src" />
<arg value="-v" />
<arg value="--config-file=${basedir}/.php_cs.local.php" />
<arg value="--dry-run" />
</exec>
</target>
<target name="phpdoc" description="Check php documentation">
<exec executable="phpdoc">
<arg line="--directory ${basedir}/src" />
<arg line="--target ${basedir}/build/api" />
<arg line="--template checkstyle" />
</exec>
</target>
<target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/app/build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg path="${basedir}/src" />
<arg path="${basedir}/features" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--exclude" />
<arg value="Tests" />
<arg value="--log-pmd" />
<arg value="${basedir}/app/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpdox" description="Generate API documentation using phpDox">
<exec executable="phpdox">
<arg value="-f" />
<arg path="${basedir}/app/Resources/jenkins/phpdox.xml" />
</exec>
</target>
<target name="coverage" description="Run unit tests with PHPUnit and generate coverage">
<exec executable="sh" outputproperty="xdebug_path">
<arg value="-c" />
<arg value="php -i | grep extension_dir | cut -d ' ' -f3"/>
</exec>
<exec executable="${basedir}/composer.phar" failonerror="true">
<arg value="require" />
<arg value="--no-update" />
<arg value="henrikbjorn/phpspec-code-coverage" />
<arg value="3.0.*@dev" />
</exec>
<replace
file="${basedir}/phpspec.yml.dist"
token="suites:"
failOnNoReplacements="true"
>
<replacevalue><![CDATA[formatter.name: dot
extensions:
Akeneo\SkipExampleExtension: ~
PhpSpecCodeCoverage\CodeCoverageExtension: ~
code_coverage:
format: php
output: app/build/coverage-parts/phpspec.php
suites:]]></replacevalue>
</replace>
<!--
As long as composer does not provide an option to ignore platform dependency,
it must be executed with the xdebug extension activated
-->
<exec executable="php" failonerror="true">
<arg value="-d zend_extension=${xdebug_path}/xdebug.so" />
<arg value="${basedir}/composer.phar" />
<arg value="install" />
<arg value="--no-progress" />
<arg value="--no-interaction" />
<arg value="--prefer-dist" />
<arg value="--optimize-autoloader" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
<exec executable="php">
<arg value="-d zend_extension=${xdebug_path}/xdebug.so" />
<arg value="${basedir}/bin/phpunit" />
<arg value="-c" />
<arg path="${basedir}/app/phpunit.jenkins-coverage.xml" />
<arg value="--testsuite=Jenkins_PIM_Test" />
</exec>
<exec executable="php">
<arg value="-d zend_extension=${xdebug_path}/xdebug.so" />
<arg value="${basedir}/bin/phpspec" />
<arg value="run" />
</exec>
<exec executable="php">
<arg value="-d zend_extension=${xdebug_path}/xdebug.so" />
<arg value="${basedir}/bin/merge-coverage" />
<arg value="${basedir}/app/build/coverage-parts/phpunit.php" />
<arg value="${basedir}/app/build/coverage-parts/phpspec.php" />
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="${basedir}/bin/phpunit">
<arg value="-c" />
<arg path="${basedir}/app/phpunit.jenkins.xml" />
<arg value="--testsuite=Jenkins_PIM_Test" />
</exec>
</target>
<target name="phpspec" description="Run specs with PhpSpec Dot formatter">
<exec executable="${basedir}/bin/phpspec">
<arg value="run" />
<arg value="-fdot" />
<arg value="--no-interaction" />
<arg value="--ansi" />
</exec>
</target>
<target name="phpspec-junit" description="Run specs with PhpSpec JUnit formatter">
<exec executable="${basedir}/bin/phpspec" output="app/build/logs/phpspec/junit.xml">
<arg value="run" />
<arg value="-fjunit" />
<arg value="--no-interaction" />
</exec>
</target>
<target name="link-pim-docs" description="Clone pim-docs repo and configure pim-dev to work with">
<exec executable="${basedir}/app/Resources/jenkins/pim-docs/link-pim-docs.sh" failonerror="true" />
</target>
<target name="behat" description="Run acceptance tests with Behat">
<exec executable="${basedir}/app/Resources/jenkins/behat/run_behat.sh" failonerror="true">
<arg value="-c" />
<arg value="${behat.concurrency}" />
<arg value="-x" />
<arg value="${behat.xdebug}" />
<arg value="-d" />
<arg value="${symfony.database.name}_" />
<arg value="-p" />
<arg value="${behat.profile.prefix}-" />
<arg value="-f"/>
<arg value="${behat.features} "/>
<arg value="-b"/>
<arg value="${basedir}/bin/behat ${behat.options}"/>
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
<env key="BEHAT_CONTEXT" value="JENKINS" />
</exec>
</target>
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${basedir}/app/build/logs" />
<arg value="--source" />
<arg path="${basedir}/src" />
<arg value="--output" />
<arg path="${basedir}/app/build/code-browser" />
</exec>
</target>
<target name="composer" description="Install composer.phar">
<exec executable="bash">
<arg value="-c"/>
<arg value="curl -sS https://getcomposer.org/installer | php"/>
</exec>
</target>
<target name="vendors" description="Install vendors">
<exec executable="${basedir}/composer.phar" failonerror="true">
<arg value="install" />
<arg value="--no-progress" />
<arg value="--no-interaction" />
<arg value="--prefer-dist" />
<arg value="--optimize-autoloader" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
</target>
<target name="vendors-no-scripts" description="Install vendors">
<exec executable="${basedir}/composer.phar" failonerror="true">
<arg value="install" />
<arg value="--no-progress" />
<arg value="--no-interaction" />
<arg value="--prefer-dist" />
<arg value="--optimize-autoloader" />
<arg value="--no-scripts" />
</exec>
</target>
<target name="activate-mongo" description="Activate the mongo bundle">
<replace
file="${basedir}/app/AppKernel.php"
token="// new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle()"
value="new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle()"
failOnNoReplacements="true"
/>
<replaceregexp match="# mongodb" replace="mongodb" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="pim_parameters*" />
</fileset>
</replaceregexp>
<replaceregexp match="mongodb_database:.*$" replace="mongodb_database: %mongodb.database%" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="pim_parameters*" />
</fileset>
</replaceregexp>
<replaceregexp match="pim_catalog_product_storage_driver: doctrine/orm" replace="pim_catalog_product_storage_driver: doctrine/mongodb-odm" byline="true">
<fileset dir="${basedir}/app/config/">
<include name="pim_parameters*" />
</fileset>
</replaceregexp>
</target>
<target name="setupdb" description="Setup db">
<exec executable="app/console" failonerror="true">
<arg value="pim:install" />
<arg value="--force" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
</target>
<target name="setupdb-test" description="Setup db for test env">
<exec executable="app/console" failonerror="true">
<arg value="pim:install" />
<arg value="--env=test" />
<arg value="--force" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
</target>
<target name="install-all-behat" description="Setup db and install assets for Behat">
<exec executable="app/console" failonerror="true">
<arg value="pim:install" />
<arg value="--env=behat" />
<arg value="--force" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
</target>
<target name="fixtures" description="Load fixtures">
<exec executable="app/console">
<arg value="doctrine:fixtures:load" />
<arg value="--no-interaction" />
<env key="SYMFONY__DATABASE__NAME" value="${symfony.database.name}" />
<env key="SYMFONY__DATABASE__USER" value="${symfony.database.user}" />
<env key="SYMFONY__DATABASE__PASSWORD" value="${symfony.database.password}" />
<env key="SYMFONY__MONGODB__DATABASE" value="${symfony.mongodb.database}" />
<env key="SYMFONY__CATALOG__STORAGE__DIR" value="${symfony.catalog.storage.dir}" />
</exec>
</target>
</project>