bec66191d7df397bf5fb673a150119c46435e9d3
[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.project.Project;
30 import com.atlassian.bamboo.specs.api.builders.requirement.Requirement;
31 import com.atlassian.bamboo.specs.builders.notification.PlanCompletedNotification;
32 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
33 import com.atlassian.bamboo.specs.builders.trigger.RemoteTrigger;
34 import com.atlassian.bamboo.specs.builders.trigger.RepositoryPollingTrigger;
35 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
36 import com.atlassian.bamboo.specs.util.BambooServer;
37
38 /**
39 * Core master pre-merge test plan.
40 */
41 @BambooSpec
42 public class PreMergeSpec extends AbstractCoreSpec {
43
44 protected static String planName = "Core master pre-merge";
45 protected static String planKey = "GTC";
46
47 protected int numberOfAcceptanceTestJobs = 10;
48 protected int numberOfFunctionalMysqlJobs = 10;
49 protected int numberOfFunctionalMssqlJobs = 10;
50 protected int numberOfFunctionalPgsqlJobs = 10;
51 protected int numberOfFunctionalSqliteJobs = 10;
52 protected int numberOfUnitRandomOrderJobs = 2;
53
54 /**
55 * Run main to publish plan on Bamboo
56 */
57 public static void main(final String[] args) throws Exception {
58 // By default credentials are read from the '.credentials' file.
59 BambooServer bambooServer = new BambooServer(bambooServerName);
60 bambooServer.publish(new PreMergeSpec().createPlan());
61 bambooServer.publish(new PreMergeSpec().getDefaultPlanPermissions(projectKey, planKey));
62 }
63
64 /**
65 * Core master pre-merge plan is in "TYPO3 core" project of bamboo
66 */
67 Project project() {
68 return new Project().name(projectName).key(projectKey);
69 }
70
71 /**
72 * Returns full Plan definition
73 */
74 Plan createPlan() {
75 // PREPARATION stage
76 ArrayList<Job> jobsPreparationStage = new ArrayList<Job>();
77 jobsPreparationStage.add(this.getJobBuildLabels());
78 Stage stagePreparation = new Stage("Preparation")
79 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
80
81 // EARLY stage
82 ArrayList<Job> jobsEarlyStage = new ArrayList<Job>();
83 jobsEarlyStage.add(this.getJobCglCheckGitCommit("PHP72"));
84 jobsEarlyStage.add(this.getJobComposerValidate("PHP72"));
85 Stage stageEarly = new Stage("Early")
86 .jobs(jobsEarlyStage.toArray(new Job[jobsEarlyStage.size()]));
87
88 // MAIN stage
89 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
90
91 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql(0, "PHP72", this.getTaskComposerInstall("PHP72")));
92 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(0, "PHP72", this.getTaskComposerInstall("PHP72")));
93 jobsMainStage.add(this.getJobAcceptanceTestInstallSqlite(0, "PHP72", this.getTaskComposerInstall("PHP72")));
94
95 jobsMainStage.addAll(this.getJobsAcceptanceTestsBackendMysql(0, this.numberOfAcceptanceTestJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
96
97 jobsMainStage.add(this.getJobIntegrationAnnotations(0, "PHP72", this.getTaskComposerInstall("PHP72")));
98
99 jobsMainStage.add(this.getJobIntegrationVarious(0, "PHP72", this.getTaskComposerInstall("PHP72")));
100
101 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(0, this.numberOfFunctionalMysqlJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
102 // mssql functionals are not executed as pre-merge
103 // jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(0, this.numberOfFunctionalMssqlJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
104 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(0, this.numberOfFunctionalPgsqlJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
105 jobsMainStage.addAll(this.getJobsFunctionalTestsSqlite(0, this.numberOfFunctionalSqliteJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
106
107 jobsMainStage.add(this.getJobUnitJavaScript(0, "PHP72", this.getTaskComposerInstall("PHP72")));
108
109 jobsMainStage.add(this.getJobLintPhp("PHP72"));
110
111 jobsMainStage.add(this.getJobLintScssTs("PHP72"));
112
113 jobsMainStage.add(this.getJobUnitPhp(0, "PHP72", this.getTaskComposerInstall("PHP72")));
114 jobsMainStage.add(this.getJobUnitDeprecatedPhp(0, "PHP72", this.getTaskComposerInstall("PHP72")));
115 jobsMainStage.addAll(this.getJobUnitPhpRandom(0, this.numberOfUnitRandomOrderJobs, "PHP72", this.getTaskComposerInstall("PHP72")));
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 master pre-merge tests. Auto generated! See Build/bamboo of core git repository.")
123 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
124 .stages(
125 stagePreparation,
126 stageEarly,
127 stageMainStage
128 )
129 .linkedRepositories("github TYPO3 TYPO3.CMS")
130 .triggers(
131 new RepositoryPollingTrigger()
132 .name("Repository polling for post-merge builds"),
133 new RemoteTrigger()
134 .name("Remote trigger for pre-merge builds")
135 .description("Gerrit")
136 .triggerIPAddresses("5.10.165.218,91.184.35.13"))
137 .variables(
138 new Variable("changeUrl", ""),
139 new Variable("patchset", "")
140 )
141 .planBranchManagement(
142 new PlanBranchManagement()
143 .delete(new BranchCleanup())
144 .notificationForCommitters()
145 )
146 .notifications(new Notification()
147 .type(new PlanCompletedNotification())
148 .recipients(new AnyNotificationRecipient(new AtlassianModule("com.atlassian.bamboo.plugins.bamboo-slack:recipient.slack"))
149 .recipientString("https://intercept.typo3.com/index.php")
150 )
151 );
152 }
153 }