-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.xml
233 lines (212 loc) · 10.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Extension Builder" description="Builds an extension.zip from a git repository" default="all">
<property name="vendor-name" value="board3" />
<property name="extension-name" value="portal" />
<!--
Only set this to "true" if you have dependencies in the composer.json,
otherwise use "false".
-->
<property name="has-dependencies" value="true" />
<target name="clean-package">
<!--
Remove some unnecessary files/directories
${dir}/ is the folder of your extension, e.g. ext/nickvergessen/newspage/
-->
<delete dir="${dir}/tests" />
<delete dir="${dir}/.github" />
<delete dir="${dir}/travis" />
<delete dir="${dir}/vendor/marc1706/phpbb-text-shortener/.github" />
<delete dir="${dir}/language/ar" />
<delete dir="${dir}/language/es" />
<delete dir="${dir}/language/fr" />
<delete dir="${dir}/language/it" />
<delete dir="${dir}/language/nl" />
<delete file="${dir}/.gitignore" />
<delete file="${dir}/.gitattributes" />
<delete file="${dir}/build.xml" />
<delete file="${dir}/composer.lock" />
<delete file="${dir}/composer.phar" />
<delete file="${dir}/phpunit.xml.dist" />
<delete file="${dir}/README.md" />
</target>
<!--
TODO: DO NOT EDIT BELOW THIS LINE!!!!
-->
<property name="version" value="HEAD" override="true" />
<property name="package.version" value="HEAD" />
<property name="build-directory" value="build" override="true" />
<property name="package-directory" value="${build-directory}/package/${vendor-name}/${extension-name}" />
<property name="phpbb-root" value="${build-directory}/../../../../../" />
<property name="clover-path" value="${build-directory}/logs/clover.xml" />
<property name="coverage-html-path" value="${build-directory}/coverage" />
<!-- These are the main targets which you will probably want to use -->
<target name="all" depends="prepare-structure,package" />
<!--
Clean up the build directory
-->
<target name="clean">
<delete dir="${build-directory}" />
<mkdir dir="${build-directory}" />
</target>
<target name="composer">
<exec dir="${build-directory}/../"
command="php composer.phar install"
passthru="true" />
</target>
<target name="prepare-tests" depends="clean,composer">
<if>
<available property="phpbb-is-available" file="${phpbb-root}/phpBB/vendor/bin/phpunit" type="file" />
<then>
<echo msg="phpBB is already set up." />
</then>
<else>
<!-- Move Board3 Portal and set up phpBB -->
<exec command="CURRENT_BUILD_REV=$(git rev-parse --abbrev-ref HEAD)" passthru="true" />
<exec command="echo $GIT_BRANCH" passthru="true" />
<exec command="git clone -v --progress https://github.com/phpbb/phpbb.git phpbb" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="git checkout 3.3.x" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB" command="php ../composer.phar install" passthru="true" />
<mkdir dir="phpbb/phpBB/ext/board3" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3" command="git clone https://github.com/board3/Board3-Portal.git portal" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="git checkout $GIT_BRANCH" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="php composer.phar install" passthru="true" />
<property name="phpbb-root" value="${build-directory}/../phpbb" override="true" />
<property name="clover-path" value="../build/logs/clover.xml" override="true" />
<property name="coverage-html-path" value="../build/coverage" override="true" />
<exec dir="${build-directory}/../phpbb" command="cp ../../test_config_22x.php tests/test_config.php" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/cache" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="mkdir phpBB/cache/test" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/cache/test" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/files" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/store" passthru="true" />
<exec dir="${build-directory}/../phpbb" command="chmod 777 phpBB/images/avatars/upload" passthru="true" />
</else>
</if>
<if>
<equals arg1="$JENKINS_URL" arg2="" />
<then>
<echo msg="JENKINS_URL is not set" />
</then>
<else>
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="wget https://phar.phpunit.de/phploc.phar" passthru="true" />
<if>
<available property="logs-dir-available" file="${build-directory}/logs" type="dir" />
<then>
<echo msg="Logs dir already set up." />
</then>
<else>
<mkdir dir="${build-directory}/logs" />
<exec dir="${build-directory}/logs" command="touch phploc.csv" />
</else>
</if>
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3" command="php portal/phploc.phar --exclude=vendor --exclude=travis --log-csv ../../../../build/logs/phploc.csv portal/" passthru="true" />
<exec dir="${build-directory}/../phpbb/phpBB/ext/board3/portal" command="rm phploc.phar" passthru="true" />
</else>
</if>
<if>
<equals arg1="$BUILD_NUMBER" arg2="" />
<then>
<echo msg="BUILD_NUMBER is not available" />
</then>
<else>
<property environment="env" />
<echo>Build number is ${env.BUILD_NUMBER}</echo>
<property name="package.version" value="${env.BUILD_NUMBER}" override="true" />
</else>
</if>
</target>
<target name="test" depends="clean,composer,prepare-tests">
<if>
<available property="phpunit-available" file="phpbb/phpBB/vendor/bin/phpunit" type="file" />
<then>
<exec dir="${phpbb-root}"
command="phpBB/vendor/bin/phpunit
-c phpBB/ext/${vendor-name}/${extension-name}/ --coverage-clover=${clover-path} --coverage-html=${coverage-html-path}"
passthru="true" returnProperty="test.pass" />
<if>
<not>
<equals arg1="${test.pass}" arg2="0"/>
</not>
<then>
<fail msg="PHPUnit tests failed."/>
</then>
</if>
</then>
<else>
<echo msg="PHPUnit couldn't be found." />
</else>
</if>
</target>
<target name="test-slow" depends="clean,composer">
<if>
<available property="phpunit-available" file="phpbb/phpBB/vendor/bin/phpunit" type="file" />
<then>
<exec dir="${phpbb-root}"
command="phpBB/vendor/bin/phpunit
-c phpBB/ext/${vendor-name}/${extension-name}/
--group slow"
passthru="true" />
<if>
<not>
<equals arg1="${test.pass}" arg2="0"/>
</not>
<then>
<fail msg="PHPUnit slow tests failed."/>
</then>
</if>
</then>
<else>
<echo msg="PHPUnit couldn't be found." />
</else>
</if>
</target>
<!--
Recreate the necessary folders
-->
<target name="prepare-structure" depends="clean,composer,test,test-slow">
<mkdir dir="${build-directory}" />
<mkdir dir="${build-directory}/checkout" />
<mkdir dir="${build-directory}/package" />
<mkdir dir="${build-directory}/package/${vendor-name}" />
<mkdir dir="${build-directory}/package/${vendor-name}/${extension-name}" />
<mkdir dir="${build-directory}/upload" />
</target>
<!--
The real packaging
-->
<target name="package">
<echo msg="Extracting ${version}" />
<phingcall target="git-checkout">
<property name="archive-version" value="${version}" />
</phingcall>
<if>
<equals arg1="${has-dependencies}" arg2="1" />
<then>
<exec dir="${package-directory}" command="php composer.phar install --no-dev"
checkreturn="true" />
</then>
</if>
<phingcall target="clean-package">
<property name="dir" value="${package-directory}" />
</phingcall>
<phingcall target="wrap-package">
<property name="destination-filename" value="${build-directory}/upload/${vendor-name}_${extension-name}_${package.version}" />
</phingcall>
</target>
<!--
Checkout a given version and install/clean the dependencies
-->
<target name="git-checkout">
<echo msg="Getting archive for ${archive-version}" />
<exec command="git archive ${archive-version} --format zip --output ${build-directory}/checkout/${archive-version}.zip"
checkreturn="true" />
<unzip file="${build-directory}/checkout/${archive-version}.zip" todir="${package-directory}" />
</target>
<!--
Create the zip and tar ball
-->
<target name="wrap-package">
<echo msg="Creating archives (${vendor-name}/${extension-name} ${version})" />
<zip basedir="${build-directory}/package/" destfile="${destination-filename}.zip" />
</target>
</project>