-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
282 lines (247 loc) · 11.1 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
<?xml version="1.0" encoding="UTF-8" ?>
<project name="lazzier" default="help">
<!-- ================================================================= -->
<!-- Basic ANT build script boilerplate for PHP projects -->
<!-- intended to be run in a CI environment -->
<!-- ================================================================= -->
<!-- Base properties -->
<property name="rootDir" value="./"/>
<property name="buildDir" value="${rootDir}/build"/>
<property name="appDir" value="${rootDir}/app"/>
<property name="toolsDir" value="${rootDir}/vendor/bin"/>
<property name="outputDir" value="${buildDir}/logs"/>
<!-- DOCs -->
<property name="docsDir" value="${buildDir}/api"/>
<property name="docsTitle" value="Lazzier Documentation"/>
<property name="withDocs" value="false"/>
<!-- Environment, Target, Version etc. -->
<property name="environment" value="dev"/>
<property name="release" value="1.0.0"/>
<property environment="env"/>
<condition property="version"
value="v${release}.${env.BUILD_NUMBER}"
else="v${release}.${environment}">
<isset property="env.BUILD_NUMBER"/>
</condition>
<condition property="gitBranch"
value="${env.BRANCH_NAME}"
else="develop">
<isset property="env.BRANCH_NAME"/>
</condition>
<property name="workingBranch" value="${workingBranch}">
<filterchain>
<replaceregexp>
<regexp pattern="\/" replace="_" ignoreCase="true"/>
</replaceregexp>
</filterchain>
</property>
<condition property="artifactName"
value="${ant.project.name}"
else="${workingBranch}">
<equals arg1="master" arg2="${gitBranch}"/>
</condition>
<condition property="isProduction" else="false">
<equals arg1="${environment}" arg2="prod" />
</condition>
<condition property="isUnix">
<os family="unix"/>
</condition>
<property name="deployment" value="${artifactName}_${version}"/>
<!-- Phing extensions -->
<property name="ext.phing_tasks" value="/home/jenkins/phing-extensions/"/>
<includepath classpath="${ext.phing_tasks}" />
<taskdef name="propertyfile" classname="PropertyFileTask" />
<!-- ============================================ -->
<!-- Target: help. short description.... -->
<!-- ============================================ -->
<target name="help">
<echo message="${line.separator}
----------------------------- ${line.separator}
List of useful build targets ${line.separator}
----------------------------- ${line.separator}
${line.separator}
* install run this after first git checkout ${line.separator}
- installs composer packages ${line.separator}
${line.separator}
* test run all tests ${line.separator}
- run this before you consider your task done ${line.separator}
* lint run static code analysis ${line.separator}
- run this to check systax errors ${line.separator}
* build deploy application to a given environment ${line.separator}
- run this to deploy dev and stating manually ${line.separator}
* deploy deploy application to a given environment ${line.separator}
- run this to deploy dev and stating manually ${line.separator}
${line.separator}" />
</target>
<!-- ============================================ -->
<!-- Target: generate BuildInfo -->
<!-- ============================================ -->
<target name="buildinfo">
<tstamp>
<format property="builtAt" pattern="dd-MM-yyyy HH:mm" timezone="Europe/Berlin"/>
</tstamp>
<exec executable="uname" outputproperty="buildsystem"><arg value="-a"/></exec>
<propertyfile file="${rootDir}version.properties"
comment="This file is automatically generated - DO NOT EDIT">
<entry key="buildtime" value="${builtAt}"/>
<entry key="version" value="${version}"/>
<entry key="build" value="${env.BUILD_NUMBER}"/>
<entry key="git_branch" value="${gitBranch}"/>
<entry key="deployment" value="${deployment}"/>
<entry key="builder" value="${user.name}"/>
<entry key="system" value="${buildsystem}"/>
</propertyfile>
</target>
<!-- ============================================ -->
<!-- Target: install. basic installation -->
<!-- ============================================ -->
<target name="install"
depends="install.dependencies"
description=""/>
<target name="install.dependencies"
depends=""
description="Run composer">
<exec executable="php" checkreturn="true">
<arg value="${toolsDir}/composer.phar" />
<arg value="install" />
<arg value="--no-progress" />
<arg value="--optimize-autoloader" />
<arg value="--working-dir=${rootDir}" />
</exec>
</target>
<!-- CLEAN -->
<target name="clean"
unless="clean.done"
description="Cleanup build artifacts">
<delete dir="${buildDir}" quiet='true' />
<delete dir="${outputDir}" quiet='true' />
<property name="clean.done" value="true"/>
</target>
<!-- PREPARE -->
<target name="prepare"
unless="prepare.done"
depends="clean"
description="Prepare for build">
<mkdir dir="${buildDir}/dist"/>
<mkdir dir="${outputDir}"/>
<mkdir dir="${buildDir}/pdepend"/>
<property name="prepare.done" value="true"/>
</target>
<!-- ============================================ -->
<!-- Target: lint . static code analysis. -->
<!-- ============================================ -->
<target name="lint"
description="Run all tools for static-code analysis">
<parallel threadCount="2">
<phingcall target="securitycheck"/>
<phingcall target="phploc"/>
<phingcall target="phpmd"/>
<phingcall target="pdepend"/>
<phingcall target="phpcs"/>
<phingcall target="phpcpd"/>
</parallel>
</target>
<target name="securitycheck"
description="Checks if your application uses dependencies with known security vulnerabilities.">
<exec executable="${toolsDir}/security-checker" output="${outputDir}/securitycheck.log">
<arg value="security:check" />
<arg value="${rootDir}/composer.lock" />
</exec>
</target>
<target name="phploc"
description="Measure project size using PHPLOC and print human readable output.">
<exec executable="${toolsDir}/phploc">
<arg value="--count-tests"/>
<arg value="--log-csv"/>
<arg path="${outputDir}/phploc.csv"/>
<arg value="--log-xml"/>
<arg path="${outputDir}/phploc.xml"/>
<arg path="${appDir}"/>
<arg path="${rootDir}/tests"/>
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD and log result in XML format.">
<exec executable="${toolsDir}/phpmd">
<arg path="${appDir}"/>
<arg value="xml" />
<arg path="${rootDir}/../phpmd.xml" />
<arg value="--reportfile" />
<arg path="${outputDir}/pmd.xml" />
</exec>
</target>
<target name="pdepend"
description="Calculate software metrics using PHP_Depend and log result in XML format.">
<exec executable="${toolsDir}/pdepend">
<arg value="--jdepend-xml=${outputDir}/jdepend.xml" />
<arg value="--jdepend-chart=${buildDir}/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${buildDir}/pdepend/overview-pyramid.svg" />
<arg path="${appDir}" />
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format.">
<exec executable="${toolsDir}/phpcs">
<arg value="--report=checkstyle" />
<arg value="--report-file=${outputDir}/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=*.blade.php,*/Resources/*,*/vendor/*" />
<arg path="${appDir}" />
</exec>
</target>
<target name="phpcpd"
description="Find duplicate code using PHPCPD and log result in XML format.">
<exec executable="${toolsDir}/phpcpd">
<arg value="--log-pmd" />
<arg path="${outputDir}/pmd-cpd.xml" />
<arg path="${appDir}" />
</exec>
</target>
<!-- ============================================ -->
<!-- Target: intended for console. test it all -->
<!-- ============================================ -->
<!-- Run Unit Tests with Coverage through PHPUnit -->
<target name="test" description="Execute PHPUnit tests with coverage.">
<exec executable="${toolsDir}/phpunit">
<arg line="-c ${rootDir}/phpunit.xml"/>
<arg line="--coverage-html=${buildDir}/phpunit/"/>
<arg line="--coverage-clover=${outputDir}/phpunit-clover.xml"/>
<arg line="--log-junit ${outputDir}/phpunit.xml"/>
</exec>
</target>
<!-- ============================================ -->
<!-- Target: dist. Copy files for distribution. -->
<!-- ============================================ -->
<!-- ============================================ -->
<!-- Target: docs -->
<!-- ============================================ -->
<target name="docs"
if="${withDocs}"
depends="docs.prepare"
description="Generate API-docs">
<exec executable="${toolsDir}/phpdoc">
<arg line="--directory ${appDir}
--title '${docsTitle}'
--target ${docsDir}" />
</exec>
</target>
<target name="docs.prepare"
depends=""
description="Clean api-docs folder">
<mkdir dir="${docsDir}" />
<delete includeEmptyDirs="true">
<fileset dir="${docsDir}" includes="**/*"/>
</delete>
</target>
<!-- ============================================ -->
<!-- Target: build and deploy, tbd -->
<!-- ============================================ -->
<target name="build"
depends="install,prepare,lint,test,docs,buildinfo"
description="Build Lazzier CLI" />
<!--<target name="deploy"
depends="buildinfo,dist"
description="Deploy application $targetapp} to environment ${environment}">
</target>-->
</project>