819ecd201f0d902f7f233a74c8f134c95a12040a
[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 8.7 pre-merge test plan.
42 */
43 @BambooSpec
44 public class PreMergeSpec extends AbstractCoreSpec {
45
46 protected static String planName = "Core 8.7 pre-merge";
47 protected static String planKey = "GTC87";
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 = 2;
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 8.7 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.getRequirementPhpVersion70Or71(), "PHP7071"));
92 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(this.getRequirementPhpVersion70Or71(), "PHP7071"));
93
94 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
95
96 jobsMainStage.add(this.getJobIntegrationVarious());
97
98 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
99
100 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
101
102 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
103
104 jobsMainStage.add(this.getJobUnitJavaScript());
105
106 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion70(), "PHP70"));
107 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion71(), "PHP71"));
108
109 jobsMainStage.add(this.getJobLintScssTs());
110
111 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion70(), "PHP70"));
112 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion71(), "PHP71"));
113
114 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion70(), "PHP70"));
115 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion71(), "PHP71"));
116
117 Stage stageMainStage = new Stage("Main stage")
118 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
119
120 // Compile plan
121 return new Plan(project(), planName, planKey)
122 .description("Execute TYPO3 core 8.7 pre-merge tests. Auto generated! See Build/bamboo of core git repository.")
123 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
124 .stages(
125 stagePreparation,
126 stageMainStage
127 )
128 .linkedRepositories("git.typo3.org Core 8.7")
129 .triggers(
130 new RepositoryPollingTrigger()
131 .name("Repository polling for post-merge builds"),
132 new RemoteTrigger()
133 .name("Remote trigger for pre-merge builds")
134 .description("Gerrit")
135 .triggerIPAddresses("5.10.165.218,91.184.35.13"))
136 .variables(
137 new Variable("changeUrl", ""),
138 new Variable("patchset", "")
139 )
140 .planBranchManagement(
141 new PlanBranchManagement()
142 .delete(new BranchCleanup())
143 .notificationForCommitters()
144 )
145 .notifications(new Notification()
146 .type(new PlanCompletedNotification())
147 .recipients(new AnyNotificationRecipient(new AtlassianModule("com.atlassian.bamboo.plugins.bamboo-slack:recipient.slack"))
148 .recipientString("https://intercept.typo3.com/index.php")
149 )
150 );
151 }
152
153 /**
154 * Job creating labels needed for intercept communication
155 */
156 protected Job getJobBuildLabels() {
157 return new Job("Create build labels", new BambooKey("CLFB"))
158 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
159 .pluginConfigurations(new AllOtherPluginsConfiguration()
160 .configuration(new MapBuilder()
161 .put("repositoryDefiningWorkingDirectory", -1)
162 .put("custom", new MapBuilder()
163 .put("auto", new MapBuilder()
164 .put("regex", "https:\\/\\/review\\.typo3\\.org\\/(#\\/c\\/)?(\\d+)")
165 .put("label", "change-\\2\\, patchset-${bamboo.patchset}")
166 .build()
167 )
168 .put("buildHangingConfig.enabled", "false")
169 .put("ncover.path", "")
170 .put("clover", new MapBuilder()
171 .put("path", "")
172 .put("license", "")
173 .put("useLocalLicenseKey", "true")
174 .build()
175 )
176 .build()
177 )
178 .build()
179 )
180 )
181 .tasks(
182 new ScriptTask()
183 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
184 .inlineBody("echo \"I'm just here for the labels!\"")
185 )
186 .cleanWorkingDirectory(true);
187 }
188
189 /**
190 * Job checking CGL of last git commit
191 */
192 protected Job getJobCglCheckGitCommit() {
193 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
194 .description("Check coding guidelines by executing Build/Scripts/cglFixMyCommit.sh script")
195 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
196 .tasks(
197 this.getTaskGitCloneRepository(),
198 this.getTaskGitCherryPick(),
199 this.getTaskComposerInstall(),
200 new ScriptTask()
201 .description("Execute cgl check script")
202 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
203 .inlineBody(
204 this.getScriptTaskBashInlineBody() +
205 "./Build/Scripts/cglFixMyCommit.sh dryrun\n"
206 )
207 )
208 .requirements(
209 new Requirement("system.phpVersion")
210 .matchValue("7\\.0|7\\.1")
211 .matchType(Requirement.MatchType.MATCHES)
212 )
213 .cleanWorkingDirectory(true);
214 }
215 }