962c8dedcef6d468af422ebad213d9be7199ce16
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / PreMergeSpec.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.AtlassianModule;
20 import com.atlassian.bamboo.specs.api.builders.BambooKey;
21 import com.atlassian.bamboo.specs.api.builders.Variable;
22 import com.atlassian.bamboo.specs.api.builders.notification.AnyNotificationRecipient;
23 import com.atlassian.bamboo.specs.api.builders.notification.Notification;
24 import com.atlassian.bamboo.specs.api.builders.plan.Job;
25 import com.atlassian.bamboo.specs.api.builders.plan.Plan;
26 import com.atlassian.bamboo.specs.api.builders.plan.Stage;
27 import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
28 import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
29 import com.atlassian.bamboo.specs.api.builders.plan.configuration.AllOtherPluginsConfiguration;
30 import com.atlassian.bamboo.specs.api.builders.project.Project;
31 import com.atlassian.bamboo.specs.api.builders.requirement.Requirement;
32 import com.atlassian.bamboo.specs.builders.notification.PlanCompletedNotification;
33 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
34 import com.atlassian.bamboo.specs.builders.trigger.RemoteTrigger;
35 import com.atlassian.bamboo.specs.builders.trigger.RepositoryPollingTrigger;
36 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
37 import com.atlassian.bamboo.specs.util.BambooServer;
38 import com.atlassian.bamboo.specs.util.MapBuilder;
39
40 /**
41 * Core master pre-merge test plan.
42 */
43 @BambooSpec
44 public class PreMergeSpec extends AbstractCoreSpec {
45
46 protected static String planName = "Core master pre-merge";
47 protected static String planKey = "GTC";
48
49 protected int numberOfAcceptanceTestJobs = 8;
50 protected int numberOfFunctionalMysqlJobs = 10;
51 protected int numberOfFunctionalMssqlJobs = 10;
52 protected int numberOfFunctionalPgsqlJobs = 10;
53 protected int numberOfFunctionalSqliteJobs = 10;
54 protected int numberOfUnitRandomOrderJobs = 2;
55
56 /**
57 * Run main to publish plan on Bamboo
58 */
59 public static void main(final String[] args) throws Exception {
60 // By default credentials are read from the '.credentials' file.
61 BambooServer bambooServer = new BambooServer(bambooServerName);
62 bambooServer.publish(new PreMergeSpec().createPlan());
63 bambooServer.publish(new PreMergeSpec().getDefaultPlanPermissions(projectKey, planKey));
64 }
65
66 /**
67 * Core master pre-merge plan is in "TYPO3 core" project of bamboo
68 */
69 Project project() {
70 return new Project().name(projectName).key(projectKey);
71 }
72
73 /**
74 * Returns full Plan definition
75 */
76 Plan createPlan() {
77 // PREPARATION stage
78 ArrayList<Job> jobsPreparationStage = new ArrayList<Job>();
79
80 jobsPreparationStage.add(this.getJobBuildLabels());
81
82 jobsPreparationStage.add(this.getJobCglCheckGitCommit());
83
84 jobsPreparationStage.add(this.getJobComposerValidate());
85
86 Stage stagePreparation = new Stage("Preparation")
87 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
88
89 // MAIN stage
90 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
91
92 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql(this.getRequirementPhpVersion72(), "PHP72"));
93 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(this.getRequirementPhpVersion72(), "PHP72"));
94 jobsMainStage.add(this.getJobAcceptanceTestInstallSqlite(this.getRequirementPhpVersion72(), "PHP72"));
95
96 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, this.getRequirementPhpVersion72(), "PHP72"));
97
98 jobsMainStage.add(this.getJobIntegrationAnnotations());
99
100 jobsMainStage.add(this.getJobIntegrationVarious());
101
102 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion72(), "PHP72"));
103
104 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, this.getRequirementPhpVersion72(), "PHP72"));
105
106 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, this.getRequirementPhpVersion72(), "PHP72"));
107
108 jobsMainStage.addAll(this.getJobsFunctionalTestsSqlite(this.numberOfFunctionalSqliteJobs, this.getRequirementPhpVersion72(), "PHP72"));
109
110 jobsMainStage.add(this.getJobUnitJavaScript());
111
112 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion72(), "PHP72"));
113
114 jobsMainStage.add(this.getJobLintScssTs());
115
116 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion72(), "PHP72"));
117
118 jobsMainStage.add(this.getJobUnitDeprecatedPhp(this.getRequirementPhpVersion72(), "PHP72"));
119
120 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion72(), "PHP72"));
121
122 Stage stageMainStage = new Stage("Main stage")
123 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
124
125 // Compile plan
126 return new Plan(project(), planName, planKey)
127 .description("Execute TYPO3 core master pre-merge tests. Auto generated! See Build/bamboo of core git repository.")
128 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
129 .stages(
130 stagePreparation,
131 stageMainStage
132 )
133 .linkedRepositories("git.typo3.org Core")
134 .triggers(
135 new RepositoryPollingTrigger()
136 .name("Repository polling for post-merge builds"),
137 new RemoteTrigger()
138 .name("Remote trigger for pre-merge builds")
139 .description("Gerrit")
140 .triggerIPAddresses("5.10.165.218,91.184.35.13"))
141 .variables(
142 new Variable("changeUrl", ""),
143 new Variable("patchset", "")
144 )
145 .planBranchManagement(
146 new PlanBranchManagement()
147 .delete(new BranchCleanup())
148 .notificationForCommitters()
149 )
150 .notifications(new Notification()
151 .type(new PlanCompletedNotification())
152 .recipients(new AnyNotificationRecipient(new AtlassianModule("com.atlassian.bamboo.plugins.bamboo-slack:recipient.slack"))
153 .recipientString("https://intercept.typo3.com/index.php")
154 )
155 );
156 }
157
158 /**
159 * Job creating labels needed for intercept communication
160 */
161 protected Job getJobBuildLabels() {
162 return new Job("Create build labels", new BambooKey("CLFB"))
163 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
164 .pluginConfigurations(new AllOtherPluginsConfiguration()
165 .configuration(new MapBuilder()
166 .put("repositoryDefiningWorkingDirectory", -1)
167 .put("custom", new MapBuilder()
168 .put("auto", new MapBuilder()
169 .put("regex", "https:\\/\\/review\\.typo3\\.org\\/(#\\/c\\/)?(\\d+)")
170 .put("label", "change-\\2\\, patchset-${bamboo.patchset}")
171 .build()
172 )
173 .put("buildHangingConfig.enabled", "false")
174 .put("ncover.path", "")
175 .put("clover", new MapBuilder()
176 .put("path", "")
177 .put("license", "")
178 .put("useLocalLicenseKey", "true")
179 .build()
180 )
181 .build()
182 )
183 .build()
184 )
185 )
186 .tasks(
187 new ScriptTask()
188 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
189 .inlineBody("echo \"I'm just here for the labels!\"")
190 )
191 .cleanWorkingDirectory(true);
192 }
193
194 /**
195 * Job checking CGL of last git commit
196 */
197 protected Job getJobCglCheckGitCommit() {
198 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
199 .description("Check coding guidelines by executing Build/Scripts/cglFixMyCommit.sh script")
200 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
201 .tasks(
202 this.getTaskGitCloneRepository(),
203 this.getTaskGitCherryPick(),
204 this.getTaskComposerInstall(),
205 new ScriptTask()
206 .description("Execute cgl check script")
207 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
208 .inlineBody(
209 this.getScriptTaskBashInlineBody() +
210 "./Build/Scripts/cglFixMyCommit.sh dryrun\n"
211 )
212 )
213 .requirements(
214 this.getRequirementPhpVersion72()
215 )
216 .cleanWorkingDirectory(true);
217 }
218 }