-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
138 lines (122 loc) · 6.27 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="vufind-marc" basedir="." default="main">
<property name="tmp" value="/tmp" />
<property name="package" value="${phing.project.name}" override="true" />
<property name="builddir" value="${tmp}/build/${phing.project.name}" override="true" />
<property name="srcdir" value="${project.basedir}" override="true" />
<property name="skip_phpdoc" value="false" />
<property name="phpdoc_version" value="3.3.1" />
<property name="phpunit_command" value="${srcdir}/vendor/bin/phpunit" /><!-- if you have issues with segfaults during code coverage generation, try adding -dzend.enable_gc=0 to this (but this fix was probably only needed in PHP 5) -->
<!-- Main Target -->
<target name="main" description="main target">
<trycatch property="exceptionmsg">
<try>
<phingcall target="startup" />
<phingcall target="ci-tasks" />
<phingcall target="shutdown" />
</try>
<catch>
<phingcall target="shutdown" />
<fail>Unexpected error during continuous integration tasks -- ${exceptionmsg}</fail>
</catch>
</trycatch>
</target>
<!-- Continuous Integration Tasks -->
<target name="ci-tasks" description="continuous integration tasks">
<!-- Create dirs -->
<mkdir dir="${builddir}/reports"/>
<mkdir dir="${builddir}/reports/coverage"/>
<!-- Call standard tasks -->
<phingcall target="phpcs"/>
<phingcall target="phpunit"/>
<phingcall target="phpdoc"/>
<phingcall target="phpcpd"/>
<phingcall target="phpmd"/>
<phingcall target="pdepend"/>
<phingcall target="phploc"/>
<phingcall target="phpstan-checkstyle"/>
</target>
<!-- Report rule violations with PHPMD (mess detector) -->
<target name="phpmd">
<exec command="${srcdir}/vendor/bin/phpmd ${srcdir}/src xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/tests --reportfile ${builddir}/reports/phpmd.xml" />
</target>
<!-- Measure project with phploc -->
<target name="phploc">
<exec command="${srcdir}/vendor/bin/phploc --log-csv ${builddir}/reports/phploc.csv ${srcdir}/src" />
</target>
<!-- PHP_Depend code analysis -->
<target name="pdepend">
<exec command="${srcdir}/vendor/bin/pdepend --jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/src" />
</target>
<!-- PHP copy-and-paste detection -->
<target name="phpcpd">
<exec command="${srcdir}/vendor/bin/phpcpd --log-pmd ${builddir}/reports/pmd-cpd.xml --exclude tests ${srcdir}/src" />
</target>
<!-- PHP CodeSniffer -->
<target name="phpcbf">
<exec command="${srcdir}/vendor/bin/phpcbf --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
</target>
<target name="phpcs">
<exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml --report=checkstyle > ${builddir}/reports/checkstyle.xml" escape="false" />
</target>
<target name="phpcs-console">
<exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" />
</target>
<!-- Phpstan -->
<target name="phpstan-checkstyle">
<exec command="${srcdir}/vendor/bin/phpstan --configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G --error-format=checkstyle analyse > ${builddir}/reports/phpstan-checkstyle.xml" escape="false" passthru="true" checkreturn="true" />
</target>
<target name="phpstan-console">
<exec command="${srcdir}/vendor/bin/phpstan --configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" escape="false" passthru="true" checkreturn="true" />
</target>
<!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
<target name="php-cs-fixer">
<exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --verbose" passthru="true" escape="false" />
</target>
<target name="php-cs-fixer-dryrun">
<exec command="${srcdir}/vendor/bin/php-cs-fixer fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --dry-run --verbose --diff" passthru="true" escape="false" checkreturn="true" />
</target>
<!-- PHP API Documentation -->
<target name="phpdoc">
<!-- GET phpDocumentor.phar -->
<if>
<not><available file="${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar" /></not>
<then>
<httpget followRedirects="true" url="https://github.com/phpDocumentor/phpDocumentor2/releases/download/v${phpdoc_version}/phpDocumentor.phar" dir="${srcdir}/vendor/bin" filename="phpDocumentor-${phpdoc_version}.phar" />
<chmod mode="0755">
<fileset dir="${srcdir}/vendor/bin">
<include name="phpDocumentor-${phpdoc_version}.phar" />
</fileset>
</chmod>
</then>
</if>
<!-- Run phpdoc -->
<!-- Skip the whole phpdoc task when disabled -->
<if>
<not><istrue value="${skip_phpdoc}" /></not>
<then>
<mkdir dir="${builddir}/apidocs" />
<mkdir dir="${builddir}/docs_cache" />
<exec command="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar --cache-folder=${builddir}/docs_cache --title="VuFind-Marc API Documentation" -t ${builddir}/apidocs -d ${srcdir}/src" passthru="true" />
</then>
</if>
</target>
<!-- PHPUnit -->
<target name="phpunit" description="Run tests">
<exec dir="${srcdir}/tests" command="${phpunit_command} --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/" passthru="true" checkreturn="true" />
</target>
<!-- PHPUnit without logging output -->
<target name="phpunitfast" description="Run tests">
<exec dir="${srcdir}/tests" command="${phpunit_command}" passthru="true" checkreturn="true" />
</target>
<!-- Set up dependencies -->
<target name="startup" description="set up dependencies">
<exec command="composer install" />
</target>
<!-- Clean up -->
<target name="shutdown" description="clean up file system">
<delete dir="${srcdir}/vendor" includeemptydirs="true" failonerror="true" />
<delete file="${srcdir}/composer.lock" failonerror="true" />
<exec command="git reset --hard" />
</target>
</project>