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