-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommon.xml
More file actions
488 lines (441 loc) · 26 KB
/
common.xml
File metadata and controls
488 lines (441 loc) · 26 KB
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
477
478
479
480
481
482
483
484
485
486
487
488
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="appserver-io-dist/package" basedir="." default="build">
<!-- Readin enviroment properties to env property -->
<property environment="env" />
<!-- Generate a timestamp to time.stamp property -->
<tstamp>
<format property="time.stamp" pattern="yyyy.MM.dd.HHmmss"/>
</tstamp>
<!-- get the absolute path of this file for resource import -->
<dirname property="package.basedir" file="${ant.file.appserver-io-dist/package}"/>
<!-- Read in tests property files -->
<property file="${package.basedir}/common.properties"/>
<property file="${package.basedir}/common.default.properties"/>
<!-- Set directory properties -->
<property name="src.dir" value="${basedir}/src" />
<property name="target.dir" value="${basedir}/target" />
<property name="build.dir" value="${basedir}/build" />
<property name="tests.dir" value="${basedir}/tests" />
<property name="temp.dir" value="${basedir}/tmp" />
<property name="reports.dir" value="${basedir}/reports" />
<!-- initialize the library specific properties -->
<property name="codepool" value="vendor"/>
<!-- ==================================================================== -->
<!-- Import the tests/*.xml files -->
<!-- ==================================================================== -->
<import file="${package.basedir}/tests/test.xml"/>
<!-- ==================================================================== -->
<!-- Cleans the target directories -->
<!-- ==================================================================== -->
<target name="clean">
<delete dir="${target.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
<delete dir="${temp.dir}" includeemptydirs="true" quiet="false" verbose="false" failonerror="true"/>
</target>
<!-- ==================================================================== -->
<!-- Prepares the target dir -->
<!-- ==================================================================== -->
<target name="prepare" depends="clean">
<mkdir dir="${target.dir}" />
<mkdir dir="${temp.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Cleans the build directories -->
<!-- ==================================================================== -->
<target name="clean-build" depends="prepare-build">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${build.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Cleans the reports directories -->
<!-- ==================================================================== -->
<target name="clean-reports" depends="prepare-reports">
<delete includeemptydirs="true" quiet="false" verbose="false" failonerror="true">
<fileset dir="${reports.dir}" includes="**/*"/>
</delete>
</target>
<!-- ==================================================================== -->
<!-- Prepares the reports environment -->
<!-- ==================================================================== -->
<target name="prepare-reports">
<mkdir dir="${reports.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the build environment -->
<!-- ==================================================================== -->
<target name="prepare-build">
<mkdir dir="${build.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Prepares the temp environment -->
<!-- ==================================================================== -->
<target name="prepare-temp">
<mkdir dir="${temp.dir}" />
</target>
<!-- ==================================================================== -->
<!-- Will check if a download of the appserver src is needed -->
<!-- ==================================================================== -->
<target name="check-appserver-src-needed">
<!-- check if the appserver source is already present -->
<available file="${temp.dir}/appserver-src/.git" type="dir" property="appserver.src.unneeded"/>
</target>
<!-- ==================================================================== -->
<!-- Will download the appserver src unless it is not needed -->
<!-- ==================================================================== -->
<target name="get-appserver-src" depends="prepare-temp, check-appserver-src-needed" unless="appserver.src.unneeded">
<!-- clone appserver src -->
<exec dir="${temp.dir}" executable="git">
<arg line="clone https://github.com/${appserver.src.repo} appserver-src" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will provide the appserver.src.version property if not defined -->
<!-- already -->
<!-- ==================================================================== -->
<target name="get-appserver-src-version" depends="get-appserver-src">
<!-- get lastest tag version -->
<exec dir="${temp.dir}/appserver-src" executable="git" outputProperty="appserver.src.version">
<arg line="describe --abbrev=0 --tags" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will split the github tag into a semver version (e.g. 1.0.0) and a -->
<!-- suffix (e.g. beta) -->
<!-- ==================================================================== -->
<target name="prepare-src-version-parts" depends="get-appserver-src-version">
<!-- filter the version string -->
<filter-version param="${appserver.src.version}" />
<property name="appserver.src.semver" value="${RESULT_VERSION}" />
<condition property="appserver.src.suffix" value=".${RESULT_BUILD-NUMBER}">
<not>
<equals arg1="${RESULT_BUILD-NUMBER}" arg2="" />
</not>
</condition>
<property name="appserver.src.suffix" value="${RESULT_BUILD-NUMBER}" />
</target>
<!-- ==================================================================== -->
<!-- Checks if composer has installed it's dependencies -->
<!-- ==================================================================== -->
<target name="is-composer-installed">
<condition property="composer.present">
<available file="${build.dir}" type="dir"/>
</condition>
</target>
<!-- ==================================================================== -->
<!-- Installs all dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-install" depends="is-composer-installed" unless="composer.present" description="Installs all dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev install"/>
</exec>
</target>
<!-- ==================================================================== -->
<!-- Updates composer dependencies defined in composer.json -->
<!-- ==================================================================== -->
<target name="composer-update" depends="is-composer-installed" if="composer.present" description="Updates composer dependencies defined in composer.json">
<exec dir="${basedir}" executable="composer">
<arg line="--no-interaction --dev update"/>
</exec>
</target>
<!-- ===================================================================== -->
<!-- Checks if the build- and deployment stub has already been initialized -->
<!-- ===================================================================== -->
<target name="composer-init">
<antcall target="composer-install"/>
<antcall target="composer-update"/>
</target>
<!-- ==================================================================== -->
<!-- Installs composer in target directory -->
<!-- ==================================================================== -->
<target name="install-composer">
<get src="http://getcomposer.org/installer" dest="${temp.dir}/composer-installer" />
<exec dir="${temp.dir}" executable="php">
<arg value="composer-installer" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will test if the targeted box is already up and running. -->
<!-- Will set the properties "vagrant-box.running" or -->
<!-- "vagrant-box.not-running" depending on the result -->
<!-- ==================================================================== -->
<target name="test-vagrant-box-running">
<!-- issue the actual command -->
<exec dir="${temp.dir}" executable="vagrant" outputproperty="vagrant-box.status">
<arg value="status" />
</exec>
<parse-vagrant-box-status status="${vagrant-box.status}" boxname="${vagrant-box.name}" />
<condition property="vagrant-box.not-running">
<isset property="BOX_NOT_RUNNING"/>
</condition>
<condition property="vagrant-box.running">
<isset property="BOX_RUNNING"/>
</condition>
</target>
<!-- ==================================================================== -->
<!-- Will parse a vagrant box status to look for the "running" state. -->
<!-- Will set BOX_RUNNING if found, BOX_NOT_RUNNING if otherwise -->
<!-- ==================================================================== -->
<scriptdef name="parse-vagrant-box-status" language="javascript">
<attribute name="status"/>
<attribute name="boxname"/>
<![CDATA[
// getting the params
var status = attributes.get("status");
var boxName = attributes.get("boxname");
// check the occurence of a certain run indicator
if (status.indexOf(boxName + " running") > -1) {
project.setProperty("BOX_RUNNING", true);
} else {
project.setProperty("BOX_NOT_RUNNING", true);
}
]]>
</scriptdef>
<!-- ==================================================================== -->
<!-- Will start a vagrant box within the tmp directory -->
<!-- ==================================================================== -->
<target name="start-vagrant-box" depends="test-vagrant-box-running" if="vagrant-box.not-running">
<!-- tell the user we need the box name first -->
<fail unless="vagrant-box.name" message="Please specify the type of box to start e.g. using 'ant start-vagrant-build-box'" />
<!-- issue the actual start command -->
<exec dir="${temp.dir}" executable="vagrant" errorproperty="vagrant-box.start.failed">
<arg line="up ${vagrant-box.name} --provider=${vagrant.provider} --destroy-on-error" />
</exec>
<!-- eliminate the possiblity of empty but existing error output -->
<property name="vagrant-box.start.failed" value=""/>
<condition property="fatal-error.occured" value="${vagrant-box.start.failed}">
<not>
<equals arg1="${vagrant-box.start.failed}" arg2=""/>
</not>
</condition>
<!-- check for a specific build failure and make an emergency destroy -->
<antcall target="destroy-vagrant-box-on-error" />
<!-- tell them about any failures we might encountered -->
<fail if="fatal-error.occured" message="Starting the vagrant box failed! Error message was: '${fatal-error.occured}', also see log above." />
</target>
<!-- ==================================================================== -->
<!-- Will start a vagrant box specifically suited for build tasks -->
<!-- ==================================================================== -->
<target name="start-vagrant-build-box">
<!-- map the vagrant name according to our prepared environment -->
<property name="vagrant-box.name" value="${vagrant-box.prefix}Build" />
<!-- prepare the building environment -->
<antcall target="prepare-build-environment" />
<!-- start our vagrant box -->
<antcall target="start-vagrant-box" />
</target>
<!-- ==================================================================== -->
<!-- Will destroy any running vagrant box within our tmp directory -->
<!-- ==================================================================== -->
<target name="destroy-vagrant-box">
<!-- issue the actual destroy command -->
<exec dir="${temp.dir}" executable="vagrant" failonerror="true">
<arg line="destroy -f" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will destroy any running vagrant box within our tmp directory if -->
<!-- there has been an error before -->
<!-- ==================================================================== -->
<target name="destroy-vagrant-box-on-error" if="fatal-error.occured" unless="${vagrant-box.error-resistant}">
<!-- forward to the destroy command -->
<antcall target="destroy-vagrant-box" />
</target>
<!-- ==================================================================== -->
<!-- Will split a string at the "-" character -->
<!-- ==================================================================== -->
<scriptdef name="filter-version" language="javascript">
<attribute name="param"/>
<![CDATA[
// getting the param
var param = attributes.get("param");
// preset the return values
var resultVersion = param;
var resultBuildNumber = '';
// split if necessary
if (param.indexOf("-") !== -1) {
resultVersion = param.substring(0, param.indexOf("-"));
resultBuildNumber = param.replace(resultVersion + "-", "");
}
// store the result in new properties
project.setProperty("RESULT_VERSION", resultVersion);
project.setProperty("RESULT_BUILD-NUMBER", resultBuildNumber);
]]>
</scriptdef>
<!-- ==================================================================== -->
<!-- Prepares the appserver sources -->
<!-- ==================================================================== -->
<target name="prepare-appserver-dist" depends="prepare, prepare-src-version-parts">
<!-- install local composer -->
<antcall target="install-composer" />
<!-- tell them what we do here -->
<echo message="Checkout latest tag version ${appserver.src.version}" />
<!-- checkout latest tag version -->
<exec dir="${temp.dir}/appserver-src" executable="git">
<arg line="checkout -q ${appserver.src.version}" />
</exec>
<!-- move to target.dir -->
<move todir="${target.dir}/src${appserver-base.dir}">
<fileset dir="${temp.dir}/appserver-src"/>
</move>
<!-- remove git db files -->
<delete dir="${target.dir}/src${appserver-base.dir}/.git" includeemptydirs="true" />
<!-- create the file with the version number -->
<echo file="${target.dir}/src${appserver-base.dir}/etc/appserver/.release-version" message="${appserver.src.semver}-${build.number}${appserver.src.suffix}" />
<!-- install dependencies via composer and let postinstall-scripts proceed -->
<echo message="Installing composer dependencies" />
<exec dir="${target.dir}/src${appserver-base.dir}" executable="php">
<arg line="${temp.dir}/composer.phar install --prefer-dist --no-dev --no-interaction --ignore-platform-reqs --optimize-autoloader"/>
</exec>
<!-- create deploy folder if not exists -->
<mkdir dir="${target.dir}/src/opt/appserver/deploy"/>
<!-- deploy api/example app by putting it into deploy folder of runtime -->
<get src="${appserver.apps.api.url}" dest="${target.dir}/src${appserver-base.dir}/var/deploy/api.phar" />
<get src="${appserver.apps.example.url}" dest="${target.dir}/src${appserver-base.dir}/deploy/example.phar" />
</target>
<!-- ==================================================================== -->
<!-- Propagates the recently built version to more general plattforms -->
<!-- like blog entries, external build targets, etc. -->
<!-- ==================================================================== -->
<target name="version-release" description="Propagates the recent build to the official release sites, updates release lists, etc..">
<echo message="Now starting release cycle for the lately built version"/>
</target>
<!-- ==================================================================== -->
<!-- Publishes the recent build to any snapshot hubs, etc.. Not to be -->
<!-- mistaken for the "release" target -->
<!-- ==================================================================== -->
<target name="publish" description="Publishes the recent build to any snapshot hubs, etc..">
<echo message="Now starting publish cycle"/>
<!-- upload the build artifacts to the snapshot hub -->
<antcall target="copy-to-hub" />
</target>
<!-- ==================================================================== -->
<!-- Copies any built package to the snapshot hosting server. -->
<!-- ==================================================================== -->
<target name="copy-to-hub" description="Uploads any built package to the file-server.">
<echo message="Now try to upload all builds to ${build.server.host}:${build.server.upload-path}"/>
<!-- determine if we are on a Windows machine, if so make it known -->
<condition property="os.is-windows">
<os family="windows" />
</condition>
<!-- execute the actual copy commands -->
<antcall target="windows-copy-to-hub" />
<antcall target="unix-copy-to-hub" />
</target>
<!-- ==================================================================== -->
<!-- Copies any built package to the snapshot hosting server. -->
<!-- This target is only usable on Windows machines. -->
<!-- ==================================================================== -->
<target name="windows-copy-to-hub" if="os.is-windows" description="Uploads any built package from a Windows machine to the file-server.">
<echo message="Using Windows style upload process"/>
<scp todir="${build.server.user}@${build.server.host}:${build.server.upload-path}" trust="true" keyfile="${user.home}/.ssh/id_rsa" failonerror="true">
<fileset dir="${build.dir}" >
<include name="*.${build.name.ext}"/>
<include name="*.${extractor.name.ext}"/>
<include name="*.${os.package-extension}"/>
</fileset>
</scp>
</target>
<!-- ==================================================================== -->
<!-- Copies any built package to the snapshot hosting server. -->
<!-- This target is only usable on an Unix like machines. -->
<!-- ==================================================================== -->
<target name="unix-copy-to-hub" unless="os.is-windows" description="Uploads any built package from a Unix like machine to the file-server.">
<echo message="Using Unix style upload process"/>
<exec executable="sh" failonerror="true">
<arg value="-c" />
<arg value="scp -o StrictHostKeyChecking=no -i ${user.home}/.ssh/id_rsa ${build.dir}/* ${build.server.user}@${build.server.host}:${build.server.upload-path}" />
</exec>
</target>
<!-- ==================================================================== -->
<!-- Will prepare the environment to run a vagrant box in -->
<!-- ==================================================================== -->
<target name="prepare-build-environment" depends="prepare, clean-build, clean-reports">
<copy todir="${temp.dir}" failonerror="true">
<fileset dir="${basedir}">
<include name="build.*"/>
<include name="tests/*"/>
<include name="${codepool}/**"/>
<exclude name="tests/provision.sh"/>
</fileset>
</copy>
<!-- expand the properties within our box configuration -->
<copy todir="${temp.dir}" failonerror="true">
<fileset dir=".">
<include name="Vagrantfile"/>
<include name="provision.sh"/>
</fileset>
<filterchain>
<expandproperties/>
</filterchain>
</copy>
<!-- prepare a tmp dir for work within the VM -->
<mkdir dir="${temp.dir}/tmp" />
</target>
<!-- ==================================================================== -->
<!-- Creates all RPM packages within a temporarily started vagrant box. -->
<!-- Box will be started and destroyed automatically -->
<!-- ==================================================================== -->
<target name="build">
<!-- start our vagrant box -->
<antcall target="start-vagrant-build-box" />
<!-- start the build in the box -->
<antcall target="vagrant-build" />
<!-- destroy the box after all work is done -->
<antcall target="destroy-vagrant-box" />
</target>
<!-- ==================================================================== -->
<!-- Creates all RPM packages within an existing vagrant box -->
<!-- ==================================================================== -->
<target name="vagrant-build">
<!-- map the vagrant name according to the expected environment -->
<property name="vagrant-box.name" value="${vagrant-box.prefix}Build" />
<!-- invoke original build target within vagrant box -->
<exec dir="${temp.dir}" executable="sh" errorproperty="build.failed">
<arg value="-c" />
<arg value="vagrant ssh-config | ssh -F /dev/stdin ${vagrant-box.name} 'sudo ant local-build -buildfile ${vagrant.basedir}/build.xml -Dgithub.oauth.token=${github.oauth.token} -Dbuild.number=${build.number} -Dtarget-os.major.version=${target-os.major.version} -Dtarget-os.minor.version=${target-os.minor.version} -Dappserver.runtime.version=${appserver.runtime.version} -Dappserver.runtime.build=${appserver.runtime.build} -Dappserver.src.version=${appserver.src.version}'" />
</exec>
<!-- eliminate the possiblity of empty but existing error output -->
<property name="build.failed" value=""/>
<condition property="fatal-error.occured" value="${build.failed}">
<not>
<equals arg1="${build.failed}" arg2=""/>
</not>
</condition>
<!-- check for a specific build failure and make an emergency destroy -->
<antcall target="destroy-vagrant-box-on-error" />
<!-- tell them about any failures we might encountered -->
<fail if="fatal-error.occured" message="The build failed with message '${fatal-error.occured}', see log above." />
</target>
<!-- ==================================================================== -->
<!-- Runs all available tests from all included test files -->
<!-- ==================================================================== -->
<target name="local-run-tests" depends="prepare">
<!-- run the integration tests -->
<antcall target="local-run-system-tests" />
<!-- run integration tests -->
<antcall target="local-run-integration-tests" />
</target>
<!-- ==================================================================== -->
<!-- Runs all available tests from all included test files within a -->
<!-- vagrant machine -->
<!-- ==================================================================== -->
<target name="vagrant-run-tests">
<!-- run the system tests within the assumed box -->
<antcall target="vagrant-run-system-tests" />
<!-- run the performance tests within the assumed box -->
<antcall target="vagrant-run-integration-tests" />
</target>
<!-- ==================================================================== -->
<!-- Runs all available tests from all included test files within a -->
<!-- vagrant machine -->
<!-- ==================================================================== -->
<target name="run-tests">
<!-- start our vagrant box -->
<antcall target="start-vagrant-test-box" />
<!-- do the actual testing -->
<antcall target="vagrant-run-tests" />
<!-- destroy the box after all work is done -->
<antcall target="destroy-vagrant-box" />
</target>
</project>