-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.xml
93 lines (87 loc) · 3.98 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
<project name="qabel-accounting" basedir="." default="build">
<property environment="env"/>
<property name="dblog" value="/tmp/postgresql.5433.log"/>
<property name="dbdir" value="/tmp/postgresqldata.5433"/>
<condition property="dbdir.exists"><available file="${dbdir}" type="dir"/></condition>
<condition property="dblog.exists"><available file="${dblog}" type="file"/></condition>
<condition property="clean-db.required"><or><available file="${dbdir}" type="dir"/><available file="${dblog}" type="file"/></or></condition>
<target name="build" depends="install">
<antcall target="test"/>
</target>
<target name="clean" depends="clean-db,clean-virtualenv"/>
<target name="clean-db" if="clean-db.required" depends="clean-dbdir,clean-dblog"/>
<target name="clean-dbdir" if="${dbdir.exists}">
<delete dir="${dbdir}"/>
</target>
<target name="clean-dblog" if="${dblog.exists}">
<delete file="${dblog}"/>
</target>
<property name="virtualenv" value="${basedir}/venv"/>
<property name="vbin" value="${virtualenv}/bin"/>
<condition property="virtualenv.exists"><available file="${virtualenv}" type="dir"/></condition>
<target name="clean-virtualenv" if="virtualenv.exists">
<exec executable="rm" dir="${basedir}" failonerror="true">
<arg value="-r"/>
<arg value="${virtualenv}"/>
</exec>
<property name="virtualenv.exists" value="false"/>
</target>
<target name="create-virtualenv">
<exec executable="virtualenv" failonerror="true">
<arg value="${virtualenv}"/>
<arg value="--python=python3.5"/>
<arg value="--no-site-packages"/>
</exec>
</target>
<target name="virtualenv" depends="create-virtualenv">
<exec executable="${vbin}/pip" failonerror="true">
<arg value="install"/>
<arg value="--upgrade"/>
<arg value="pip"/>
<arg value="setuptools"/>
<arg value="wheel"/>
</exec>
</target>
<target name="install" depends="virtualenv,install-phantom">
<exec executable="${vbin}/pip" failonerror="true">
<arg value="install"/>
<arg value="-U"/>
<arg value="-r"/>
<arg value="requirements.txt"/>
</exec>
</target>
<available file="npm" filepath="${env.PATH}" property="npm.exists"/>
<available file="phantomjs" filepath="${env.PATH}" property="phantomjs.exists"/>
<target name="install-phantom-npm" unless="phantomjs.exists">
<echo message="installing phantom via npm"/>
<exec executable="npm" resultproperty="npm.exitcode" failonerror="false">
<arg value="install"/>
<arg value="-l"/>
<arg value="phantomjs"/>
</exec>
<condition property="phantomjs.installed" value="true" else="false"><equals arg1="${npm.exitcode}" arg2="0" forcestring="true"/></condition>
<symlink link="${vbin}/phantomjs" resource="${basedir}/node_modules/phantomjs/bin/phantomjs" overwrite="true"/>
<echo message="result: ${phantomjs.installed}"/>
</target>
<target name="install-phantom" unless="phantomjs.exists" depends="install-phantom-npm">
<fail message="missing phantomjs, please install it in path or install npm">
<condition>
<not>
<or>
<equals arg1="${phantomjs.exists}" arg2="true"/>
<equals arg1="${phantomjs.installed}" arg2="true"/>
</or>
</not>
</condition>
</fail>
</target>
<target name="test" depends="install,clean-db">
<exec executable="${vbin}/py.test" dir="${basedir}" failonerror="true">
<env key="PATH" path="${env.PATH}:${vbin}"/>
<arg value="--junitxml=${basedir}/junit.xml"/>
<arg value="-v"/>
<arg value="--exitfirst"/>
<arg value="--ff"/>
</exec>
</target>
</project>