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