209720ce1a880bcdbd9b4b6d9587f87e92891a12
[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.getTaskSplitFunctionalJobs(numberOfChunks, requirementIdentifier),
526 this.getTaskDockerDependenciesFunctionalPostgres10(),
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 this.getTaskDockerDependenciesUnit(),
1003 new ScriptTask()
1004 .description("Run phpunit")
1005 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1006 .inlineBody(
1007 this.getScriptTaskBashInlineBody() +
1008 "function phpunit() {\n" +
1009 " docker run \\\n" +
1010 " -u ${HOST_UID} \\\n" +
1011 " -v /etc/passwd:/etc/passwd \\\n" +
1012 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1013 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1014 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1015 " --rm \\\n" +
1016 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1017 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
1018 "}\n" +
1019 "\n" +
1020 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml"
1021 )
1022 )
1023 .finalTasks(
1024 this.getTaskStopDockerDependencies(),
1025 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1026 .resultDirectories("test-reports/phpunit.xml")
1027 )
1028 .requirements(
1029 this.getRequirementDocker10()
1030 )
1031 .cleanWorkingDirectory(true);
1032 }
1033
1034 /**
1035 * Job for unit testing deprecated PHP
1036 *
1037 * @param String requirementIdentifier
1038 */
1039 protected Job getJobUnitDeprecatedPhp(String requirementIdentifier) {
1040 return new Job("Unit deprecated " + requirementIdentifier, new BambooKey("UTD" + requirementIdentifier))
1041 .description("Run deprecated unit tests " + requirementIdentifier)
1042 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1043 .tasks(
1044 this.getTaskGitCloneRepository(),
1045 this.getTaskGitCherryPick(),
1046 this.getTaskComposerInstall(requirementIdentifier),
1047 this.getTaskDockerDependenciesUnit(),
1048 new ScriptTask()
1049 .description("Run phpunit")
1050 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1051 .inlineBody(
1052 this.getScriptTaskBashInlineBody() +
1053 "function phpunit() {\n" +
1054 " docker run \\\n" +
1055 " -u ${HOST_UID} \\\n" +
1056 " -v /etc/passwd:/etc/passwd \\\n" +
1057 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1058 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1059 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1060 " --rm \\\n" +
1061 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1062 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit $*\"\n" +
1063 "}\n" +
1064 "\n" +
1065 "phpunit --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTestsDeprecated.xml"
1066 )
1067 )
1068 .finalTasks(
1069 this.getTaskStopDockerDependencies(),
1070 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1071 .resultDirectories("test-reports/phpunit.xml")
1072 )
1073 .requirements(
1074 this.getRequirementDocker10()
1075 )
1076 .cleanWorkingDirectory(true);
1077 }
1078
1079 /**
1080 * Jobs for unit testing PHP in random test order
1081 *
1082 * @param int numberOfRuns
1083 * @param String requirementIdentifier
1084 */
1085 protected ArrayList<Job> getJobUnitPhpRandom(int numberOfRuns, String requirementIdentifier) {
1086 ArrayList<Job> jobs = new ArrayList<Job>();
1087
1088 for (int i=1; i<=numberOfRuns; i++) {
1089 jobs.add(new Job("Unit " + requirementIdentifier + " random " + i, new BambooKey("UTR" + requirementIdentifier + i))
1090 .description("Run unit tests on " + requirementIdentifier + " in random order 0" + i)
1091 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
1092 .tasks(
1093 this.getTaskGitCloneRepository(),
1094 this.getTaskGitCherryPick(),
1095 this.getTaskComposerInstall(requirementIdentifier),
1096 this.getTaskDockerDependenciesUnit(),
1097 new ScriptTask()
1098 .description("Run phpunit-randomizer")
1099 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1100 .inlineBody(
1101 this.getScriptTaskBashInlineBody() +
1102 "function phpunitRandomizer() {\n" +
1103 " docker run \\\n" +
1104 " -u ${HOST_UID} \\\n" +
1105 " -v /etc/passwd:/etc/passwd \\\n" +
1106 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1107 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1108 " --network ${BAMBOO_COMPOSE_PROJECT_NAME}_test \\\n" +
1109 " --rm \\\n" +
1110 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1111 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/phpunit-randomizer $*\"\n" +
1112 "}\n" +
1113 "\n" +
1114 "phpunitRandomizer --log-junit test-reports/phpunit.xml -c " + this.testingFrameworkBuildPath + "UnitTests.xml --order rand"
1115 )
1116 )
1117 .finalTasks(
1118 this.getTaskStopDockerDependencies(),
1119 new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
1120 .resultDirectories("test-reports/phpunit.xml")
1121 )
1122 .requirements(
1123 this.getRequirementDocker10()
1124 )
1125 .cleanWorkingDirectory(true)
1126 );
1127 }
1128
1129 return jobs;
1130 }
1131
1132 /**
1133 * Task definition for basic core clone of linked default repository
1134 */
1135 protected Task getTaskGitCloneRepository() {
1136 return new VcsCheckoutTask()
1137 .description("Checkout git core")
1138 .checkoutItems(new CheckoutItem().defaultRepository());
1139 }
1140
1141 /**
1142 * Task definition to cherry pick a patch set from gerrit on top of cloned core
1143 */
1144 protected Task getTaskGitCherryPick() {
1145 return new ScriptTask()
1146 .description("Gerrit cherry pick")
1147 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1148 .inlineBody(
1149 this.getScriptTaskBashInlineBody() +
1150 "CHANGEURL=${bamboo.changeUrl}\n" +
1151 "CHANGEURLID=${CHANGEURL#https://review.typo3.org/}\n" +
1152 "PATCHSET=${bamboo.patchset}\n" +
1153 "\n" +
1154 "if [[ $CHANGEURL ]]; then\n" +
1155 " gerrit-cherry-pick https://review.typo3.org/Packages/TYPO3.CMS $CHANGEURLID/$PATCHSET || exit 1\n" +
1156 "fi\n"
1157 );
1158 }
1159
1160 /**
1161 * Task definition to execute composer install
1162 *
1163 * @param String requirementIdentifier
1164 */
1165 protected Task getTaskComposerInstall(String requirementIdentifier) {
1166 return new ScriptTask()
1167 .description("composer install")
1168 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1169 .inlineBody(
1170 this.getScriptTaskBashInlineBody() +
1171 this.getScriptTaskComposer(requirementIdentifier) +
1172 "composer install -n"
1173 )
1174 .environmentVariables(this.composerRootVersionEnvironment);
1175 }
1176
1177 /**
1178 * Task to prepare an acceptance test
1179 */
1180 protected Task getTaskPrepareAcceptanceTest() {
1181 return new ScriptTask()
1182 .description("Prepare acceptance test environment")
1183 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1184 .inlineBody(
1185 this.getScriptTaskBashInlineBody() +
1186 "mkdir -p typo3temp/var/tests/\n"
1187 );
1188 }
1189
1190 /**
1191 * Start docker sibling containers to execute acceptance tests on mariadb
1192 */
1193 protected Task getTaskDockerDependenciesAcceptanceInstallMariadb10() {
1194 return new ScriptTask()
1195 .description("Start docker siblings for acceptance test install mariadb")
1196 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1197 .inlineBody(
1198 this.getScriptTaskBashInlineBody() +
1199 "cd Build/testing-docker/bamboo\n" +
1200 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1201 "docker-compose run start_dependencies_acceptance_install_mariadb10"
1202 );
1203 }
1204
1205 /**
1206 * Start docker sibling containers to execute acceptance tests on postgres
1207 */
1208 protected Task getTaskDockerDependenciesAcceptanceInstallPostgres10() {
1209 return new ScriptTask()
1210 .description("Start docker siblings for acceptance test install postgres")
1211 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1212 .inlineBody(
1213 this.getScriptTaskBashInlineBody() +
1214 "cd Build/testing-docker/bamboo\n" +
1215 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1216 "docker-compose run start_dependencies_acceptance_install_postgres10"
1217 );
1218 }
1219
1220 /**
1221 * Start docker sibling containers to execute acceptance tests on sqlite
1222 */
1223 protected Task getTaskDockerDependenciesAcceptanceInstallSqlite() {
1224 return new ScriptTask()
1225 .description("Start docker siblings for acceptance test install sqlite")
1226 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1227 .inlineBody(
1228 this.getScriptTaskBashInlineBody() +
1229 "cd Build/testing-docker/bamboo\n" +
1230 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1231 "docker-compose run start_dependencies_acceptance_install_sqlite"
1232 );
1233 }
1234
1235 /**
1236 * Start docker sibling containers to execute functional tests on mariadb
1237 */
1238 protected Task getTaskDockerDependenciesFunctionalMariadb10() {
1239 return new ScriptTask()
1240 .description("Start docker siblings for functional tests on mariadb")
1241 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1242 .inlineBody(
1243 this.getScriptTaskBashInlineBody() +
1244 "cd Build/testing-docker/bamboo\n" +
1245 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1246 "docker-compose run start_dependencies_functional_mariadb10"
1247 );
1248 }
1249
1250 /**
1251 * Start docker sibling containers to execute functional tests on postgres
1252 */
1253 protected Task getTaskDockerDependenciesFunctionalPostgres10() {
1254 return new ScriptTask()
1255 .description("Start docker siblings for functional tests on postgres10")
1256 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1257 .inlineBody(
1258 this.getScriptTaskBashInlineBody() +
1259 "cd Build/testing-docker/bamboo\n" +
1260 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1261 "docker-compose run start_dependencies_functional_postgres10"
1262 );
1263 }
1264
1265 /**
1266 * Start docker sibling containers to execute functional tests on sqlite
1267 */
1268 protected Task getTaskDockerDependenciesFunctionalSqlite() {
1269 return new ScriptTask()
1270 .description("Start docker siblings for functional tests on sqlite")
1271 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1272 .inlineBody(
1273 this.getScriptTaskBashInlineBody() +
1274 "cd Build/testing-docker/bamboo\n" +
1275 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1276 "docker-compose run start_dependencies_functional_sqlite"
1277 );
1278 }
1279
1280 /**
1281 * Start docker sibling containers to execute unit tests
1282 */
1283 protected Task getTaskDockerDependenciesUnit() {
1284 return new ScriptTask()
1285 .description("Start docker siblings for unit tests")
1286 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1287 .inlineBody(
1288 this.getScriptTaskBashInlineBody() +
1289 "cd Build/testing-docker/bamboo\n" +
1290 "echo COMPOSE_PROJECT_NAME=${BAMBOO_COMPOSE_PROJECT_NAME}sib > .env\n" +
1291 "docker-compose run start_dependencies_unit"
1292 );
1293 }
1294
1295 /**
1296 * Stop started docker containers
1297 */
1298 protected Task getTaskStopDockerDependencies() {
1299 return new ScriptTask()
1300 .description("Stop docker siblings")
1301 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1302 .inlineBody(
1303 this.getScriptTaskBashInlineBody() +
1304 "cd Build/testing-docker/bamboo\n" +
1305 "docker-compose down -v"
1306 );
1307 }
1308
1309 /**
1310 * Task to split functional jobs into chunks
1311 *
1312 * @param int numberOfJobs
1313 * @param String requirementIdentifier
1314 */
1315 protected Task getTaskSplitFunctionalJobs(int numberOfJobs, String requirementIdentifier) {
1316 return new ScriptTask()
1317 .description("Create list of test files to execute per job")
1318 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
1319 .inlineBody(
1320 this.getScriptTaskBashInlineBody() +
1321 "function splitFunctionalTests() {\n" +
1322 " docker run \\\n" +
1323 " -u ${HOST_UID} \\\n" +
1324 " -v /etc/passwd:/etc/passwd \\\n" +
1325 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1326 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1327 " --rm \\\n" +
1328 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1329 " bin/bash -c \"cd ${PWD}; ./" + this.testingFrameworkBuildPath + "Scripts/splitFunctionalTests.php $*\"\n" +
1330 "}\n" +
1331 "\n" +
1332 "splitFunctionalTests " + numberOfJobs + " -v"
1333 );
1334 }
1335
1336 /**
1337 * Requirement for docker 1.0 set by bamboo-agents
1338 */
1339 protected Requirement getRequirementDocker10() {
1340 return new Requirement("system.hasDocker")
1341 .matchValue("1.0")
1342 .matchType(Requirement.MatchType.EQUALS);
1343 }
1344
1345 /**
1346 * A bash header for script tasks forking a bash if needed
1347 */
1348 protected String getScriptTaskBashInlineBody() {
1349 return
1350 "#!/bin/bash\n" +
1351 "\n" +
1352 "if [ \"$(ps -p \"$$\" -o comm=)\" != \"bash\" ]; then\n" +
1353 " bash \"$0\" \"$@\"\n" +
1354 " exit \"$?\"\n" +
1355 "fi\n" +
1356 "\n" +
1357 "set -x\n" +
1358 "\n";
1359 }
1360
1361 /**
1362 * A bash function aliasing 'composer' as docker command
1363 *
1364 * @param String requirementIdentifier
1365 */
1366 protected String getScriptTaskComposer(String requirementIdentifier) {
1367 return
1368 "function composer() {\n" +
1369 " docker run \\\n" +
1370 " -u ${HOST_UID} \\\n" +
1371 " -v /etc/passwd:/etc/passwd \\\n" +
1372 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
1373 " -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} \\\n" +
1374 " -e HOME=${HOME} \\\n" +
1375 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
1376 " --rm \\\n" +
1377 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
1378 " bin/bash -c \"cd ${PWD}; composer $*\"\n" +
1379 "}\n" +
1380 "\n";
1381 }
1382 }