e00f5ec6f79f0effc329eddde6af9dbd572673d6
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / NightlySpec.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.BambooSpec;
19 import com.atlassian.bamboo.specs.api.builders.BambooKey;
20 import com.atlassian.bamboo.specs.api.builders.Variable;
21 import com.atlassian.bamboo.specs.api.builders.plan.Job;
22 import com.atlassian.bamboo.specs.api.builders.plan.Plan;
23 import com.atlassian.bamboo.specs.api.builders.plan.Stage;
24 import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
25 import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
26 import com.atlassian.bamboo.specs.api.builders.project.Project;
27 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
28 import com.atlassian.bamboo.specs.builders.trigger.ScheduledTrigger;
29 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
30 import com.atlassian.bamboo.specs.util.BambooServer;
31
32 /**
33 * Core master nightly test plan.
34 */
35 @BambooSpec
36 public class NightlySpec extends AbstractCoreSpec {
37
38 protected static String planName = "Core master nightly";
39 protected static String planKey = "GTN";
40
41 protected int numberOfAcceptanceTestJobs = 8;
42 protected int numberOfFunctionalMysqlJobs = 6;
43 protected int numberOfFunctionalMssqlJobs = 6;
44 protected int numberOfFunctionalPgsqlJobs = 6;
45 protected int numberOfFunctionalSqliteJobs = 10;
46 protected int numberOfUnitRandomOrderJobs = 4;
47
48 /**
49 * Run main to publish plan on Bamboo
50 */
51 public static void main(final String[] args) throws Exception {
52 // By default credentials are read from the '.credentials' file.
53 BambooServer bambooServer = new BambooServer(bambooServerName);
54 bambooServer.publish(new NightlySpec().createPlan());
55 bambooServer.publish(new NightlySpec().getDefaultPlanPermissions(projectKey, planKey));
56 }
57
58 /**
59 * Core master pre-merge plan is in "TYPO3 core" project of bamboo
60 */
61 Project project() {
62 return new Project().name(projectName).key(projectKey);
63 }
64
65 /**
66 * Returns full Plan definition
67 */
68 Plan createPlan() {
69 // MAIN stage
70 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
71
72 jobsMainStage.add(this.getJobComposerValidate("PHP72"));
73
74 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql("PHP72"));
75 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql("PHP72"));
76 jobsMainStage.add(this.getJobAcceptanceTestInstallSqlite("PHP72"));
77
78 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, "PHP72"));
79
80 jobsMainStage.add(this.getJobCglCheckFullCore("PHP72"));
81
82 jobsMainStage.add(this.getJobIntegrationAnnotations("PHP72"));
83
84 jobsMainStage.add(this.getJobIntegrationVarious("PHP72"));
85
86 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, "PHP72"));
87 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, "PHP72"));
88 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, "PHP72"));
89 jobsMainStage.addAll(this.getJobsFunctionalTestsSqlite(this.numberOfFunctionalSqliteJobs, "PHP72"));
90
91 jobsMainStage.add(this.getJobUnitJavaScript("PHP72"));
92
93 jobsMainStage.add(this.getJobLintPhp("PHP72"));
94
95 jobsMainStage.add(this.getJobLintScssTs("PHP72"));
96
97 jobsMainStage.add(this.getJobUnitPhp("PHP72"));
98 jobsMainStage.add(this.getJobUnitDeprecatedPhp("PHP72"));
99 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, "PHP72"));
100
101 Stage stageMainStage = new Stage("Main stage")
102 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
103
104
105 // Compile plan
106 return new Plan(project(), planName, planKey)
107 .description("Execute TYPO3 core master nightly tests. Auto generated! See Build/bamboo of core git repository.")
108 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
109 .stages(
110 stageMainStage
111 )
112 .linkedRepositories("git.typo3.org Core")
113 .triggers(
114 new ScheduledTrigger()
115 .name("Scheduled")
116 .description("daily at night")
117 // daily 03:23
118 .cronExpression("0 23 3 ? * *")
119 )
120 .variables(
121 new Variable("changeUrl", ""),
122 new Variable("patchset", "")
123 )
124 .planBranchManagement(
125 new PlanBranchManagement()
126 .delete(new BranchCleanup())
127 .notificationForCommitters()
128 );
129 }
130
131 /**
132 * Job checking CGL of all core php files
133 *
134 * @param String requirementIdentifier
135 */
136 protected Job getJobCglCheckFullCore(String requirementIdentifier) {
137 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
138 .description("Check coding guidelines of full core")
139 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
140 .tasks(
141 this.getTaskGitCloneRepository(),
142 this.getTaskGitCherryPick(),
143 this.getTaskComposerInstall(requirementIdentifier),
144 new ScriptTask()
145 .description("Execute cgl check")
146 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
147 .inlineBody(
148 this.getScriptTaskBashInlineBody() +
149 "function phpCsFixer() {\n" +
150 " docker run \\\n" +
151 " -u ${HOST_UID} \\\n" +
152 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
153 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
154 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
155 " --rm \\\n" +
156 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
157 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/php-cs-fixer $*\"\n" +
158 "}\n" +
159 "\n" +
160 "phpCsFixer fix -v --dry-run --path-mode intersection --config=Build/.php_cs typo3/\n" +
161 "exit $?"
162 )
163 )
164 .requirements(
165 this.getRequirementDocker10()
166 )
167 .cleanWorkingDirectory(true);
168 }
169 }