-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.xml
301 lines (265 loc) · 12.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<project name="OpenConext EngineBlock" default="build">
<target name="build" depends="test-suites,code-quality,functional-tests,security-tests" />
<target name="pre-commit" depends="test-suites,api-functional-tests,code-quality" />
<target name="pre-push" depends="test-suites,code-quality,behat-dev-wip,security-tests" />
<target name="functional-tests" depends="api-functional-tests,behat-travis" />
<target name="functional-tests-wip" depends="behat-travis-wip" />
<target name="functional-tests-selenium" depends="behat-travis-selenium"/>
<target name="code-quality-ci" depends="test-suites,code-quality,npm-lint,doc-header"/>
<target name="code-quality" depends="php-lint,phpmd,phpcs,phpcs-legacy,doc-header"/>
<target name="security-tests" depends="security-checker,npm-audit" />
<target name="test-suites" depends="eb4-tests,unit-tests,integration-tests,js-unit-tests,js-smoke-tests"/>
<target name="validate" depends="composer-validate"/>
<target name="install-git-hooks"
description="installs the pre-commit and pre-push hooks for git">
<copy file="${basedir}/ci/dev/pre-commit.dist" tofile="${basedir}/.git/hooks/pre-commit"/>
<copy file="${basedir}/ci/dev/pre-push.dist" tofile="${basedir}/.git/hooks/pre-push"/>
<chmod file="${basedir}/.git/hooks/pre-commit" perm="a+x,g-w"/>
<chmod file="${basedir}/.git/hooks/pre-push" perm="a+x,g-w"/>
</target>
<target name="get-changeset.php.raw"
description="creates a list of changed php files separated by newline">
<pathconvert property="changeset.php.raw" pathsep="${line.separator}">
<fileset dir="src">
<include name="**/*.php"/>
<modified/>
</fileset>
</pathconvert>
<!--Check if files are modified-->
<condition property="changeset.php.notempty">
<not>
<equals arg1="${changeset.php.raw}" arg2="" trim="true"/>
</not>
</condition>
</target>
<target name="get-changeset.php.spacesep" depends="get-changeset.php.raw" if="changeset.php.notempty"
description="Creates a quoted list of changed php files separated by spaces">
<loadresource property="changeset.php.spacesep">
<propertyresource name="changeset.php.raw"/>
<filterchain>
<tokenfilter delimoutput=" ">
<linetokenizer/>
<replaceregex pattern="^" replace='"'/>
<replaceregex pattern="$" replace='"'/>
</tokenfilter>
</filterchain>
</loadresource>
</target>
<target name="php-lint" depends="get-changeset.php.spacesep" if="changeset.php.notempty"
description="Perform syntax check of sourcecode files in parallel">
<exec executable="sh" failonerror="true">
<arg value="-c"/>
<arg value="echo '${changeset.php.spacesep}' | xargs -n 1 -P 4 php -l 1>/dev/null"/>
</exec>
<echo message="OK"/>
</target>
<target name="php-twig-lint" description="Perform syntax check of Twig templates">
<exec executable="app/console" failonerror="true">
<arg line="lint:twig theme/" />
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="vendor/bin/phpmd" failonerror="true">
<arg path="src"/>
<arg value="text"/>
<arg value="ci/qa-config/phpmd.xml"/>
<arg value="--exclude"/>
<arg value="*/Tests/*"/>
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec dir="${basedir}" executable="vendor/bin/phpcs" failonerror="true">
<arg value="--report=full" />
<arg value="--standard=ci/qa-config/phpcs.xml" />
<arg value="--warning-severity=0" />
<arg value="--extensions=php" />
<arg path="src" />
</exec>
</target>
<target name="phpcs-legacy"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec dir="${basedir}" executable="vendor/bin/phpcs" failonerror="true">
<arg value="--standard=ci/qa-config/phpcs-legacy.xml" />
<arg value="--warning-severity=0" />
<arg value="--extensions=php" />
<arg value="-s" />
<arg path="library" />
</exec>
</target>
<target name="phpcbf"
description="Fix coding standard violations using PHP_CodeSniffer">
<exec dir="${basedir}" executable="vendor/bin/phpcbf" failonerror="true">
<arg value="--standard=ci/qa-config/phpcs.xml" />
<arg value="--extensions=php" />
<arg value="--no-patch" />
<arg path="src" />
</exec>
</target>
<target name="phpcompat"
description="Check code compatibilty using PHP_CodeSniffer">
<exec dir="${basedir}" executable="vendor/bin/phpcs" failonerror="true">
<arg value="--standard=ci/qa-config/phpcompat.xml" />
<arg value="--extensions=php" />
<arg value="--runtime-set" />
<arg value="testVersion" />
<arg value="7.2-" />
<arg path="src" />
</exec>
<exec dir="${basedir}" executable="vendor/bin/phpcs" failonerror="true">
<arg value="--standard=ci/qa-config/phpcompat.xml" />
<arg value="--extensions=php" />
<arg value="--runtime-set" />
<arg value="testVersion" />
<arg value="7.2-" />
<arg path="library" />
</exec>
</target>
<target name="doc-header" description="Check if the copyright header is valid">
<exec executable="vendor/bin/docheader" failonerror="true">
<arg line="check src/ tests/ library/ --exclude-dir resources --exclude-dir languages" />
</exec>
</target>
<target name="security-checker" description="Check for vulnerable dependencies with SensioLabs Security Checker">
<exec dir="${basedir}" executable="bin/securityChecker.sh" failonerror="true"></exec>
</target>
<target name="npm-lint" description="Performs the linting of css and js">
<exec dir="${basedir}/theme" executable="npm" failonerror="true">
<arg line="run lint"/>
</exec>
</target>
<target name="npm-audit" description="Run npm audit">
<exec dir="${basedir}/theme" executable="npm" failonerror="true">
<arg line="run audit"/>
</exec>
</target>
<target name="eb4-tests" description="Run EB4 tests with PHPUnit">
<delete dir="app/cache/test"/>
<exec executable="vendor/bin/phpunit" failonerror="true">
<arg line="--configuration=${basedir}/tests/phpunit.xml"/>
<arg line="--testsuite=eb4"/>
<arg line="--coverage-text"/>
</exec>
</target>
<target name="unit-tests" description="Run unit tests with PHPUnit">
<delete dir="app/cache/test"/>
<exec executable="vendor/bin/phpunit" failonerror="true">
<arg line="--configuration=${basedir}/tests/phpunit.xml"/>
<arg line="--testsuite=unit"/>
<arg line="--coverage-text"/>
</exec>
</target>
<target name="integration-tests" description="Run integration tests with PHPUnit">
<delete dir="app/cache/test"/>
<exec executable="vendor/bin/phpunit" failonerror="true">
<arg line="--configuration=${basedir}/tests/phpunit.xml"/>
<arg line="--testsuite=integration"/>
</exec>
</target>
<target name="js-unit-tests">
<exec dir="${basedir}/theme" executable="node_modules/.bin/jest" failonerror="true">
<env key="CHROME_BIN" value="/usr/bin/google-chrome" />
<arg value="material/javascripts/tests/unit" />
</exec>
</target>
<target name="js-smoke-tests">
<exec dir="${basedir}/theme" executable="node_modules/.bin/jest" failonerror="true">
<env key="CHROME_BIN" value="/usr/bin/google-chrome" />
<arg line="--runInBand" />
<arg line="material/javascripts/tests/smoke" />
</exec>
</target>
<property environment="env" />
<target name="js-visual-regression-tests">
<exec dir="${basedir}/theme" executable="node_modules/.bin/cypress" failonerror="true">
<env key="CYPRESS_integrationFolder" value="cypress/visual-regression/${env.EB_THEME}" />
<arg line="run --browser=chrome --headless" />
</exec>
</target>
<target name="api-functional-tests"
description="Run functional tests with PHPUnit"
depends="create-test-db">
<delete dir="app/cache/test"/>
<exec executable="vendor/bin/phpunit" failonerror="true">
<arg line="--configuration=${basedir}/tests/phpunit.xml"/>
<arg line="--testsuite=functional"/>
</exec>
</target>
<target name="behat-dev">
<echo message="${line.separator}${line.separator}Running Behat"/>
<antcall target="run-behat">
<param name="suite" value="default"/>
</antcall>
</target>
<target name="behat-selenium-dev">
<echo message="Starting a new selenium instance" />
<antcall target="selenium-stop"/>
<antcall target="selenium-start"/>
<echo message="${line.separator}${line.separator}Running Behat"/>
<antcall target="run-behat">
<param name="suite" value="selenium"/>
</antcall>
<antcall target="selenium-stop"/>
</target>
<target name="behat-dev-wip">
<echo message="${line.separator}${line.separator}Running Behat"/>
<antcall target="run-behat">
<param name="suite" value="wip"/>
</antcall>
</target>
<target name="behat-travis"
description="Run the functional testing suite">
<antcall target="run-behat">
<param name="suite" value="default"/>
</antcall>
</target>
<target name="behat-travis-wip"
description="Run the functional testing suite for features marked as WIP">
<antcall target="run-behat">
<param name="suite" value="wip"/>
</antcall>
</target>
<target name="behat-travis-selenium"
description="Run the functional testing suite for features marked as selenium with selenium">
<antcall target="run-behat">
<param name="suite" value="selenium"/>
</antcall>
</target>
<target name="run-behat"
description="Execute the behat test suite"
depends="create-test-db">
<exec executable="vendor/bin/behat" failonerror="true">
<arg line="-c ./tests/behat.yml"/>
<arg line="--suite ${suite} -vv"/>
<arg line="--format progress"/>
<arg line="--strict"/>
</exec>
</target>
<target name="create-test-db">
<exec executable="app/console" failonerror="true">
<arg line="doctrine:schema:drop --force --env=test" />
</exec>
<exec executable="app/console" failonerror="true">
<arg line="doctrine:schema:create --env=test" />
</exec>
</target>
<target name="composer-validate"
description="validate composer">
<exec executable="composer" failonerror="true">
<arg line="validate"/>
</exec>
</target>
<target name="selenium-start"
description="ensures that selenium is started">
<exec executable="sudo" failonerror="true">
<arg line="systemctl start selenium"/>
</exec>
</target>
<target name="selenium-stop"
description="ensures that selenium is stopped">
<exec executable="sudo" failonerror="false">
<arg line="systemctl stop selenium"/>
</exec>
</target>
</project>