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