forked from paulgibbs/behat-wordpress-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
240 lines (222 loc) · 8.23 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
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model xlink:href="/usr/share/php5/PEAR/data/phing/etc/phing-grammar.rng"
type="application/xml"
schematypens="http://relaxng.org/ns/structure/1.0" ?>
<project name="wordhat" description="BDD for Wordpress"
default="wordhat:test">
<import file="build/phing/docker.xml" />
<import file="build/phing/behat.xml" />
<property environment="env" />
<property name="wordhat.php-version" value="7.2" />
<property name="wordhat.wordpress-version" value="4.9.5" />
<property name="wordhat.phpstan-level" value="1" />
<property name="wordhat.phpstan-configfile"
value="${project.basedir}/phpstan.neon" />
<property name="wordhat.phpcs-configfile"
value="${project.basedir}/phpcs-ruleset.xml" />
<property name="wordhat.push-image" value="false" />
<target name="wordhat:test" depends="wordhat:prepare-config">
<phingcall target="wordhat:phpcs" />
<if>
<equals arg1="${wordhat.runstyle}" arg2="docker" />
<then>
<phingcall target="wordhat:docker-test" />
</then>
<elseif>
<equals arg1="${wordhat.runstyle}" arg2="native" />
<then>
<phingcall target="wordhat:native-test" />
</then>
</elseif>
</if>
</target>
<target name="wordhat:docker-test">
<phingcall target="docker:build" />
<phingcall target="docker:up" />
<echo msg="Waiting for WordPress to start" />
<waitfor maxwaitunit="second" maxwait="60"
checkeveryunit="second" checkevery="5">
<http url="http://wordpress:8080" quiet="true" />
</waitfor>
<phingcall target="docker:exec-tests" />
<if>
<isset property="${wordhat.pauls-build}" />
<then>
<phingcall target="docker:push" />
</then>
</if>
<phingcall target="docker:stop" />
<phingcall target="docker:cleanup" />
</target>
<target name="wordhat:native-test">
<!-- scoping means that this needs to be reloaded here -->
<property
file="${project.basedir}/build/properties/${wordhat.ci-engine}.yml" />
<!-- for the moment assume all the pre-reqs are in place - gradually
migrate them in -->
<echo message="${wordhat.behat-tags}" />
<if>
<isset property="wordhat.behat-tags" />
<then>
<phingcall target="behat:exec-tests">
<property name="behat.tags"
value="${wordhat.behat-tags}" />
</phingcall>
</then>
<else>
<phingcall target="behat:exec-tests" />
</else>
</if>
</target>
<target name="wordhat:detect-ci" unless="wordhat.runstyle">
<if>
<isset property="env.TRAVIS" />
<then>
<property name="wordhat.runstyle"
value="docker" />
<property name="wordhat.ci-engine"
value="travis" />
<if>
<equals
arg1="paulgibbs/behat-wordpress-extension"
arg2="${env.TRAVIS_REPO_SLUG}" />
<then>
<property name="wordhat.pauls-build"
value="true" />
</then>
</if>
</then>
<elseif>
<isset property="env.APPVEYOR" />
<then>
<property name="wordhat.runstyle"
value="native" />
<property name="wordhat.ci-engine"
value="appveyor" />
</then>
</elseif>
<else>
<property name="wordhat.runstyle"
value="docker" />
<property name="wordhat.ci-engine"
value="local" />
</else>
</if>
</target>
<target name="wordhat:prepare-config"
depends="wordhat:detect-ci">
<if>
<equals arg1="${wordhat.runstyle}" arg2="docker" />
<then>
<phingcall
target="wordhat:prepare-docker-config" />
</then>
<elseif>
<equals arg1="${wordhat.runstyle}" arg2="native" />
<then>
<phingcall
target="wordhat:prepare-native-config" />
</then>
</elseif>
</if>
</target>
<target name="wordhat:prepare-docker-config">
<property
file="${project.basedir}/build/properties/docker.yml" />
<copy tofile="${project.basedir}/build/docker/Dockerfile"
file="${project.basedir}/build/templates/Dockerfile.template"
overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy tofile="${project.basedir}/build/behat.yml"
file="${project.basedir}/build/templates/behat.yml.template"
overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy
tofile="${project.basedir}/build/docker/docker-compose.yml"
file="${project.basedir}/build/templates/docker-compose.yml.template"
overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<target name="wordhat:prepare-native-config">
<property
file="${project.basedir}/build/properties/${wordhat.ci-engine}.yml" />
<copy tofile="${project.basedir}/build/behat.yml"
file="${project.basedir}/build/templates/behat.yml.template"
overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<target name="wordhat:phpstan">
<property name="wordhat.php-binary"
value="vendor/bin/phpstan" />
<if>
<os family="windows" />
<then>
<pathconvert targetos="windows"
property="wordhat.php-binary">
<path path="${wordhat.php-binary}">
</path>
</pathconvert>
<pathconvert targetos="windows"
property="wordhat.phpstan-configfile">
<path path="${wordhat.phpstan-configfile}">
</path>
</pathconvert>
</then>
</if>
<exec executable="${wordhat.php-binary}" passthru="true"
checkreturn="true">
<arg value="analyse" />
<arg value="-c" />
<arg value="${wordhat.phpstan-configfile}" />
<arg value="--level=${wordhat.phpstan-level}" />
<arg value="src" />
</exec>
</target>
<target name="wordhat:phpcs">
<property name="wordhat.php-binary"
value="vendor/bin/phpcs" />
<if>
<os family="windows" />
<then>
<pathconvert targetos="windows"
property="wordhat.php-binary">
<path path="${wordhat.php-binary}">
</path>
</pathconvert>
</then>
</if>
<exec executable="${wordhat.php-binary}" passthru="true"
checkreturn="true">
<arg value="--standard=${wordhat.phpcs-configfile}" />
<arg value="-p" />
<arg value="-s" />
<arg value="-v" />
<arg value="-n" />
<arg value="src" />
<arg value="--extensions=php" />
</exec>
</target>
<target name="wordhat:check-syntax">
<foreach param="file" absparam="wordhat:file"
target="wordhat:check-file-syntax">
<fileset dir="${project.basedir}/src">
<include name="**/*.php" />
</fileset>
</foreach>
</target>
<target name="wordhat:check-file-syntax">
<exec command="php -l ${wordhat:file}" checkreturn="true" />
</target>
</project>