-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
200 lines (165 loc) · 7.48 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of g7mzr/db module.
*
* (c) Sandy McNeil <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-->
<project name="g7mzr/db" default="build" basedir="." description="Phing Buildfile.">
<!-- Set up default directories -->
<property name="basedir" value="${project.basedir}" />
<property name="toolsdir" value="${basedir}/vendor/bin/"/>
<property name="builddir" value="${basedir}/build/"/>
<!-- The default location for the composer phar -->
<property name="composer" value="${basedir}/build/composer.phar"/>
<!-- ================================================================== -->
<!-- Targets to Setup the Build Tools -->
<!-- ================================================================== -->
<target name="php-check">
<condition property="php" value="php">
<not>
<isset property="${php}"/>
</not>
</condition>
</target>
<target name="composer-check">
<available file="${composer}" property="composer.present"/>
</target>
<target name="composer-download"
depends="composer-check"
unless="composer.present">
<property name="composer.noselfupdate" value="true"/>
<exec executable="wget" dir="${builddir}" passthru="true" logoutput="true">
<arg line="https://getcomposer.org/composer.phar" />
</exec>
</target>
<target name="composer-selfupdate"
depends="php-check,composer-download"
unless="composer.noselfupdate">
<exec executable="${php}">
<arg value="${composer}"/>
<arg value="self-update"/>
<arg value="--quiet"/>
</exec>
</target>
<!-- Install or Update the Dependancies -->
<target name="composer-install"
depends="composer-selfupdate"
description="Installing composer dependencies">
<exec executable="php" passthru="true" logoutput="true">
<arg value="${composer}" />
<arg value="install" />
<arg value="--prefer-dist" />
<arg value="--no-progress" />
</exec>
</target>
<target name="composer-update"
depends="composer-selfupdate"
description="Manual update composer dependencies">
<exec executable="php" passthru="true" logoutput="true">
<arg value="${composer}" />
<arg value="update" />
<arg value="--prefer-dist" />
<arg value="--no-progress" />
</exec>
</target>
<!-- ================================================================== -->
<!-- Targets used to CLEAN the BUILD ENVIRONMENT -->
<!-- ================================================================== -->
<target name="clean-artifacts">
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<!--<delete dir="${basedir}/vendor"/> -->
</target>
<!-- ================================================================== -->
<!-- Targets used to PREPARE the BUILD ENVIRONMENT -->
<!-- ================================================================== -->
<target name="db-update">
<exec executable="php" dir="${basedir}" logoutput="true" checkreturn="true">
<arg line="bin/dbconfig.php" />
</exec>
</target>
<target name="prepare-build"
unless="prepare.done"
depends="composer-install, clean, db-update"
description="Prepare for build">
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<property name="prepare.done" value="true"/>
</target>
<!-- ================================================================== -->
<!-- Code Analysis Targets -->
<!-- ================================================================== -->
<!-- === MANUAL TARGETS === -->
<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 passthru="true" logoutput="true" executable="${toolsdir}phpcs">
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php " />
<arg path="${basedir}" />
</exec>
</target>
<target name="phpcbf"
description="Fix coding standard violations using PHP_CodeSniffer.">
<exec executable="${toolsdir}phpcbf" passthru="true" logoutput="true">
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}" />
</exec>
</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>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
</fileset>
</apply>
</target>
<!-- === CI TARGETS === -->
<target name="phpcs-ci"
depends="prepare"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}" />
</exec>
</target>
<!-- ================================================================== -->
<!-- Unit Testing Targets -->
<!-- ================================================================== -->
<target name="unit"
depends="prepare"
description="Run unit tests with PHPUnit">
<exec executable="${toolsdir}phpunit" checkreturn="true" passthru="true" logoutput="true">
<arg value="--configuration"/>
<arg path="${basedir}/build/phpunit.xml"/>
<arg value="--testsuite" />
<arg value="unit" />
<arg value="--bootstrap" />
<arg value="vendor/autoload.php" />
</exec>
</target>
<!-- ================================================================== -->
<!-- Build Targets -->
<!-- ================================================================== -->
<target name="clean"
depends="composer-install, clean-artifacts"/>
<target name="prepare"
depends=" clean, db-update, prepare-build"/>
<target name="unit-test"
depends="prepare, unit"/>
<target name="code-style" depends="phpcs-ci"/>
<!-- Default Build Target -->
<target name="build"
depends="clean, prepare, lint, unit-test, code-style"/>
</project>