0d69ba636fcad31e10a984e5c846b0373df4e64e
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / AbstractCoreSpec.java
1 package core;
2
3 /*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 import java.util.ArrayList;
17
18 import com.atlassian.bamboo.specs.api.builders.BambooKey;
19 import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
20 import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
21 import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
22 import com.atlassian.bamboo.specs.api.builders.plan.Job;
23 import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
24 import com.atlassian.bamboo.specs.api.builders.plan.artifact.Artifact;
25 import com.atlassian.bamboo.specs.api.builders.plan.configuration.AllOtherPluginsConfiguration;
26 import com.atlassian.bamboo.specs.api.builders.plan.configuration.PluginConfiguration;
27 import com.atlassian.bamboo.specs.api.builders.requirement.Requirement;
28 import com.atlassian.bamboo.specs.api.builders.task.Task;
29 import com.atlassian.bamboo.specs.builders.task.CheckoutItem;
30 import com.atlassian.bamboo.specs.builders.task.CommandTask;
31 import com.atlassian.bamboo.specs.builders.task.NpmTask;
32 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
33 import com.atlassian.bamboo.specs.builders.task.TestParserTask;
34 import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
35 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
36 import com.atlassian.bamboo.specs.model.task.TestParserTaskProperties;
37 import com.atlassian.bamboo.specs.util.MapBuilder;
38
39 /**
40 * Abstract class with common methods of pre-merge and nightly plan
41 */
42 abstract public class AbstractCoreSpec {
43
44 protected static String bambooServerName = "https://bamboo.typo3.com:443";
45 protected static String projectName = "TYPO3 Core";
46 protected static String projectKey = "CORE";
47
48 protected String composerRootVersionEnvironment = "COMPOSER_ROOT_VERSION=8.7.0";
49
50 protected String testingFrameworkBuildPath = "vendor/typo3/testing-framework/Resources/Core/Build/";
51
52 /**
53 * @todo This can be removed if acceptance mysql tests are rewritten and active again
54 */
55 protected String credentialsMysql =
56 "typo3DatabaseName=\"func\"" +
57 " typo3DatabaseUsername=\"funcu\"" +
58 " typo3DatabasePassword=\"funcp\"" +
59 " typo3DatabaseHost=\"localhost\"" +
60 " typo3InstallToolPassword=\"klaus\"";
61
62 /**
63 * @todo This can be removed if acceptance pgsql tests are rewritten and active again
64 */
65 protected String credentialsPgsql =
66 "typo3DatabaseDriver=\"pdo_pgsql\"" +
67 " typo3DatabaseName=\"func\"" +
68 " typo3DatabaseUsername=\"bamboo\"" +
69 " typo3DatabaseHost=\"localhost\"" +
70 " typo3DatabasePort=\"5433\"" +
71 " typo3InstallToolPassword=\"klaus\"";
72
73 /**
74 * Default permissions on core plans
75 *
76 * @param projectName
77 * @param planName
78 * @return
79 */
80 protected PlanPermissions getDefaultPlanPermissions(String projectKey, String planKey) {
81 return new PlanPermissions(new PlanIdentifier(projectKey, planKey))
82 .permissions(new Permissions()
83 .groupPermissions("TYPO3 GmbH", PermissionType.ADMIN, PermissionType.VIEW, PermissionType.EDIT, PermissionType.BUILD, PermissionType.CLONE)
84 .groupPermissions("TYPO3 Core Team", PermissionType.VIEW, PermissionType.BUILD)
85 .loggedInUserPermissions(PermissionType.VIEW)
86 .anonymousUserPermissionView()
87 );
88 }
89
90 /**
91 * Default plan plugin configuration
92 *
93 * @return
94 */
95 protected PluginConfiguration getDefaultPlanPluginConfiguration() {
96 return new AllOtherPluginsConfiguration()
97 .configuration(new MapBuilder()
98 .put("custom", new MapBuilder()
99 .put("artifactHandlers.useCustomArtifactHandlers", "false")
100 .put("buildExpiryConfig", new MapBuilder()
101 .put("duration", "30")
102 .put("period", "days")
103 .put("labelsToKeep", "")
104 .put("expiryTypeResult", "true")
105 .put("buildsToKeep", "")
106 .put("enabled", "true")
107 .build()
108 )
109 .build()
110 )
111 .build()
112 );
113 }
114
115 /**
116 * Default job plugin configuration
117 *
118 * @return
119 */
120 protected PluginConfiguration getDefaultJobPluginConfiguration() {
121 return new AllOtherPluginsConfiguration()
122 .configuration(new MapBuilder()
123 .put("repositoryDefiningWorkingDirectory", -1)
124 .put("custom", new MapBuilder()
125 .put("auto", new MapBuilder()
126 .put("regex", "")
127 .put("label", "")
128 .build()
129 )
130 .put("buildHangingConfig.enabled", "false")
131 .put("ncover.path", "")
132 .put("clover", new MapBuilder()
133 .put("path", "")
134 .put("license", "")
135 .put("useLocalLicenseKey", "true")
136 .build()
137 )
138 .build()
139 )
140 .build()
141 );
142 }
143
144 /**
145 * Job creating labels needed for intercept communication
146 */
147 protected Job getJobBuildLabels() {
148 return new Job("Create build labels", new BambooKey("CLFB"))
149 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
150 .pluginConfigurations(new AllOtherPluginsConfiguration()
151 .configuration(new MapBuilder()
152 .put("repositoryDefiningWorkingDirectory", -1)
153 .put("custom", new MapBuilder()
154 .put("auto", new MapBuilder()
155 .put("label", "change-${bamboo.changeUrl}, patchset-${bamboo.patchset}")
156 .build()
157 )
158 .put("buildHangingConfig.enabled", "false")
159 .put("ncover.path", "")
160 .put("clover", new MapBuilder()
161 .put("path", "")
162 .put("license", "")
163 .put("useLocalLicenseKey", "true")
164 .build()
165 )
166 .build()
167 )
168 .build()
169 )
170 )
171 .tasks(
172 new ScriptTask()
173 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
174 .inlineBody("echo \"I'm just here for the labels!\"")
175 )
176 .requirements(
177 this.getRequirementDocker10()
178 )
179 .cleanWorkingDirectory(true);
180 }
181
182 /**
183 * Job composer validate
184 *
185 * @param String requirementIdentifier
186 */
187 protected Job getJobComposerValidate(String requirementIdentifier) {
188 return new Job("Validate composer.json", new BambooKey("VC"))
189 .description("Validate composer.json before actual tests are executed")
190 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
191 .tasks(
192 this.getTaskGitCloneRepository(),
193 this.getTaskGitCherryPick(),
194 new ScriptTask()
195 .description("composer validate")
196 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
197 .inlineBody(
198 this.getScriptTaskBashInlineBody() +
199 this.getScriptTaskComposer(requirementIdentifier) +
200 "composer validate"
201 )
202 .environmentVariables(this.composerRootVersionEnvironment)
203 )
204 .requirements(
205 this.getRequirementDocker10()
206 )
207 .cleanWorkingDirectory(true);
208 }
209
210 /**
211 * Job acceptance test installs system on mysql
212 *
213 * @param String requirementIdentfier
214 */
215 protected Job getJobAcceptanceTestInstallMysql(String requirementIdentifier) {
216 return new Job("Accept inst my " + requirementIdentifier, new BambooKey("ACINSTMY" + requirementIdentifier))
217 .description("Install TYPO3 on mariadb and load introduction package " + requirementIdentifier)
218 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
219 .tasks(
220 this.getTaskGitCloneRepository(),
221 this.getTaskGitCherryPick(),
222 this.getTaskComposerInstall(requirementIdentifier),
223 this.getTaskPrepareAcceptanceTest(),
224 this.getTaskDockerDependenciesAcceptanceInstallMariadb10(),
225 new ScriptTask()
226 .description("Install TYPO3 on mariadb 10")
227 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
228 .inlineBody(
229 this.getScriptTaskBashInlineBody() +
230 "function codecept() {\n" +
231 " docker run \\\n" +
232 " -u ${HOST_UID} \\\n" +
233 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
234 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
235 " -e typo3InstallMysqlDatabaseHost=${typo3InstallMysqlDatabaseHost} \\\n" +
236 " -e typo3InstallMysqlDatabaseName=${typo3InstallMysqlDatabaseName} \\\n" +
237 " -e typo3InstallMysqlDatabaseUsername=${typo3InstallMysqlDatabaseUsername} \\\n" +
238 " -e typo3InstallMysqlDatabasePassword=${typo3InstallMysqlDatabasePassword} \\\n" +
239 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
240 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
241 " --rm \\\n" +
242 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
243 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
244 "}\n" +
245 "\n" +
246 "codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=mysql --xml reports.xml --html reports.html\n"
247 )
248 )
249 .finalTasks(
250 this.getTaskStopDockerDependencies(),
251 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
252 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
253 )
254 .artifacts(new Artifact()
255 .name("Test Report")
256 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
257 .shared(false)
258 )
259 .requirements(
260 this.getRequirementDocker10()
261 )
262 .cleanWorkingDirectory(true);
263 }
264
265 /**
266 * Job acceptance test installs system and introduction package on pgsql
267 *
268 * @param String requirementIdentfier
269 */
270 protected Job getJobAcceptanceTestInstallPgsql(String requirementIdentifier) {
271 return new Job("Accept inst pg " + requirementIdentifier, new BambooKey("ACINSTPG" + requirementIdentifier))
272 .description("Install TYPO3 on pgsql and load introduction package " + requirementIdentifier)
273 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
274 .tasks(
275 this.getTaskGitCloneRepository(),
276 this.getTaskGitCherryPick(),
277 this.getTaskComposerInstall(requirementIdentifier),
278 this.getTaskPrepareAcceptanceTest(),
279 this.getTaskDockerDependenciesAcceptanceInstallPostgres95(),
280 new ScriptTask()
281 .description("Install TYPO3 on postgresql 9.5")
282 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
283 .inlineBody(
284 this.getScriptTaskBashInlineBody() +
285 "function codecept() {\n" +
286 " docker run \\\n" +
287 " -u ${HOST_UID} \\\n" +
288 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
289 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
290 " -e typo3InstallPostgresqlDatabaseHost=postgres9-5 \\\n" +
291 " -e typo3InstallPostgresqlDatabaseName=${typo3InstallPostgresqlDatabaseName} \\\n" +
292 " -e typo3InstallPostgresqlDatabaseUsername=${typo3InstallPostgresqlDatabaseUsername} \\\n" +
293 " -e typo3InstallPostgresqlDatabasePassword=${typo3InstallPostgresqlDatabasePassword} \\\n" +
294 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
295 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
296 " --rm \\\n" +
297 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
298 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
299 "}\n" +
300 "\n" +
301 "codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=postgresql --xml reports.xml --html reports.html\n"
302 )
303 )
304 .finalTasks(
305 this.getTaskStopDockerDependencies(),
306 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
307 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
308 )
309 .artifacts(new Artifact()
310 .name("Test Report")
311 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
312 .shared(false)
313 )
314 .requirements(
315 this.getRequirementDocker10()
316 )
317 .cleanWorkingDirectory(true);
318 }
319
320 /**
321 * Jobs for mysql based acceptance tests
322 *
323 * @param int numberOfChunks
324 * @param String requirementIdentifier
325 */
326 protected ArrayList<Job> getJobsAcceptanceTestsBackendMysql(int numberOfChunks, String requirementIdentifier) {
327 ArrayList<Job> jobs = new ArrayList<Job>();
328
329 for (int i=1; i<=numberOfChunks; i++) {
330 jobs.add(new Job("Accept my " + requirementIdentifier + " 0" + i, new BambooKey("ACMY" + requirementIdentifier + "0" + i))
331 .description("Run acceptance tests" + requirementIdentifier)
332 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
333 .tasks(
334 this.getTaskGitCloneRepository(),
335 this.getTaskGitCherryPick(),
336 this.getTaskComposerInstall(requirementIdentifier),
337 this.getTaskPrepareAcceptanceTest(),
338 this.getTaskDockerDependenciesAcceptanceBackendMariadb10(),
339 new ScriptTask()
340 .description("Split acceptance tests")
341 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
342 .inlineBody(
343 this.getScriptTaskBashInlineBody() +
344 "function splitAcceptanceTests() {\n" +
345 " docker run \\\n" +
346 " -u ${HOST_UID} \\\n" +
347 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
348 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
349 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
350 " --rm \\\n" +
351 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
352 " bin/bash -c \"cd ${PWD}; ./" + this.testingFrameworkBuildPath + "Scripts/splitAcceptanceTests.sh $*\"\n" +
353 "}\n" +
354 "\n" +
355 "splitAcceptanceTests " + numberOfChunks
356 ),
357 new ScriptTask()
358 .description("Execute codeception acceptance suite group " + i)
359 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
360 .inlineBody(
361 this.getScriptTaskBashInlineBody() +
362 "function codecept() {\n" +
363 " docker run \\\n" +
364 " -u ${HOST_UID} \\\n" +
365 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
366 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
367 " -e typo3DatabaseName=func_test \\\n" +
368 " -e typo3DatabaseUsername=root \\\n" +
369 " -e typo3DatabasePassword=funcp \\\n" +
370 " -e typo3DatabaseHost=mariadb10 \\\n" +
371 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
372 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
373 " --rm \\\n" +
374 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
375 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
376 "}\n" +
377 "\n" +
378 "codecept run Backend -d -g AcceptanceTests-Job-" + i + " -c typo3/sysext/core/Tests/codeception.yml --xml reports.xml --html reports.html\n"
379 )
380 )
381 .finalTasks(
382 this.getTaskStopDockerDependencies(),
383 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
384 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
385 )
386 .artifacts(new Artifact()
387 .name("Test Report")
388 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
389 .shared(false)
390 )
391 .requirements(
392 this.getRequirementDocker10()
393 )
394 .cleanWorkingDirectory(true)
395 );
396 }
397
398 return jobs;
399 }
400
401 /**
402 * Jobs for mysql based functional tests
403 *
404 * @param int numberOfChunks
405 * @param String requirementIdentifier
406 */
407 protected ArrayList<Job> getJobsFunctionalTestsMysql(int numberOfChunks, String requirementIdentifier) {
408 ArrayList<Job> jobs = new ArrayList<Job>();
409
410 for (int i=0; i<numberOfChunks; i++) {
411 jobs.add(new Job("Func mysql " + requirementIdentifier + " 0" + i, new BambooKey("FMY" + requirementIdentifier + "0" + i))
412 .description("Run functional tests on mysql DB " + requirementIdentifier)
413 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
414 .tasks(
415 this.getTaskGitCloneRepository(),
416 this.getTaskGitCherryPick(),
417 this.getTaskComposerInstall(requirementIdentifier),
418 this.getTaskDockerDependenciesFunctionalMariadb10(),
419 this.getTaskSplitFunctionalJobs(numberOfChunks),
420 new ScriptTask()
421 .description("Run phpunit with functional chunk 0" + i)
422 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
423 .inlineBody(
424 this.getScriptTaskBashInlineBody() +
425 "function phpunit() {\n" +
426 " docker run \\\n" +
427 " -u ${HOST_UID} \\\n" +
428 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
429 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
430 " -e typo3DatabaseName=func_test \\\n" +
431 " -e typo3DatabaseUsername=root \\\n" +
432 " -e typo3DatabasePassword=funcp \\\n" +
433 " -e typo3DatabaseHost=mariadb10 \\\n" +
434 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
435 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
436 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
437 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
438 " --rm \\\n" +
439 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
440 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
441 "}\n" +
442 "\n" +
443 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
444 )
445 )
446 .finalTasks(
447 this.getTaskStopDockerDependencies(),
448 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
449 .resultDirectories("test-reports/phpunit.xml")
450 )
451 .requirements(
452 this.getRequirementDocker10()
453 )
454 .cleanWorkingDirectory(true)
455 );
456 }
457
458 return jobs;
459 }
460
461 /**
462 * Jobs for mssql based functional tests
463 *
464 * @param int numberOfChunks
465 * @param String requirementIdentifier
466 */
467 protected ArrayList<Job> getJobsFunctionalTestsMssql(int numberOfChunks, String requirementIdentifier) {
468 ArrayList<Job> jobs = new ArrayList<Job>();
469
470 for (int i=0; i<numberOfChunks; i++) {
471 jobs.add(new Job("Func mssql " + requirementIdentifier + " 0" + i, new BambooKey("FMS" + requirementIdentifier + "0" + i))
472 .description("Run functional tests on mssql DB " + requirementIdentifier)
473 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
474 .tasks(
475 this.getTaskGitCloneRepository(),
476 this.getTaskGitCherryPick(),
477 this.getTaskComposerInstall(requirementIdentifier),
478 this.getTaskDockerDependenciesFunctionalMssql(),
479 this.getTaskSplitFunctionalJobs(numberOfChunks),
480 new ScriptTask()
481 .description("Run phpunit with functional chunk 0" + i)
482 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
483 .inlineBody(
484 this.getScriptTaskBashInlineBody() +
485 "function phpunit() {\n" +
486 " docker run \\\n" +
487 " -u ${HOST_UID} \\\n" +
488 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
489 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
490 " -e typo3DatabaseDriver=sqlsrv \\\n" +
491 " -e typo3DatabaseName=func \\\n" +
492 " -e typo3DatabasePassword=Test1234! \\\n" +
493 " -e typo3DatabaseUsername=SA \\\n" +
494 " -e typo3DatabaseHost=localhost \\\n" +
495 " -e typo3DatabasePort=1433 \\\n" +
496 " -e typo3DatabaseCharset=utf-8 \\\n" +
497 " -e typo3DatabaseHost=mssql2017cu9 \\\n" +
498 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
499 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
500 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
501 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
502 " --rm \\\n" +
503 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
504 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
505 "}\n" +
506 "\n" +
507 "phpunit --exclude-group not-mssql --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
508 )
509 )
510 .finalTasks(
511 this.getTaskStopDockerDependencies(),
512 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
513 .resultDirectories("test-reports/phpunit.xml")
514 )
515 .requirements(
516 this.getRequirementDocker10()
517 )
518 .cleanWorkingDirectory(true)
519 );
520 }
521
522 return jobs;
523 }
524
525 /**
526 * Jobs for pgsql based functional tests
527 *
528 * @param int numberOfChunks
529 * @param String requirementIdentifier
530 */
531 protected ArrayList<Job> getJobsFunctionalTestsPgsql(int numberOfChunks, String requirementIdentifier) {
532 ArrayList<Job> jobs = new ArrayList<Job>();
533
534 for (int i=0; i<numberOfChunks; i++) {
535 jobs.add(new Job("Func pgsql " + requirementIdentifier + " 0" + i, new BambooKey("FPG" + requirementIdentifier + "0" + i))
536 .description("Run functional tests on pgsql DB " + requirementIdentifier)
537 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
538 .tasks(
539 this.getTaskGitCloneRepository(),
540 this.getTaskGitCherryPick(),
541 this.getTaskComposerInstall(requirementIdentifier),
542 this.getTaskDockerDependenciesFunctionalPostgres95(),
543 this.getTaskSplitFunctionalJobs(numberOfChunks),
544 new ScriptTask()
545 .description("Run phpunit with functional chunk 0" + i)
546 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
547 .inlineBody(
548 this.getScriptTaskBashInlineBody() +
549 "function phpunit() {\n" +
550 " docker run \\\n" +
551 " -u ${HOST_UID} \\\n" +
552 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
553 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
554 " -e typo3DatabaseDriver=pdo_pgsql \\\n" +
555 " -e typo3DatabaseName=bamboo \\\n" +
556 " -e typo3DatabaseUsername=bamboo \\\n" +
557 " -e typo3DatabaseHost=postgres9-5 \\\n" +
558 " -e typo3DatabasePassword=funcp \\\n" +
559 " -e typo3TestingRedisHost=redis4 \\\n" +
560 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
561 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
562 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
563 " --rm \\\n" +
564 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
565 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
566 "}\n" +
567 "\n" +
568 "phpunit --exclude-group not-postgres --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
569 )
570 )
571 .finalTasks(
572 this.getTaskStopDockerDependencies(),
573 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
574 .resultDirectories("test-reports/phpunit.xml")
575 )
576 .requirements(
577 this.getRequirementDocker10()
578 )
579 .cleanWorkingDirectory(true)
580 );
581 }
582
583 return jobs;
584 }
585
586 /**
587 * Job with various smaller script tests
588 *
589 * @param String requirementIdentifier
590 */
591 protected Job getJobIntegrationVarious(String requirementIdentifier) {
592 // Exception code checker, xlf, permissions, rst file check
593 return new Job("Integration various", new BambooKey("CDECC"))
594 .description("Checks duplicate exceptions, git submodules, xlf files, permissions, rst")
595 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
596 .tasks(
597 this.getTaskGitCloneRepository(),
598 this.getTaskGitCherryPick(),
599 this.getTaskComposerInstall(requirementIdentifier),
600 new ScriptTask()
601 .description("Run duplicate exception code check script")
602 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
603 .inlineBody(
604 this.getScriptTaskBashInlineBody() +
605 "./Build/Scripts/duplicateExceptionCodeCheck.sh\n"
606 ),
607 new ScriptTask()
608 .description("Run git submodule status and verify there are none")
609 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
610 .inlineBody(
611 this.getScriptTaskBashInlineBody() +
612 "if [[ `git submodule status 2>&1 | wc -l` -ne 0 ]]; then\n" +
613 " echo \\\"Found a submodule definition in repository\\\";\n" +
614 " exit 99;\n" +
615 "fi\n"
616 ),
617 new ScriptTask()
618 .description("Run permission check script")
619 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
620 .inlineBody(
621 this.getScriptTaskBashInlineBody() +
622 "./Build/Scripts/checkFilePermissions.sh\n"
623 ),
624 new ScriptTask()
625 .description("Run xlf check")
626 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
627 .inlineBody(
628 this.getScriptTaskBashInlineBody() +
629 "./Build/Scripts/xlfcheck.sh"
630 ),
631 new ScriptTask()
632 .description("Run rst check")
633 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
634 .inlineBody(
635 this.getScriptTaskBashInlineBody() +
636 "function validateRstFiles() {\n" +
637 " docker run \\\n" +
638 " -u ${HOST_UID} \\\n" +
639 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
640 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
641 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
642 " --rm \\\n" +
643 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
644 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/validateRstFiles.php $*\"\n" +
645 "}\n" +
646 "\n" +
647 "validateRstFiles"
648 ),
649 new ScriptTask()
650 .description("Run path length check")
651 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
652 .inlineBody(
653 this.getScriptTaskBashInlineBody() +
654 "./Build/Scripts/maxFilePathLength.sh"
655 ),
656 new ScriptTask()
657 .description("Run functional fixture csv format checker")
658 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
659 .inlineBody(
660 this.getScriptTaskBashInlineBody() +
661 "function checkIntegrityCsvFixtures() {\n" +
662 " docker run \\\n" +
663 " -u ${HOST_UID} \\\n" +
664 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
665 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
666 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
667 " --rm \\\n" +
668 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
669 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityCsvFixtures.php $*\"\n" +
670 "}\n" +
671 "\n" +
672 "checkIntegrityCsvFixtures"
673 ),
674 new ScriptTask()
675 .description("Run composer.json integrity check")
676 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
677 .inlineBody(
678 this.getScriptTaskBashInlineBody() +
679 "function checkIntegrityComposer() {\n" +
680 " docker run \\\n" +
681 " -u ${HOST_UID} \\\n" +
682 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
683 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
684 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
685 " --rm \\\n" +
686 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
687 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityComposer.php $*\"\n" +
688 "}\n" +
689 "\n" +
690 "checkIntegrityComposer"
691 )
692 )
693 .requirements(
694 this.getRequirementDocker10()
695 )
696 .cleanWorkingDirectory(true);
697 }
698
699 /**
700 * Job for javascript unit tests
701 *
702 * @param String requirementIdentifier
703 */
704 protected Job getJobUnitJavaScript(String requirementIdentifier) {
705 return new Job("Unit JavaScript", new BambooKey("JSUT"))
706 .description("Run JavaScript unit tests")
707 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
708 .tasks(
709 this.getTaskGitCloneRepository(),
710 this.getTaskGitCherryPick(),
711 this.getTaskComposerInstall(requirementIdentifier),
712 new ScriptTask()
713 .description("yarn install in Build/ dir")
714 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
715 .inlineBody(
716 this.getScriptTaskBashInlineBody() +
717 "function yarn() {\n" +
718 " docker run \\\n" +
719 " -u ${HOST_UID} \\\n" +
720 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
721 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
722 " -e HOME=${HOME} \\\n" +
723 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
724 " --rm \\\n" +
725 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
726 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
727 "}\n" +
728 "\n" +
729 "yarn install"
730 ),
731 new ScriptTask()
732 .description("Run tests")
733 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
734 .inlineBody(
735 this.getScriptTaskBashInlineBody() +
736 "function karma() {\n" +
737 " docker run \\\n" +
738 " -u ${HOST_UID} \\\n" +
739 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
740 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
741 " -e HOME=${HOME} \\\n" +
742 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
743 " --rm \\\n" +
744 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
745 " bin/bash -c \"cd ${PWD}; ./Build/node_modules/karma/bin/karma $*\"\n" +
746 "}\n" +
747 "\n" +
748 "karma start " + this.testingFrameworkBuildPath + "Configuration/JSUnit/karma.conf.js --single-run"
749 )
750 )
751 .finalTasks(
752 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
753 .resultDirectories("typo3temp/var/tests/*")
754 )
755 .artifacts(
756 new Artifact()
757 .name("Clover Report (System)")
758 .copyPattern("**/*.*")
759 .location("Build/target/site/clover")
760 .shared(false)
761 )
762 .requirements(
763 this.getRequirementDocker10()
764 )
765 .cleanWorkingDirectory(true);
766 }
767
768 /**
769 * Job for PHP lint
770 *
771 * @param String requirementIdentfier
772 */
773 protected Job getJobLintPhp(String requirementIdentifier) {
774 return new Job("Lint " + requirementIdentifier, new BambooKey("L" + requirementIdentifier))
775 .description("Run php -l on source files for linting " + requirementIdentifier)
776 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
777 .tasks(
778 this.getTaskGitCloneRepository(),
779 this.getTaskGitCherryPick(),
780 new ScriptTask()
781 .description("Run php lint")
782 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
783 .inlineBody(
784 this.getScriptTaskBashInlineBody() +
785 "function runLint() {\n" +
786 " docker run \\\n" +
787 " -u ${HOST_UID} \\\n" +
788 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
789 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
790 " -e HOME=${HOME} \\\n" +
791 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
792 " --rm \\\n" +
793 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
794 " bin/bash -c \"cd ${PWD}; find . -name \\*.php -print0 | xargs -0 -n1 -P2 php -n -c /etc/php/cli-no-xdebug/php.ini -l >/dev/null\"\n" +
795 "}\n" +
796 "\n" +
797 "runLint"
798 )
799 )
800 .requirements(
801 this.getRequirementDocker10()
802 )
803 .cleanWorkingDirectory(true);
804 }
805
806 /**
807 * Job for lint npm scss and typescript
808 *
809 * @param String requirementIdentifier
810 */
811 protected Job getJobLintScssTs(String requirementIdentifier) {
812 return new Job("Lint scss ts", new BambooKey("LSTS"))
813 .description("Lint scss and ts, build css and js, test git is clean")
814 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
815 .tasks(
816 this.getTaskGitCloneRepository(),
817 this.getTaskGitCherryPick(),
818 new ScriptTask()
819 .description("yarn install in Build/ dir")
820 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
821 .inlineBody(
822 this.getScriptTaskBashInlineBody() +
823 "function yarn() {\n" +
824 " docker run \\\n" +
825 " -u ${HOST_UID} \\\n" +
826 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
827 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
828 " -e HOME=${HOME} \\\n" +
829 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
830 " --rm \\\n" +
831 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
832 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
833 "}\n" +
834 "\n" +
835 "yarn install"
836 ),
837 new ScriptTask()
838 .description("Run grunt lint")
839 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
840 .inlineBody(
841 this.getScriptTaskBashInlineBody() +
842 "function grunt() {\n" +
843 " docker run \\\n" +
844 " -u ${HOST_UID} \\\n" +
845 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
846 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
847 " -e HOME=${HOME} \\\n" +
848 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
849 " --rm \\\n" +
850 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
851 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
852 "}\n" +
853 "\n" +
854 "grunt lint"
855 ),
856 new ScriptTask()
857 .description("Run grunt scripts")
858 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
859 .inlineBody(
860 this.getScriptTaskBashInlineBody() +
861 "function grunt() {\n" +
862 " docker run \\\n" +
863 " -u ${HOST_UID} \\\n" +
864 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
865 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
866 " -e HOME=${HOME} \\\n" +
867 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
868 " --rm \\\n" +
869 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
870 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
871 "}\n" +
872 "\n" +
873 "grunt scripts"
874 ),
875 new ScriptTask()
876 .description("Run grunt css")
877 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
878 .inlineBody(
879 this.getScriptTaskBashInlineBody() +
880 "function grunt() {\n" +
881 " docker run \\\n" +
882 " -u ${HOST_UID} \\\n" +
883 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
884 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
885 " -e HOME=${HOME} \\\n" +
886 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
887 " --rm \\\n" +
888 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
889 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
890 "}\n" +
891 "\n" +
892 "grunt css"
893 ),
894 new ScriptTask()
895 .description("git status to check for changed files after build-js")
896 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
897 .inlineBody(
898 this.getScriptTaskBashInlineBody() +
899 "git status | grep -q \"nothing to commit, working tree clean\""
900 )
901 )
902 .requirements(
903 this.getRequirementDocker10()
904 )
905 .cleanWorkingDirectory(true);
906 }
907
908 /**
909 * Job for unit testing PHP
910 *
911 * @param String requirementIdentfier
912 */
913 protected Job getJobUnitPhp(String requirementIdentifier) {
914 return new Job("Unit " + requirementIdentifier, new BambooKey("UT" + requirementIdentifier))
915 .description("Run unit tests " + requirementIdentifier)
916 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
917 .tasks(
918 this.getTaskGitCloneRepository(),
919 this.getTaskGitCherryPick(),
920 this.getTaskComposerInstall(requirementIdentifier),
921 this.getTaskDockerDependenciesUnit(),
922 new ScriptTask()
923 .description("Run phpunit")
924 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
925 .inlineBody(
926 this.getScriptTaskBashInlineBody() +
927 "function phpunit() {\n" +
928 " docker run \\\n" +
929 " -u ${HOST_UID} \\\n" +
930 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
931 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
932 " -e typo3TestingRedisHost=redis4 \\\n" +
933 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
934 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
935 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
936 " --rm \\\n" +
937 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
938 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
939 "}\n" +
940 "\n" +
941 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml"
942 )
943 )
944 .finalTasks(
945 this.getTaskStopDockerDependencies(),
946 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
947 .resultDirectories("test-reports/phpunit.xml")
948 )
949 .requirements(
950 this.getRequirementDocker10()
951 )
952 .cleanWorkingDirectory(true);
953 }
954
955 /**
956 * Jobs for unit testing PHP in random test order
957 *
958 * @param int numberOfRuns
959 * @param String requirementIdentfier
960 */
961 protected ArrayList<Job> getJobUnitPhpRandom(int numberOfRuns, String requirementIdentifier) {
962 ArrayList<Job> jobs = new ArrayList<Job>();
963
964 for (int i=0; i<numberOfRuns; i++) {
965 jobs.add(new Job("Unit " + requirementIdentifier + " random 0" + i, new BambooKey("UTR" + requirementIdentifier + "0" + i))
966 .description("Run unit tests on " + requirementIdentifier + " in random order 0" + i)
967 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
968 .tasks(
969 this.getTaskGitCloneRepository(),
970 this.getTaskGitCherryPick(),
971 this.getTaskComposerInstall(requirementIdentifier),
972 this.getTaskDockerDependenciesUnit(),
973 new ScriptTask()
974 .description("Run phpunit-randomizer")
975 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
976 .inlineBody(
977 this.getScriptTaskBashInlineBody() +
978 "function phpunitRandomizer() {\n" +
979 " docker run \\\n" +
980 " -u ${HOST_UID} \\\n" +
981 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
982 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
983 " -e typo3TestingRedisHost=redis4 \\\n" +
984 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
985 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
986 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
987 " --rm \\\n" +
988 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
989 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit-randomizer $*\"\n" +
990 "}\n" +
991 "\n" +
992 "phpunitRandomizer --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml --order rand"
993 )
994 )
995 .finalTasks(
996 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
997 .resultDirectories("test-reports/phpunit.xml")
998 )
999 .requirements(
1000 this.getRequirementDocker10()
1001 )
1002 .cleanWorkingDirectory(true)
1003 );
1004 }
1005
1006 return jobs;
1007 }
1008
1009 /**
1010 * Task definition for basic core clone of linked default repository
1011 */
1012 protected Task getTaskGitCloneRepository() {
1013 return new VcsCheckoutTask()
1014 .description("Checkout git core")
1015 .checkoutItems(new CheckoutItem().defaultRepository());
1016 }
1017
1018 /**
1019 * Task definition to cherry pick a patch set from gerrit on top of cloned core
1020 */
1021 protected Task getTaskGitCherryPick() {
1022 return new ScriptTask()
1023 .description("Gerrit cherry pick")
1024 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1025 .inlineBody(
1026 this.getScriptTaskBashInlineBody() +
1027 "CHANGEURL=${bamboo.changeUrl}\n" +
1028 "CHANGEURLID=${CHANGEURL#https://review.typo3.org/}\n" +
1029 "PATCHSET=${bamboo.patchset}\n" +
1030 "\n" +
1031 "if [[ $CHANGEURL ]]; then\n" +
1032 " gerrit-cherry-pick https://review.typo3.org/Packages/TYPO3.CMS $CHANGEURLID/$PATCHSET || exit 1\n" +
1033 "fi\n"
1034 );
1035 }
1036
1037 /**
1038 * Task definition to execute composer install
1039 *
1040 * @param String requirementIdentifier
1041 */
1042 protected Task getTaskComposerInstall(String requirementIdentifier) {
1043 return new ScriptTask()
1044 .description("composer install")
1045 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1046 .inlineBody(
1047 this.getScriptTaskBashInlineBody() +
1048 this.getScriptTaskComposer(requirementIdentifier) +
1049 "composer install -n"
1050 )
1051 .environmentVariables(this.composerRootVersionEnvironment);
1052 }
1053
1054 /**
1055 * Task to prepare an acceptance test starting selenium and others
1056 */
1057 protected Task getTaskPrepareAcceptanceTest() {
1058 return new ScriptTask()
1059 .description("Prepare acceptance test environment")
1060 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1061 .inlineBody(
1062 this.getScriptTaskBashInlineBody() +
1063 "mkdir -p typo3temp/var/tests/\n"
1064 );
1065 }
1066
1067 /**
1068 * Start docker sibling containers to execute acceptance install tests on mariadb
1069 */
1070 protected Task getTaskDockerDependenciesAcceptanceInstallMariadb10() {
1071 return new ScriptTask()
1072 .description("Start docker siblings for acceptance test install mariadb")
1073 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1074 .inlineBody(
1075 this.getScriptTaskBashInlineBody() +
1076 "cd Build/testing-docker/bamboo\n" +
1077 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1078 "docker-compose run start_dependencies_acceptance_install_mariadb10"
1079 );
1080 }
1081
1082 /**
1083 * Start docker sibling containers to execute acceptance install tests on postgres
1084 */
1085 protected Task getTaskDockerDependenciesAcceptanceInstallPostgres95() {
1086 return new ScriptTask()
1087 .description("Start docker siblings for acceptance test install postgres")
1088 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1089 .inlineBody(
1090 this.getScriptTaskBashInlineBody() +
1091 "cd Build/testing-docker/bamboo\n" +
1092 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1093 "docker-compose run start_dependencies_acceptance_install_postgres9-5"
1094 );
1095 }
1096
1097 /**
1098 * Start docker sibling containers to execute acceptance backend tests on mariadb
1099 */
1100 protected Task getTaskDockerDependenciesAcceptanceBackendMariadb10() {
1101 return new ScriptTask()
1102 .description("Start docker siblings for acceptance test backend mariadb")
1103 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1104 .inlineBody(
1105 this.getScriptTaskBashInlineBody() +
1106 "cd Build/testing-docker/bamboo\n" +
1107 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1108 "docker-compose run start_dependencies_acceptance_backend_mariadb10"
1109 );
1110 }
1111
1112 /**
1113 * Start docker sibling containers to execute functional tests on mariadb
1114 */
1115 protected Task getTaskDockerDependenciesFunctionalMariadb10() {
1116 return new ScriptTask()
1117 .description("Start docker siblings for functional tests on mariadb")
1118 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1119 .inlineBody(
1120 this.getScriptTaskBashInlineBody() +
1121 "cd Build/testing-docker/bamboo\n" +
1122 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1123 "docker-compose run start_dependencies_functional_mariadb10"
1124 );
1125 }
1126
1127 /**
1128 * Start docker sibling containers to execute functional tests on mssql
1129 */
1130 protected Task getTaskDockerDependenciesFunctionalMssql() {
1131 return new ScriptTask()
1132 .description("Start docker siblings for functional tests on mssql")
1133 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1134 .inlineBody(
1135 this.getScriptTaskBashInlineBody() +
1136 "cd Build/testing-docker/bamboo\n" +
1137 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1138 "docker-compose run start_dependencies_functional_mssql"
1139 );
1140 }
1141
1142 /**
1143 * Start docker sibling containers to execute functional tests on postgres
1144 */
1145 protected Task getTaskDockerDependenciesFunctionalPostgres95() {
1146 return new ScriptTask()
1147 .description("Start docker siblings for functional tests on postgres9-5")
1148 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1149 .inlineBody(
1150 this.getScriptTaskBashInlineBody() +
1151 "cd Build/testing-docker/bamboo\n" +
1152 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1153 "docker-compose run start_dependencies_functional_postgres9-5"
1154 );
1155 }
1156
1157 /**
1158 * Start docker sibling containers to execute unit tests
1159 */
1160 protected Task getTaskDockerDependenciesUnit() {
1161 return new ScriptTask()
1162 .description("Start docker siblings for unit tests")
1163 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1164 .inlineBody(
1165 this.getScriptTaskBashInlineBody() +
1166 "cd Build/testing-docker/bamboo\n" +
1167 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1168 "docker-compose run start_dependencies_unit"
1169 );
1170 }
1171
1172 /**
1173 * Stop started docker containers
1174 */
1175 protected Task getTaskStopDockerDependencies() {
1176 return new ScriptTask()
1177 .description("Stop docker siblings")
1178 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1179 .inlineBody(
1180 this.getScriptTaskBashInlineBody() +
1181 "cd Build/testing-docker/bamboo\n" +
1182 "docker-compose down -v"
1183 );
1184 }
1185
1186 /**
1187 * Task to split functional jobs into chunks
1188 */
1189 protected Task getTaskSplitFunctionalJobs(int numberOfJobs) {
1190 return new ScriptTask()
1191 .description("Create list of test files to execute per job")
1192 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1193 .inlineBody(
1194 this.getScriptTaskBashInlineBody() +
1195 "./" + this.testingFrameworkBuildPath + "Scripts/splitFunctionalTests.sh " + numberOfJobs
1196 );
1197 }
1198
1199 /**
1200 * Requirement for docker 1.0 set by bamboo-agents
1201 */
1202 protected Requirement getRequirementDocker10() {
1203 return new Requirement("system.hasDocker")
1204 .matchValue("1.0")
1205 .matchType(Requirement.MatchType.EQUALS);
1206 }
1207
1208 /**
1209 * A bash header for script tasks forking a bash if needed
1210 */
1211 protected String getScriptTaskBashInlineBody() {
1212 return
1213 "#!/bin/bash\n" +
1214 "\n" +
1215 "if [ \"$(ps -p \"$$\" -o comm=)\" != \"bash\" ]; then\n" +
1216 " bash \"$0\" \"$@\"\n" +
1217 " exit \"$?\"\n" +
1218 "fi\n" +
1219 "\n" +
1220 "set -x\n" +
1221 "\n";
1222 }
1223
1224 /**
1225 * A bash function aliasing 'composer' as docker command
1226 *
1227 * @param String requirementIdentifier
1228 */
1229 protected String getScriptTaskComposer(String requirementIdentifier) {
1230 return
1231 "function composer() {\n" +
1232 " docker run \\\n" +
1233 " -u ${HOST_UID} \\\n" +
1234 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1235 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1236 " -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} \\\n" +
1237 " -e HOME=${HOME} \\\n" +
1238 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1239 " --rm \\\n" +
1240 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1241 " bin/bash -c \"cd ${PWD}; composer $*\"\n" +
1242 "}\n" +
1243 "\n";
1244 }
1245 }