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