-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
155 lines (141 loc) · 6.24 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="vufind-marc" basedir="." default="main">
<property name="sh" value="/bin/sh" />
<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" />
<!-- 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="phpmd"/>
<phingcall target="pdepend"/>
<phingcall target="phpstan-checkstyle"/>
</target>
<!-- Report rule violations with PHPMD (mess detector) -->
<target name="phpmd">
<exec executable="${srcdir}/vendor/bin/phpmd">
<arg line="${srcdir}/src xml ${srcdir}/tests/phpmd.xml --exclude ${srcdir}/tests --reportfile ${builddir}/reports/phpmd.xml" />
</exec>
</target>
<!-- PHP_Depend code analysis -->
<target name="pdepend">
<exec executable="${srcdir}/vendor/bin/pdepend">
<arg line="--jdepend-xml=${builddir}/reports/jdepend.xml --jdepend-chart=${builddir}/reports/dependencies.svg --overview-pyramid=${builddir}/reports/pdepend-pyramid.svg ${srcdir}/src" />
</exec>
</target>
<!-- PHP CodeSniffer -->
<target name="phpcbf">
<exec executable="${srcdir}/vendor/bin/phpcbf" escape="false" passthru="true" checkreturn="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>
<target name="phpcs">
<exec executable="${srcdir}/vendor/bin/phpcs">
<arg line="--standard=${srcdir}/tests/phpcs.xml --report=checkstyle > ${builddir}/reports/checkstyle.xml" escape="false" />
</exec>
</target>
<target name="phpcs-console">
<exec executable="${srcdir}/vendor/bin/phpcs" escape="false" passthru="true" checkreturn="true">
<arg line="--standard=${srcdir}/tests/phpcs.xml" />
</exec>
</target>
<!-- Phpstan -->
<target name="phpstan-checkstyle">
<exec executable="${srcdir}/vendor/bin/phpstan" escape="false" passthru="true" checkreturn="true">
<arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G --error-format=checkstyle analyse > ${builddir}/reports/phpstan-checkstyle.xml" />
</exec>
</target>
<target name="phpstan-console">
<exec executable="${srcdir}/vendor/bin/phpstan" escape="false" passthru="true" checkreturn="true">
<arg line="--configuration=${srcdir}/tests/phpstan.neon --memory-limit=2G analyse" />
</exec>
</target>
<!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) -->
<target name="php-cs-fixer">
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false">
<arg line="fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --verbose" />
</exec>
</target>
<target name="php-cs-fixer-dryrun">
<exec executable="${srcdir}/vendor/bin/php-cs-fixer" passthru="true" escape="false" checkreturn="true">
<arg line="fix --config=${srcdir}/tests/vufind.php-cs-fixer.php --dry-run --verbose --diff" />
</exec>
</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 executable="php ${srcdir}/vendor/bin/phpDocumentor-${phpdoc_version}.phar" passthru="true">
<arg line="--cache-folder=${builddir}/docs_cache --title="VuFind-Marc API Documentation" -t ${builddir}/apidocs -d ${srcdir}/src" />
</exec>
</then>
</if>
</target>
<!-- PHPUnit -->
<target name="phpunit" description="Run tests">
<exec dir="${srcdir}/tests" executable="${sh}" passthru="true" checkreturn="true">
<arg line="-c '${phpunit_command} --log-junit ${builddir}/reports/phpunit.xml --coverage-clover ${builddir}/reports/coverage/clover.xml --coverage-html ${builddir}/reports/coverage/'" />
</exec>
</target>
<!-- PHPUnit without logging output -->
<target name="phpunitfast" description="Run tests">
<exec dir="${srcdir}/tests" executable="${sh}" passthru="true" checkreturn="true">
<arg line="-c '${phpunit_command} '" />
</exec>
</target>
<!-- Set up dependencies -->
<target name="startup" description="set up dependencies">
<exec executable="composer">
<arg line="install" />
</exec>
</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 executable="git">
<arg line="reset --hard" />
</exec>
</target>
</project>