[TASK] Simplify bamboo variable to label handling
[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=9.5.0";
49
50 protected String testingFrameworkBuildPath = "vendor/typo3/testing-framework/Resources/Core/Build/";
51
52 /**
53 * Default permissions on core plans
54 *
55 * @param projectName
56 * @param planName
57 * @return
58 */
59 protected PlanPermissions getDefaultPlanPermissions(String projectKey, String planKey) {
60 return new PlanPermissions(new PlanIdentifier(projectKey, planKey))
61 .permissions(new Permissions()
62 .groupPermissions("TYPO3 GmbH", PermissionType.ADMIN, PermissionType.VIEW, PermissionType.EDIT, PermissionType.BUILD, PermissionType.CLONE)
63 .groupPermissions("TYPO3 Core Team", PermissionType.VIEW, PermissionType.BUILD)
64 .loggedInUserPermissions(PermissionType.VIEW)
65 .anonymousUserPermissionView()
66 );
67 }
68
69 /**
70 * Default plan plugin configuration
71 *
72 * @return
73 */
74 protected PluginConfiguration getDefaultPlanPluginConfiguration() {
75 return new AllOtherPluginsConfiguration()
76 .configuration(new MapBuilder()
77 .put("custom", new MapBuilder()
78 .put("artifactHandlers.useCustomArtifactHandlers", "false")
79 .put("buildExpiryConfig", new MapBuilder()
80 .put("duration", "30")
81 .put("period", "days")
82 .put("labelsToKeep", "")
83 .put("expiryTypeResult", "true")
84 .put("buildsToKeep", "")
85 .put("enabled", "true")
86 .build()
87 )
88 .build()
89 )
90 .build()
91 );
92 }
93
94 /**
95 * Default job plugin configuration
96 *
97 * @return
98 */
99 protected PluginConfiguration getDefaultJobPluginConfiguration() {
100 return new AllOtherPluginsConfiguration()
101 .configuration(new MapBuilder()
102 .put("repositoryDefiningWorkingDirectory", -1)
103 .put("custom", new MapBuilder()
104 .put("auto", new MapBuilder()
105 .put("regex", "")
106 .put("label", "")
107 .build()
108 )
109 .put("buildHangingConfig.enabled", "false")
110 .put("ncover.path", "")
111 .put("clover", new MapBuilder()
112 .put("path", "")
113 .put("license", "")
114 .put("useLocalLicenseKey", "true")
115 .build()
116 )
117 .build()
118 )
119 .build()
120 );
121 }
122
123 /**
124 * Job creating labels needed for intercept communication
125 */
126 protected Job getJobBuildLabels() {
127 return new Job("Create build labels", new BambooKey("CLFB"))
128 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
129 .pluginConfigurations(new AllOtherPluginsConfiguration()
130 .configuration(new MapBuilder()
131 .put("repositoryDefiningWorkingDirectory", -1)
132 .put("custom", new MapBuilder()
133 .put("auto", new MapBuilder()
134 .put("label", "change-${bamboo.changeUrl}, patchset-${bamboo.patchset}")
135 .build()
136 )
137 .put("buildHangingConfig.enabled", "false")
138 .put("ncover.path", "")
139 .put("clover", new MapBuilder()
140 .put("path", "")
141 .put("license", "")
142 .put("useLocalLicenseKey", "true")
143 .build()
144 )
145 .build()
146 )
147 .build()
148 )
149 )
150 .tasks(
151 new ScriptTask()
152 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
153 .inlineBody("echo \"I'm just here for the labels!\"")
154 )
155 .requirements(
156 this.getRequirementDocker10()
157 )
158 .cleanWorkingDirectory(true);
159 }
160
161 /**
162 * Job composer validate
163 *
164 * @param String requirementIdentifier
165 */
166 protected Job getJobComposerValidate(String requirementIdentifier) {
167 return new Job("Validate composer.json", new BambooKey("VC"))
168 .description("Validate composer.json before actual tests are executed")
169 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
170 .tasks(
171 this.getTaskGitCloneRepository(),
172 this.getTaskGitCherryPick(),
173 new ScriptTask()
174 .description("composer validate")
175 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
176 .inlineBody(
177 this.getScriptTaskBashInlineBody() +
178 this.getScriptTaskComposer(requirementIdentifier) +
179 "composer validate"
180 )
181 .environmentVariables(this.composerRootVersionEnvironment)
182 )
183 .requirements(
184 this.getRequirementDocker10()
185 )
186 .cleanWorkingDirectory(true);
187 }
188
189
190 /**
191 * Job checking CGL of last git commit
192 *
193 * @param String requirementIdentifier
194 */
195 protected Job getJobCglCheckGitCommit(String requirementIdentifier) {
196 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
197 .description("Check coding guidelines by executing Build/Scripts/cglFixMyCommit.sh script")
198 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
199 .tasks(
200 this.getTaskGitCloneRepository(),
201 this.getTaskGitCherryPick(),
202 this.getTaskComposerInstall(requirementIdentifier),
203 new ScriptTask()
204 .description("Execute cgl check script")
205 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
206 .inlineBody(
207 this.getScriptTaskBashInlineBody() +
208 "function cglFixMyCommit() {\n" +
209 " docker run \\\n" +
210 " -u ${HOST_UID} \\\n" +
211 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
212 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
213 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
214 " --rm \\\n" +
215 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
216 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/cglFixMyCommit.sh $*\"\n" +
217 "}\n" +
218 "\n" +
219 "cglFixMyCommit dryrun\n"
220 )
221 )
222 .requirements(
223 this.getRequirementDocker10()
224 )
225 .cleanWorkingDirectory(true);
226 }
227
228 /**
229 * Job checking CGL of all core php files
230 *
231 * @param int stageNumber
232 * @param String requirementIdentifier
233 * @param Task composerTask
234 */
235 protected Job getJobCglCheckFullCore(int stageNumber, String requirementIdentifier, Task composerTask) {
236 return new Job("Integration CGL " + stageNumber, new BambooKey("CGLCHECK" + stageNumber))
237 .description("Check coding guidelines of full core")
238 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
239 .tasks(
240 this.getTaskGitCloneRepository(),
241 this.getTaskGitCherryPick(),
242 composerTask,
243 new ScriptTask()
244 .description("Execute cgl check")
245 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
246 .inlineBody(
247 this.getScriptTaskBashInlineBody() +
248 "function phpCsFixer() {\n" +
249 " docker run \\\n" +
250 " -u ${HOST_UID} \\\n" +
251 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
252 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
253 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
254 " --rm \\\n" +
255 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
256 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/php-cs-fixer $*\"\n" +
257 "}\n" +
258 "\n" +
259 "phpCsFixer fix -v --dry-run --path-mode intersection --config=Build/.php_cs typo3/\n" +
260 "exit $?"
261 )
262 )
263 .requirements(
264 this.getRequirementDocker10()
265 )
266 .cleanWorkingDirectory(true);
267 }
268
269 /**
270 * Job acceptance test installs system on mariadb
271 *
272 * @param int stageNumber
273 * @param String requirementIdentifier
274 * @param Task composerTask
275 */
276 protected Job getJobAcceptanceTestInstallMysql(int stageNumber, String requirementIdentifier, Task composerTask) {
277 return new Job("Accept inst my " + stageNumber + " " + requirementIdentifier, new BambooKey("ACINSTMY" +stageNumber + requirementIdentifier))
278 .description("Install TYPO3 on mariadb and load introduction package " + requirementIdentifier)
279 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
280 .tasks(
281 this.getTaskGitCloneRepository(),
282 this.getTaskGitCherryPick(),
283 composerTask,
284 this.getTaskPrepareAcceptanceTest(),
285 this.getTaskDockerDependenciesAcceptanceInstallMariadb10(),
286 new ScriptTask()
287 .description("Install TYPO3 on mariadb 10")
288 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
289 .inlineBody(
290 this.getScriptTaskBashInlineBody() +
291 "function codecept() {\n" +
292 " docker run \\\n" +
293 " -u ${HOST_UID} \\\n" +
294 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
295 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
296 " -e typo3InstallMysqlDatabaseHost=${typo3InstallMysqlDatabaseHost} \\\n" +
297 " -e typo3InstallMysqlDatabaseName=${typo3InstallMysqlDatabaseName} \\\n" +
298 " -e typo3InstallMysqlDatabaseUsername=${typo3InstallMysqlDatabaseUsername} \\\n" +
299 " -e typo3InstallMysqlDatabasePassword=${typo3InstallMysqlDatabasePassword} \\\n" +
300 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
301 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
302 " --rm \\\n" +
303 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
304 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
305 "}\n" +
306 "\n" +
307 "codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=mysql --xml reports.xml --html reports.html\n"
308 )
309 )
310 .finalTasks(
311 this.getTaskStopDockerDependencies(),
312 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
313 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
314 )
315 .artifacts(new Artifact()
316 .name("Test Report")
317 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
318 .shared(false)
319 )
320 .requirements(
321 this.getRequirementDocker10()
322 )
323 .cleanWorkingDirectory(true);
324 }
325
326 /**
327 * Job acceptance test installs system and introduction package on pgsql
328 *
329 * @param int stageNumber
330 * @param String requirementIdentifier
331 * @param Task composerTask
332 */
333 protected Job getJobAcceptanceTestInstallPgsql(int stageNumber, String requirementIdentifier, Task composerTask) {
334 return new Job("Accept inst pg " + stageNumber + " " + requirementIdentifier, new BambooKey("ACINSTPG" + stageNumber + requirementIdentifier))
335 .description("Install TYPO3 on pgsql and load introduction package " + requirementIdentifier)
336 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
337 .tasks(
338 this.getTaskGitCloneRepository(),
339 this.getTaskGitCherryPick(),
340 composerTask,
341 this.getTaskPrepareAcceptanceTest(),
342 this.getTaskDockerDependenciesAcceptanceInstallPostgres10(),
343 new ScriptTask()
344 .description("Install TYPO3 on postgresql 10")
345 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
346 .inlineBody(
347 this.getScriptTaskBashInlineBody() +
348 "function codecept() {\n" +
349 " docker run \\\n" +
350 " -u ${HOST_UID} \\\n" +
351 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
352 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
353 " -e typo3InstallPostgresqlDatabaseHost=${typo3InstallPostgresqlDatabaseHost} \\\n" +
354 " -e typo3InstallPostgresqlDatabaseName=${typo3InstallPostgresqlDatabaseName} \\\n" +
355 " -e typo3InstallPostgresqlDatabaseUsername=${typo3InstallPostgresqlDatabaseUsername} \\\n" +
356 " -e typo3InstallPostgresqlDatabasePassword=${typo3InstallPostgresqlDatabasePassword} \\\n" +
357 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
358 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
359 " --rm \\\n" +
360 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
361 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
362 "}\n" +
363 "\n" +
364 "codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=postgresql --xml reports.xml --html reports.html\n"
365 )
366 )
367 .finalTasks(
368 this.getTaskStopDockerDependencies(),
369 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
370 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
371 )
372 .artifacts(new Artifact()
373 .name("Test Report")
374 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
375 .shared(false)
376 )
377 .requirements(
378 this.getRequirementDocker10()
379 )
380 .cleanWorkingDirectory(true);
381 }
382
383 /**
384 * Job acceptance test installs system and introduction package on sqlite
385 *
386 * @param int stageNumber
387 * @param String requirementIdentifier
388 * @param Task composerTask
389 */
390 protected Job getJobAcceptanceTestInstallSqlite(int stageNumber, String requirementIdentifier, Task composerTask) {
391 return new Job("Accept inst sq " + stageNumber + " " + requirementIdentifier, new BambooKey("ACINSTSQ" + stageNumber + requirementIdentifier))
392 .description("Install TYPO3 on sqlite and load introduction package " + requirementIdentifier)
393 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
394 .tasks(
395 this.getTaskGitCloneRepository(),
396 this.getTaskGitCherryPick(),
397 composerTask,
398 this.getTaskPrepareAcceptanceTest(),
399 this.getTaskDockerDependenciesAcceptanceInstallSqlite(),
400 new ScriptTask()
401 .description("Install TYPO3 on sqlite")
402 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
403 .inlineBody(
404 this.getScriptTaskBashInlineBody() +
405 "function codecept() {\n" +
406 " docker run \\\n" +
407 " -u ${HOST_UID} \\\n" +
408 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
409 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
410 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
411 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
412 " --rm \\\n" +
413 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
414 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
415 "}\n" +
416 "\n" +
417 "codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=sqlite --xml reports.xml --html reports.html\n"
418 )
419 )
420 .finalTasks(
421 this.getTaskStopDockerDependencies(),
422 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
423 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
424 )
425 .artifacts(new Artifact()
426 .name("Test Report")
427 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
428 .shared(false)
429 )
430 .requirements(
431 this.getRequirementDocker10()
432 )
433 .cleanWorkingDirectory(true);
434 }
435
436 /**
437 * Jobs for mysql based acceptance tests
438 *
439 * @param int stageNumber
440 * @param int numberOfChunks
441 * @param String requirementIdentifier
442 * @param Task composerTask
443 */
444 protected ArrayList<Job> getJobsAcceptanceTestsBackendMysql(int stageNumber, int numberOfChunks, String requirementIdentifier, Task composerTask) {
445 ArrayList<Job> jobs = new ArrayList<Job>();
446
447 for (int i=1; i<=numberOfChunks; i++) {
448 String formattedI = "" + i;
449 if (i < 10) {
450 formattedI = "0" + i;
451 }
452 jobs.add(new Job("Accept my " + stageNumber + " " + requirementIdentifier + " " + formattedI, new BambooKey("ACMY" + stageNumber + requirementIdentifier + formattedI))
453 .description("Run acceptance tests" + requirementIdentifier)
454 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
455 .tasks(
456 this.getTaskGitCloneRepository(),
457 this.getTaskGitCherryPick(),
458 composerTask,
459 this.getTaskPrepareAcceptanceTest(),
460 this.getTaskDockerDependenciesAcceptanceBackendMariadb10(),
461 new ScriptTask()
462 .description("Split acceptance tests")
463 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
464 .inlineBody(
465 this.getScriptTaskBashInlineBody() +
466 "function splitAcceptanceTests() {\n" +
467 " docker run \\\n" +
468 " -u ${HOST_UID} \\\n" +
469 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
470 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
471 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
472 " --rm \\\n" +
473 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
474 " bin/bash -c \"cd ${PWD}; ./" + this.testingFrameworkBuildPath + "Scripts/splitAcceptanceTests.php $*\"\n" +
475 "}\n" +
476 "\n" +
477 "splitAcceptanceTests " + numberOfChunks + " -v"
478 ),
479 new ScriptTask()
480 .description("Execute codeception acceptance suite group " + formattedI)
481 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
482 .inlineBody(
483 this.getScriptTaskBashInlineBody() +
484 "function codecept() {\n" +
485 " docker run \\\n" +
486 " -u ${HOST_UID} \\\n" +
487 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
488 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
489 " -e typo3DatabaseName=func_test \\\n" +
490 " -e typo3DatabaseUsername=root \\\n" +
491 " -e typo3DatabasePassword=funcp \\\n" +
492 " -e typo3DatabaseHost=mariadb10 \\\n" +
493 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
494 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
495 " --rm \\\n" +
496 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
497 " bin/bash -c \"cd ${PWD}; ./bin/codecept $*\"\n" +
498 "}\n" +
499 "\n" +
500 "codecept run Backend -d -g AcceptanceTests-Job-" + i + " -c typo3/sysext/core/Tests/codeception.yml --xml reports.xml --html reports.html\n"
501 )
502 )
503 .finalTasks(
504 this.getTaskStopDockerDependencies(),
505 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
506 .resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml")
507 )
508 .artifacts(new Artifact()
509 .name("Test Report")
510 .copyPattern("typo3temp/var/tests/AcceptanceReports/")
511 .shared(false)
512 )
513 .requirements(
514 this.getRequirementDocker10()
515 )
516 .cleanWorkingDirectory(true)
517 );
518 }
519
520 return jobs;
521 }
522
523 /**
524 * Jobs for mysql based functional tests
525 *
526 * @param int stageNumber
527 * @param int numberOfChunks
528 * @param String requirementIdentifier
529 * @param Task composerTask
530 */
531 protected ArrayList<Job> getJobsFunctionalTestsMysql(int stageNumber, int numberOfChunks, String requirementIdentifier, Task composerTask) {
532 ArrayList<Job> jobs = new ArrayList<Job>();
533
534 for (int i=1; i<=numberOfChunks; i++) {
535 String formattedI = "" + i;
536 if (i < 10) {
537 formattedI = "0" + i;
538 }
539 jobs.add(new Job("Func mysql " + stageNumber + " " + requirementIdentifier + " " + formattedI, new BambooKey("FMY" + stageNumber + requirementIdentifier + formattedI))
540 .description("Run functional tests on mysql DB " + requirementIdentifier)
541 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
542 .tasks(
543 this.getTaskGitCloneRepository(),
544 this.getTaskGitCherryPick(),
545 composerTask,
546 this.getTaskDockerDependenciesFunctionalMariadb10(),
547 this.getTaskSplitFunctionalJobs(numberOfChunks, requirementIdentifier),
548 new ScriptTask()
549 .description("Run phpunit with functional chunk " + formattedI)
550 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
551 .inlineBody(
552 this.getScriptTaskBashInlineBody() +
553 "function phpunit() {\n" +
554 " docker run \\\n" +
555 " -u ${HOST_UID} \\\n" +
556 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
557 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
558 " -e typo3DatabaseName=func_test \\\n" +
559 " -e typo3DatabaseUsername=root \\\n" +
560 " -e typo3DatabasePassword=funcp \\\n" +
561 " -e typo3DatabaseHost=mariadb10 \\\n" +
562 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
563 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
564 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
565 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
566 " --rm \\\n" +
567 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
568 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
569 "}\n" +
570 "\n" +
571 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
572 )
573 )
574 .finalTasks(
575 this.getTaskStopDockerDependencies(),
576 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
577 .resultDirectories("test-reports/phpunit.xml")
578 )
579 .requirements(
580 this.getRequirementDocker10()
581 )
582 .cleanWorkingDirectory(true)
583 );
584 }
585
586 return jobs;
587 }
588
589 /**
590 * Jobs for mssql based functional tests
591 *
592 * @param int stageNumber
593 * @param int numberOfChunks
594 * @param String requirementIdentifier
595 * @param Task composerTask
596 */
597 protected ArrayList<Job> getJobsFunctionalTestsMssql(int stageNumber, int numberOfChunks, String requirementIdentifier, Task composerTask) {
598 ArrayList<Job> jobs = new ArrayList<Job>();
599
600 for (int i=1; i<=numberOfChunks; i++) {
601 String formattedI = "" + i;
602 if (i < 10) {
603 formattedI = "0" + i;
604 }
605 jobs.add(new Job("Func mssql " + stageNumber + " " + requirementIdentifier + " " + formattedI, new BambooKey("FMS" + stageNumber + requirementIdentifier + formattedI))
606 .description("Run functional tests on mysql DB " + requirementIdentifier)
607 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
608 .tasks(
609 this.getTaskGitCloneRepository(),
610 this.getTaskGitCherryPick(),
611 composerTask,
612 this.getTaskDockerDependenciesFunctionalMssql(),
613 this.getTaskSplitFunctionalJobs(numberOfChunks, requirementIdentifier),
614 new ScriptTask()
615 .description("Run phpunit with functional chunk " + formattedI)
616 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
617 .inlineBody(
618 this.getScriptTaskBashInlineBody() +
619 "function phpunit() {\n" +
620 " docker run \\\n" +
621 " -u ${HOST_UID} \\\n" +
622 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
623 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
624 " -e typo3DatabaseDriver=sqlsrv \\\n" +
625 " -e typo3DatabaseName=func \\\n" +
626 " -e typo3DatabasePassword=Test1234! \\\n" +
627 " -e typo3DatabaseUsername=SA \\\n" +
628 " -e typo3DatabaseHost=localhost \\\n" +
629 " -e typo3DatabasePort=1433 \\\n" +
630 " -e typo3DatabaseCharset=utf-8 \\\n" +
631 " -e typo3DatabaseHost=mssql2017cu9 \\\n" +
632 " -e typo3TestingRedisHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_redis4_1 \\\n" +
633 " -e typo3TestingMemcachedHost=${BAMBOO_COMPOSE_PROJECT_NAME}sib_memcached1-5_1 \\\n" +
634 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
635 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
636 " --rm \\\n" +
637 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
638 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
639 "}\n" +
640 "\n" +
641 "phpunit --exclude-group not-mssql --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
642 )
643 )
644 .finalTasks(
645 this.getTaskStopDockerDependencies(),
646 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
647 .resultDirectories("test-reports/phpunit.xml")
648 )
649 .requirements(
650 this.getRequirementDocker10()
651 )
652 .cleanWorkingDirectory(true)
653 );
654 }
655
656 return jobs;
657 }
658
659 /**
660 * Jobs for pgsql based functional tests
661 *
662 * @param int stageNumber
663 * @param int numberOfChunks
664 * @param String requirementIdentifier
665 * @param Task composerTask
666 */
667 protected ArrayList<Job> getJobsFunctionalTestsPgsql(int stageNumber, int numberOfChunks, String requirementIdentifier, Task composerTask) {
668 ArrayList<Job> jobs = new ArrayList<Job>();
669
670 for (int i=1; i<=numberOfChunks; i++) {
671 String formattedI = "" + i;
672 if (i < 10) {
673 formattedI = "0" + i;
674 }
675 jobs.add(new Job("Func pgsql " + stageNumber + " " + requirementIdentifier + " " + formattedI, new BambooKey("FPG" + stageNumber + requirementIdentifier + formattedI))
676 .description("Run functional tests on pgsql DB " + requirementIdentifier)
677 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
678 .tasks(
679 this.getTaskGitCloneRepository(),
680 this.getTaskGitCherryPick(),
681 composerTask,
682 this.getTaskDockerDependenciesFunctionalPostgres10(),
683 this.getTaskSplitFunctionalJobs(numberOfChunks, requirementIdentifier),
684 new ScriptTask()
685 .description("Run phpunit with functional chunk " + formattedI)
686 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
687 .inlineBody(
688 this.getScriptTaskBashInlineBody() +
689 "function phpunit() {\n" +
690 " docker run \\\n" +
691 " -u ${HOST_UID} \\\n" +
692 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
693 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
694 " -e typo3DatabaseDriver=pdo_pgsql \\\n" +
695 " -e typo3DatabaseName=bamboo \\\n" +
696 " -e typo3DatabaseUsername=bamboo \\\n" +
697 " -e typo3DatabaseHost=postgres10 \\\n" +
698 " -e typo3DatabasePassword=funcp \\\n" +
699 " -e typo3TestingRedisHost=redis4 \\\n" +
700 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
701 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
702 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
703 " --rm \\\n" +
704 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
705 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
706 "}\n" +
707 "\n" +
708 "phpunit --exclude-group not-postgres --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
709 )
710 )
711 .finalTasks(
712 this.getTaskStopDockerDependencies(),
713 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
714 .resultDirectories("test-reports/phpunit.xml")
715 )
716 .requirements(
717 this.getRequirementDocker10()
718 )
719 .cleanWorkingDirectory(true)
720 );
721 }
722
723 return jobs;
724 }
725
726 /**
727 * Jobs for sqlite based functional tests
728 *
729 * @param int stageNumber
730 * @param int numberOfChunks
731 * @param String requirementIdentifier
732 * @param Task composerTask
733 */
734 protected ArrayList<Job> getJobsFunctionalTestsSqlite(int stageNumber, int numberOfChunks, String requirementIdentifier, Task composerTask) {
735 ArrayList<Job> jobs = new ArrayList<Job>();
736
737 for (int i=1; i<=numberOfChunks; i++) {
738 String formattedI = "" + i;
739 if (i < 10) {
740 formattedI = "0" + i;
741 }
742 jobs.add(new Job("Func sqlite " + stageNumber + " " + requirementIdentifier + " " + formattedI, new BambooKey("FSL" + stageNumber + requirementIdentifier + formattedI))
743 .description("Run functional tests on sqlite DB " + requirementIdentifier)
744 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
745 .tasks(
746 this.getTaskGitCloneRepository(),
747 this.getTaskGitCherryPick(),
748 composerTask,
749 this.getTaskSplitFunctionalJobs(numberOfChunks, requirementIdentifier),
750 this.getTaskDockerDependenciesFunctionalSqlite(),
751 new ScriptTask()
752 .description("Run phpunit with functional chunk " + formattedI)
753 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
754 .inlineBody(
755 this.getScriptTaskBashInlineBody() +
756 "function phpunit() {\n" +
757 " docker run \\\n" +
758 " -u ${HOST_UID} \\\n" +
759 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
760 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
761 " -e typo3DatabaseDriver=pdo_sqlite \\\n" +
762 " -e typo3TestingRedisHost=redis4 \\\n" +
763 " -e typo3TestingMemcachedHost=memcached1-5 \\\n" +
764 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
765 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
766 " --rm \\\n" +
767 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
768 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
769 "}\n" +
770 "\n" +
771 "phpunit --exclude-group not-sqlite --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "FunctionalTests-Job-" + i + ".xml"
772 )
773 )
774 .finalTasks(
775 this.getTaskStopDockerDependencies(),
776 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
777 .resultDirectories("test-reports/phpunit.xml")
778 )
779 .requirements(
780 this.getRequirementDocker10()
781 )
782 .cleanWorkingDirectory(true)
783 );
784 }
785
786 return jobs;
787 }
788
789 /**
790 * Job with integration test checking for valid @xy annotations
791 *
792 * @param int stageNumber
793 * @param String requirementIdentifier
794 * @param Task composerTask
795 */
796 protected Job getJobIntegrationAnnotations(int stageNumber, String requirementIdentifier, Task composerTask) {
797 return new Job("Integration annotations " + stageNumber, new BambooKey("IANNO" + stageNumber))
798 .description("Check docblock-annotations by executing Build/Scripts/annotationChecker.php script")
799 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
800 .tasks(
801 this.getTaskGitCloneRepository(),
802 this.getTaskGitCherryPick(),
803 composerTask,
804 new ScriptTask()
805 .description("Execute annotations check script")
806 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
807 .inlineBody(
808 this.getScriptTaskBashInlineBody() +
809 "function annotationChecker() {\n" +
810 " docker run \\\n" +
811 " -u ${HOST_UID} \\\n" +
812 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
813 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
814 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
815 " --rm \\\n" +
816 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
817 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/annotationChecker.php $*\"\n" +
818 "}\n" +
819 "\n" +
820 "annotationChecker"
821 )
822 )
823 .requirements(
824 this.getRequirementDocker10()
825 )
826 .cleanWorkingDirectory(true);
827 }
828
829 /**
830 * Job with various smaller script tests
831 *
832 * @param int stageNumber
833 * @param String requirementIdentifier
834 * @param Task composerTask
835 */
836 protected Job getJobIntegrationVarious(int stageNumber, String requirementIdentifier, Task composerTask) {
837 // Exception code checker, xlf, permissions, rst file check
838 return new Job("Integration various " + stageNumber, new BambooKey("CDECC" + stageNumber))
839 .description("Checks duplicate exceptions, git submodules, xlf files, permissions, rst")
840 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
841 .tasks(
842 this.getTaskGitCloneRepository(),
843 this.getTaskGitCherryPick(),
844 composerTask,
845 new ScriptTask()
846 .description("Run duplicate exception code check script")
847 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
848 .inlineBody(
849 this.getScriptTaskBashInlineBody() +
850 "./Build/Scripts/duplicateExceptionCodeCheck.sh\n"
851 ),
852 new ScriptTask()
853 .description("Run git submodule status and verify there are none")
854 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
855 .inlineBody(
856 this.getScriptTaskBashInlineBody() +
857 "if [[ `git submodule status 2>&1 | wc -l` -ne 0 ]]; then\n" +
858 " echo \\\"Found a submodule definition in repository\\\";\n" +
859 " exit 99;\n" +
860 "fi\n"
861 ),
862 new ScriptTask()
863 .description("Run permission check script")
864 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
865 .inlineBody(
866 this.getScriptTaskBashInlineBody() +
867 "./Build/Scripts/checkFilePermissions.sh\n"
868 ),
869 new ScriptTask()
870 .description("Run xlf check")
871 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
872 .inlineBody(
873 this.getScriptTaskBashInlineBody() +
874 "./Build/Scripts/xlfcheck.sh"
875 ),
876 new ScriptTask()
877 .description("Run rst check")
878 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
879 .inlineBody(
880 this.getScriptTaskBashInlineBody() +
881 "function validateRstFiles() {\n" +
882 " docker run \\\n" +
883 " -u ${HOST_UID} \\\n" +
884 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
885 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\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/Scripts/validateRstFiles.php $*\"\n" +
890 "}\n" +
891 "\n" +
892 "validateRstFiles"
893 ),
894 new ScriptTask()
895 .description("Run path length check")
896 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
897 .inlineBody(
898 this.getScriptTaskBashInlineBody() +
899 "./Build/Scripts/maxFilePathLength.sh"
900 ),
901 new ScriptTask()
902 .description("Run extension scanner ReST file reference tester")
903 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
904 .inlineBody(
905 this.getScriptTaskBashInlineBody() +
906 "function extensionScannerRstFileReferences() {\n" +
907 " docker run \\\n" +
908 " -u ${HOST_UID} \\\n" +
909 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
910 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
911 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
912 " --rm \\\n" +
913 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
914 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/extensionScannerRstFileReferences.php $*\"\n" +
915 "}\n" +
916 "\n" +
917 "extensionScannerRstFileReferences"
918 ),
919 new ScriptTask()
920 .description("Run functional fixture csv format checker")
921 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
922 .inlineBody(
923 this.getScriptTaskBashInlineBody() +
924 "function checkIntegrityCsvFixtures() {\n" +
925 " docker run \\\n" +
926 " -u ${HOST_UID} \\\n" +
927 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
928 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
929 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
930 " --rm \\\n" +
931 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
932 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityCsvFixtures.php $*\"\n" +
933 "}\n" +
934 "\n" +
935 "checkIntegrityCsvFixtures"
936 ),
937 new ScriptTask()
938 .description("Run UTF-8 BOM check")
939 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
940 .inlineBody(
941 this.getScriptTaskBashInlineBody() +
942 "function checkIntegrityBom() {\n" +
943 " docker run \\\n" +
944 " -u ${HOST_UID} \\\n" +
945 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
946 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
947 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
948 " --rm \\\n" +
949 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
950 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkUtf8Bom.sh $*\"\n" +
951 "}\n" +
952 "\n" +
953 "checkIntegrityBom"
954 ),
955 new ScriptTask()
956 .description("Run composer.json integrity check")
957 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
958 .inlineBody(
959 this.getScriptTaskBashInlineBody() +
960 "function checkIntegrityComposer() {\n" +
961 " docker run \\\n" +
962 " -u ${HOST_UID} \\\n" +
963 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
964 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
965 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
966 " --rm \\\n" +
967 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
968 " bin/bash -c \"cd ${PWD}; ./Build/Scripts/checkIntegrityComposer.php $*\"\n" +
969 "}\n" +
970 "\n" +
971 "checkIntegrityComposer"
972 )
973 )
974 .requirements(
975 this.getRequirementDocker10()
976 )
977 .cleanWorkingDirectory(true);
978 }
979
980 /**
981 * Job for javascript unit tests
982 *
983 * @param int stageNumber
984 * @param String requirementIdentifier
985 * @param Task composerTask
986 */
987 protected Job getJobUnitJavaScript(int stageNumber, String requirementIdentifier, Task composerTask) {
988 return new Job("Unit JavaScript " + stageNumber, new BambooKey("JSUT" + stageNumber))
989 .description("Run JavaScript unit tests")
990 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
991 .tasks(
992 this.getTaskGitCloneRepository(),
993 this.getTaskGitCherryPick(),
994 composerTask,
995 new ScriptTask()
996 .description("yarn install in Build/ dir")
997 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
998 .inlineBody(
999 this.getScriptTaskBashInlineBody() +
1000 "function yarn() {\n" +
1001 " docker run \\\n" +
1002 " -u ${HOST_UID} \\\n" +
1003 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1004 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1005 " -e HOME=${HOME} \\\n" +
1006 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1007 " --rm \\\n" +
1008 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1009 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
1010 "}\n" +
1011 "\n" +
1012 "yarn install"
1013 ),
1014 new ScriptTask()
1015 .description("Run tests")
1016 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1017 .inlineBody(
1018 this.getScriptTaskBashInlineBody() +
1019 "function karma() {\n" +
1020 " docker run \\\n" +
1021 " -u ${HOST_UID} \\\n" +
1022 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1023 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1024 " -e HOME=${HOME} \\\n" +
1025 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1026 " --rm \\\n" +
1027 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1028 " bin/bash -c \"cd ${PWD}; ./Build/node_modules/karma/bin/karma $*\"\n" +
1029 "}\n" +
1030 "\n" +
1031 "karma start " + this.testingFrameworkBuildPath + "Configuration/JSUnit/karma.conf.js --single-run"
1032 )
1033 )
1034 .finalTasks(
1035 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1036 .resultDirectories("typo3temp/var/tests/*")
1037 )
1038 .artifacts(
1039 new Artifact()
1040 .name("Clover Report (System)")
1041 .copyPattern("**/*.*")
1042 .location("Build/target/site/clover")
1043 .shared(false)
1044 )
1045 .requirements(
1046 this.getRequirementDocker10()
1047 )
1048 .cleanWorkingDirectory(true);
1049 }
1050
1051 /**
1052 * Job for PHP lint
1053 *
1054 * @param String requirementIdentifier
1055 */
1056 protected Job getJobLintPhp(String requirementIdentifier) {
1057 return new Job("Lint " + requirementIdentifier, new BambooKey("L" + requirementIdentifier))
1058 .description("Run php -l on source files for linting " + requirementIdentifier)
1059 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1060 .tasks(
1061 this.getTaskGitCloneRepository(),
1062 this.getTaskGitCherryPick(),
1063 new ScriptTask()
1064 .description("Run php lint")
1065 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1066 .inlineBody(
1067 this.getScriptTaskBashInlineBody() +
1068 "function runLint() {\n" +
1069 " docker run \\\n" +
1070 " -u ${HOST_UID} \\\n" +
1071 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1072 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1073 " -e HOME=${HOME} \\\n" +
1074 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1075 " --rm \\\n" +
1076 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1077 " 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" +
1078 "}\n" +
1079 "\n" +
1080 "runLint"
1081 )
1082 )
1083 .requirements(
1084 this.getRequirementDocker10()
1085 )
1086 .cleanWorkingDirectory(true);
1087 }
1088
1089 /**
1090 * Job for lint npm scss and typescript
1091 *
1092 * @param String requirementIdentifier
1093 */
1094 protected Job getJobLintScssTs(String requirementIdentifier) {
1095 return new Job("Lint scss ts", new BambooKey("LSTS"))
1096 .description("Lint scss and ts, build css and js, test git is clean")
1097 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1098 .tasks(
1099 this.getTaskGitCloneRepository(),
1100 this.getTaskGitCherryPick(),
1101 new ScriptTask()
1102 .description("yarn install in Build/ dir")
1103 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1104 .inlineBody(
1105 this.getScriptTaskBashInlineBody() +
1106 "function yarn() {\n" +
1107 " docker run \\\n" +
1108 " -u ${HOST_UID} \\\n" +
1109 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1110 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1111 " -e HOME=${HOME} \\\n" +
1112 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1113 " --rm \\\n" +
1114 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1115 " bin/bash -c \"cd ${PWD}/Build; yarn $*\"\n" +
1116 "}\n" +
1117 "\n" +
1118 "yarn install"
1119 ),
1120 new ScriptTask()
1121 .description("Run grunt lint")
1122 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1123 .inlineBody(
1124 this.getScriptTaskBashInlineBody() +
1125 "function grunt() {\n" +
1126 " docker run \\\n" +
1127 " -u ${HOST_UID} \\\n" +
1128 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1129 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1130 " -e HOME=${HOME} \\\n" +
1131 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1132 " --rm \\\n" +
1133 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1134 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
1135 "}\n" +
1136 "\n" +
1137 "grunt lint"
1138 ),
1139 new ScriptTask()
1140 .description("Run grunt scripts")
1141 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1142 .inlineBody(
1143 this.getScriptTaskBashInlineBody() +
1144 "function grunt() {\n" +
1145 " docker run \\\n" +
1146 " -u ${HOST_UID} \\\n" +
1147 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1148 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1149 " -e HOME=${HOME} \\\n" +
1150 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1151 " --rm \\\n" +
1152 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1153 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
1154 "}\n" +
1155 "\n" +
1156 "grunt scripts"
1157 ),
1158 new ScriptTask()
1159 .description("Run grunt css")
1160 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1161 .inlineBody(
1162 this.getScriptTaskBashInlineBody() +
1163 "function grunt() {\n" +
1164 " docker run \\\n" +
1165 " -u ${HOST_UID} \\\n" +
1166 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1167 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1168 " -e HOME=${HOME} \\\n" +
1169 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1170 " --rm \\\n" +
1171 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1172 " bin/bash -c \"cd ${PWD}/Build; ./node_modules/grunt/bin/grunt $*\"\n" +
1173 "}\n" +
1174 "\n" +
1175 "grunt css"
1176 ),
1177 new ScriptTask()
1178 .description("git status to check for changed files after build-js")
1179 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1180 .inlineBody(
1181 this.getScriptTaskBashInlineBody() +
1182 "git status | grep -q \"nothing to commit, working tree clean\""
1183 )
1184 )
1185 .requirements(
1186 this.getRequirementDocker10()
1187 )
1188 .cleanWorkingDirectory(true);
1189 }
1190
1191 /**
1192 * Job for unit testing PHP
1193 *
1194 * @param int stageNumber
1195 * @param String requirementIdentifier
1196 * @param Task composerTask
1197 */
1198 protected Job getJobUnitPhp(int stageNumber, String requirementIdentifier, Task composerTask) {
1199 return new Job("Unit " + stageNumber + " " + requirementIdentifier, new BambooKey("UT" + stageNumber + requirementIdentifier))
1200 .description("Run unit tests " + requirementIdentifier)
1201 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1202 .tasks(
1203 this.getTaskGitCloneRepository(),
1204 this.getTaskGitCherryPick(),
1205 composerTask,
1206 new ScriptTask()
1207 .description("Run phpunit")
1208 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1209 .inlineBody(
1210 this.getScriptTaskBashInlineBody() +
1211 "function phpunit() {\n" +
1212 " docker run \\\n" +
1213 " -u ${HOST_UID} \\\n" +
1214 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1215 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1216 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1217 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1218 " --rm \\\n" +
1219 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1220 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
1221 "}\n" +
1222 "\n" +
1223 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml"
1224 )
1225 )
1226 .finalTasks(
1227 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1228 .resultDirectories("test-reports/phpunit.xml")
1229 )
1230 .requirements(
1231 this.getRequirementDocker10()
1232 )
1233 .cleanWorkingDirectory(true);
1234 }
1235
1236 /**
1237 * Job for unit testing deprecated PHP
1238 *
1239 * @param int stageNumber
1240 * @param String requirementIdentifier
1241 * @param Task composerTask
1242 */
1243 protected Job getJobUnitDeprecatedPhp(int stageNumber, String requirementIdentifier, Task composerTask) {
1244 return new Job("Unit deprecated " + stageNumber + " " + requirementIdentifier, new BambooKey("UTD" + stageNumber + requirementIdentifier))
1245 .description("Run deprecated unit tests " + requirementIdentifier)
1246 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1247 .tasks(
1248 this.getTaskGitCloneRepository(),
1249 this.getTaskGitCherryPick(),
1250 composerTask,
1251 new ScriptTask()
1252 .description("Run phpunit")
1253 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1254 .inlineBody(
1255 this.getScriptTaskBashInlineBody() +
1256 "function phpunit() {\n" +
1257 " docker run \\\n" +
1258 " -u ${HOST_UID} \\\n" +
1259 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1260 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1261 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1262 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1263 " --rm \\\n" +
1264 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1265 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
1266 "}\n" +
1267 "\n" +
1268 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTestsDeprecated.xml"
1269 )
1270 )
1271 .finalTasks(
1272 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1273 .resultDirectories("test-reports/phpunit.xml")
1274 )
1275 .requirements(
1276 this.getRequirementDocker10()
1277 )
1278 .cleanWorkingDirectory(true);
1279 }
1280
1281 /**
1282 * Jobs for unit testing PHP in random test order
1283 *
1284 * @param int stageNumber
1285 * @param int numberOfRuns
1286 * @param String requirementIdentifier
1287 * @param Task composerTask
1288 */
1289 protected ArrayList<Job> getJobUnitPhpRandom(int stageNumber, int numberOfRuns, String requirementIdentifier, Task composerTask) {
1290 ArrayList<Job> jobs = new ArrayList<Job>();
1291
1292 for (int i=1; i<=numberOfRuns; i++) {
1293 jobs.add(new Job("Unit " + stageNumber + " " + requirementIdentifier + " random " + i, new BambooKey("UTR" + stageNumber + requirementIdentifier + i))
1294 .description("Run unit tests on " + requirementIdentifier + " in random order 0" + i)
1295 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1296 .tasks(
1297 this.getTaskGitCloneRepository(),
1298 this.getTaskGitCherryPick(),
1299 composerTask,
1300 new ScriptTask()
1301 .description("Run phpunit-randomizer")
1302 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1303 .inlineBody(
1304 this.getScriptTaskBashInlineBody() +
1305 "function phpunitRandomizer() {\n" +
1306 " docker run \\\n" +
1307 " -u ${HOST_UID} \\\n" +
1308 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1309 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1310 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1311 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1312 " --rm \\\n" +
1313 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1314 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit-randomizer $*\"\n" +
1315 "}\n" +
1316 "\n" +
1317 "phpunitRandomizer --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml --order rand"
1318 )
1319 )
1320 .finalTasks(
1321 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1322 .resultDirectories("test-reports/phpunit.xml")
1323 )
1324 .requirements(
1325 this.getRequirementDocker10()
1326 )
1327 .cleanWorkingDirectory(true)
1328 );
1329 }
1330
1331 return jobs;
1332 }
1333
1334 /**
1335 * Task definition for basic core clone of linked default repository
1336 */
1337 protected Task getTaskGitCloneRepository() {
1338 return new VcsCheckoutTask()
1339 .description("Checkout git core")
1340 .checkoutItems(new CheckoutItem().defaultRepository());
1341 }
1342
1343 /**
1344 * Task definition to cherry pick a patch set from gerrit on top of cloned core
1345 */
1346 protected Task getTaskGitCherryPick() {
1347 return new ScriptTask()
1348 .description("Gerrit cherry pick")
1349 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1350 .inlineBody(
1351 this.getScriptTaskBashInlineBody() +
1352 "CHANGEURL=${bamboo.changeUrl}\n" +
1353 "CHANGEURLID=${CHANGEURL#https://review.typo3.org/}\n" +
1354 "PATCHSET=${bamboo.patchset}\n" +
1355 "\n" +
1356 "if [[ $CHANGEURL ]]; then\n" +
1357 " gerrit-cherry-pick https://review.typo3.org/Packages/TYPO3.CMS $CHANGEURLID/$PATCHSET || exit 1\n" +
1358 "fi\n"
1359 );
1360 }
1361
1362 /**
1363 * Task definition to execute composer install
1364 *
1365 * @param String requirementIdentifier
1366 */
1367 protected Task getTaskComposerInstall(String requirementIdentifier) {
1368 return new ScriptTask()
1369 .description("composer install")
1370 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1371 .inlineBody(
1372 this.getScriptTaskBashInlineBody() +
1373 this.getScriptTaskComposer(requirementIdentifier) +
1374 "composer install -n"
1375 )
1376 .environmentVariables(this.composerRootVersionEnvironment);
1377 }
1378
1379 /**
1380 * Task definition to execute 'composer update --with-dependencies'.
1381 * This will update all dependencies to current possible maximum version.
1382 * Used in nightly to see if we are compatible with updates from dependencies.
1383 *
1384 * We update in 2 steps: First composer install as usual, then update. This
1385 * way it is easy to see which packages are updated in comparison to what is
1386 * currently defined in composer.lock.
1387 *
1388 * @param String requirementIdentifier
1389 */
1390 protected Task getTaskComposerUpdateMax(String requirementIdentifier) {
1391 return new ScriptTask()
1392 .description("composer update --with-dependencies")
1393 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1394 .inlineBody(
1395 this.getScriptTaskBashInlineBody() +
1396 this.getScriptTaskComposer(requirementIdentifier) +
1397 "composer install -n\n" +
1398 "composer update --with-dependencies -n"
1399 )
1400 .environmentVariables(this.composerRootVersionEnvironment);
1401 }
1402
1403 /**
1404 * Task definition to execute 'composer update --prefer-lowest'.
1405 * This will update all dependencies to current possible minimum version.
1406 * Used in nightly to see if we are compatible with lowest possible dependency versions.
1407 *
1408 * We update in 2 steps: First composer install as usual, then update. This
1409 * way it is easy to see which packages are updated in comparison to what is
1410 * currently defined in composer.lock.
1411 *
1412 * @param String requirementIdentifier
1413 */
1414 protected Task getTaskComposerUpdateMin(String requirementIdentifier) {
1415 return new ScriptTask()
1416 .description("composer update --prefer-lowest")
1417 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1418 .inlineBody(
1419 this.getScriptTaskBashInlineBody() +
1420 this.getScriptTaskComposer(requirementIdentifier) +
1421 "composer install -n\n" +
1422 "composer update --prefer-lowest -n"
1423 )
1424 .environmentVariables(this.composerRootVersionEnvironment);
1425 }
1426
1427 /**
1428 * Task to prepare an acceptance test
1429 */
1430 protected Task getTaskPrepareAcceptanceTest() {
1431 return new ScriptTask()
1432 .description("Prepare acceptance test environment")
1433 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1434 .inlineBody(
1435 this.getScriptTaskBashInlineBody() +
1436 "mkdir -p typo3temp/var/tests/\n"
1437 );
1438 }
1439
1440 /**
1441 * Start docker sibling containers to execute acceptance install tests on mariadb
1442 */
1443 protected Task getTaskDockerDependenciesAcceptanceInstallMariadb10() {
1444 return new ScriptTask()
1445 .description("Start docker siblings for acceptance test install mariadb")
1446 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1447 .inlineBody(
1448 this.getScriptTaskBashInlineBody() +
1449 "cd Build/testing-docker/bamboo\n" +
1450 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1451 "docker-compose run start_dependencies_acceptance_install_mariadb10"
1452 );
1453 }
1454
1455 /**
1456 * Start docker sibling containers to execute acceptance install tests on postgres
1457 */
1458 protected Task getTaskDockerDependenciesAcceptanceInstallPostgres10() {
1459 return new ScriptTask()
1460 .description("Start docker siblings for acceptance test install postgres")
1461 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1462 .inlineBody(
1463 this.getScriptTaskBashInlineBody() +
1464 "cd Build/testing-docker/bamboo\n" +
1465 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1466 "docker-compose run start_dependencies_acceptance_install_postgres10"
1467 );
1468 }
1469
1470 /**
1471 * Start docker sibling containers to execute acceptance install tests on sqlite
1472 */
1473 protected Task getTaskDockerDependenciesAcceptanceInstallSqlite() {
1474 return new ScriptTask()
1475 .description("Start docker siblings for acceptance test install sqlite")
1476 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1477 .inlineBody(
1478 this.getScriptTaskBashInlineBody() +
1479 "cd Build/testing-docker/bamboo\n" +
1480 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1481 "docker-compose run start_dependencies_acceptance_install_sqlite"
1482 );
1483 }
1484
1485 /**
1486 * Start docker sibling containers to execute acceptance backend tests on mariadb
1487 */
1488 protected Task getTaskDockerDependenciesAcceptanceBackendMariadb10() {
1489 return new ScriptTask()
1490 .description("Start docker siblings for acceptance test backend mariadb")
1491 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1492 .inlineBody(
1493 this.getScriptTaskBashInlineBody() +
1494 "cd Build/testing-docker/bamboo\n" +
1495 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1496 "docker-compose run start_dependencies_acceptance_backend_mariadb10"
1497 );
1498 }
1499
1500 /**
1501 * Start docker sibling containers to execute functional tests on mariadb
1502 */
1503 protected Task getTaskDockerDependenciesFunctionalMariadb10() {
1504 return new ScriptTask()
1505 .description("Start docker siblings for functional tests on mariadb")
1506 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1507 .inlineBody(
1508 this.getScriptTaskBashInlineBody() +
1509 "cd Build/testing-docker/bamboo\n" +
1510 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1511 "docker-compose run start_dependencies_functional_mariadb10"
1512 );
1513 }
1514
1515 /**
1516 * Start docker sibling containers to execute functional tests on mssql
1517 */
1518 protected Task getTaskDockerDependenciesFunctionalMssql() {
1519 return new ScriptTask()
1520 .description("Start docker siblings for functional tests on mssql")
1521 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1522 .inlineBody(
1523 this.getScriptTaskBashInlineBody() +
1524 "cd Build/testing-docker/bamboo\n" +
1525 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1526 "docker-compose run start_dependencies_functional_mssql"
1527 );
1528 }
1529
1530 /**
1531 * Start docker sibling containers to execute functional tests on postgres
1532 */
1533 protected Task getTaskDockerDependenciesFunctionalPostgres10() {
1534 return new ScriptTask()
1535 .description("Start docker siblings for functional tests on postgres10")
1536 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1537 .inlineBody(
1538 this.getScriptTaskBashInlineBody() +
1539 "cd Build/testing-docker/bamboo\n" +
1540 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1541 "docker-compose run start_dependencies_functional_postgres10"
1542 );
1543 }
1544
1545 /**
1546 * Start docker sibling containers to execute functional tests on sqlite
1547 */
1548 protected Task getTaskDockerDependenciesFunctionalSqlite() {
1549 return new ScriptTask()
1550 .description("Start docker siblings for functional tests on sqlite")
1551 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1552 .inlineBody(
1553 this.getScriptTaskBashInlineBody() +
1554 "cd Build/testing-docker/bamboo\n" +
1555 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1556 "docker-compose run start_dependencies_functional_sqlite"
1557 );
1558 }
1559
1560 /**
1561 * Stop started docker containers
1562 */
1563 protected Task getTaskStopDockerDependencies() {
1564 return new ScriptTask()
1565 .description("Stop docker siblings")
1566 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1567 .inlineBody(
1568 this.getScriptTaskBashInlineBody() +
1569 "cd Build/testing-docker/bamboo\n" +
1570 "docker-compose down -v"
1571 );
1572 }
1573
1574 /**
1575 * Task to split functional jobs into chunks
1576 *
1577 * @param int numberOfJobs
1578 * @param String requirementIdentifier
1579 */
1580 protected Task getTaskSplitFunctionalJobs(int numberOfJobs, String requirementIdentifier) {
1581 return new ScriptTask()
1582 .description("Create list of test files to execute per job")
1583 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1584 .inlineBody(
1585 this.getScriptTaskBashInlineBody() +
1586 "function splitFunctionalTests() {\n" +
1587 " docker run \\\n" +
1588 " -u ${HOST_UID} \\\n" +
1589 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1590 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1591 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1592 " --rm \\\n" +
1593 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1594 " bin/bash -c \"cd ${PWD}; ./" + this.testingFrameworkBuildPath + "Scripts/splitFunctionalTests.php $*\"\n" +
1595 "}\n" +
1596 "\n" +
1597 "splitFunctionalTests " + numberOfJobs + " -v"
1598 );
1599 }
1600
1601 /**
1602 * Requirement for docker 1.0 set by bamboo-agents
1603 */
1604 protected Requirement getRequirementDocker10() {
1605 return new Requirement("system.hasDocker")
1606 .matchValue("1.0")
1607 .matchType(Requirement.MatchType.EQUALS);
1608 }
1609
1610 /**
1611 * A bash header for script tasks forking a bash if needed
1612 */
1613 protected String getScriptTaskBashInlineBody() {
1614 return
1615 "#!/bin/bash\n" +
1616 "\n" +
1617 "if [ \"$(ps -p \"$$\" -o comm=)\" != \"bash\" ]; then\n" +
1618 " bash \"$0\" \"$@\"\n" +
1619 " exit \"$?\"\n" +
1620 "fi\n" +
1621 "\n" +
1622 "set -x\n" +
1623 "\n";
1624 }
1625
1626 /**
1627 * A bash function aliasing 'composer' as docker command
1628 *
1629 * @param String requirementIdentifier
1630 */
1631 protected String getScriptTaskComposer(String requirementIdentifier) {
1632 return
1633 "function composer() {\n" +
1634 " docker run \\\n" +
1635 " -u ${HOST_UID} \\\n" +
1636 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
1637 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1638 " -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} \\\n" +
1639 " -e HOME=${HOME} \\\n" +
1640 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1641 " --rm \\\n" +
1642 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1643 " bin/bash -c \"cd ${PWD}; composer $*\"\n" +
1644 "}\n" +
1645 "\n";
1646 }
1647 }