2ad9c041752ddf0f1355af41af6762660b07b334
[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.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.api.builders.requirement.Requirement;
28 import com.atlassian.bamboo.specs.builders.task.ScriptTask;
29 import com.atlassian.bamboo.specs.builders.trigger.RemoteTrigger;
30 import com.atlassian.bamboo.specs.builders.trigger.RepositoryPollingTrigger;
31 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
32 import com.atlassian.bamboo.specs.util.BambooServer;
33
34 /**
35 * Core master pre-merge test plan.
36 */
37 @BambooSpec
38 public class PreMergeSpec extends AbstractCoreSpec {
39
40 protected int numberOfAcceptanceTestJobs = 8;
41 protected int numberOfFunctionalMysqlJobs = 10;
42 protected int numberOfFunctionalMssqlJobs = 10;
43 protected int numberOfFunctionalPgsqlJobs = 10;
44 protected int numberOfUnitRandomOrderJobs = 2;
45
46 /**
47 * Run main to publish plan on Bamboo
48 */
49 public static void main(final String[] args) throws Exception {
50 // By default credentials are read from the '.credentials' file.
51 BambooServer bambooServer = new BambooServer("https://bamboo.typo3.com:443");
52 Plan plan = new PreMergeSpec().createPlan();
53 bambooServer.publish(plan);
54 }
55
56 /**
57 * Core master pre-merge plan is in "TYPO3 core" project of bamboo
58 */
59 Project project() {
60 return new Project().name("TYPO3 Core").key("CORE");
61 }
62
63 /**
64 * Returns full Plan definition
65 */
66 Plan createPlan() {
67 // PREPARATION stage
68 ArrayList<Job> jobsPreparationStage = new ArrayList<Job>();
69
70 jobsPreparationStage.add(this.getJobBuildLabels());
71
72 jobsPreparationStage.add(this.getJobCglCheckGitCommit());
73
74 jobsPreparationStage.add(this.getJobComposerValidate());
75
76 Stage stagePreparation = new Stage("Preparation")
77 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
78
79
80 // MAIN stage
81 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
82
83 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql(this.getRequirementPhpVersion70Or71(), "PHP7071"));
84 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(this.getRequirementPhpVersion70Or71(), "PHP7071"));
85
86 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
87
88 jobsMainStage.add(this.getJobIntegrationVarious());
89
90 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
91
92 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
93
94 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, this.getRequirementPhpVersion70Or71(), "PHP7071"));
95
96 jobsMainStage.add(this.getJobUnitJavaScript());
97
98 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion70(), "PHP70"));
99 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion71(), "PHP71"));
100
101 jobsMainStage.add(this.getJobLintScssTs());
102
103 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion70(), "PHP70"));
104 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion71(), "PHP71"));
105
106 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion70(), "PHP70"));
107 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion71(), "PHP71"));
108
109 Stage stageMainStage = new Stage("Main stage")
110 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
111
112
113 // Compile plan
114 return new Plan(project(), "Core master pre-merge", "GTC")
115 .description("Execute TYPO3 core master pre-merge tests. Auto generated! See Build/bamboo of core git repository.")
116 .stages(
117 stagePreparation,
118 stageMainStage
119 )
120 .linkedRepositories("git.typo3.org Core")
121 .triggers(
122 new RepositoryPollingTrigger()
123 .name("Repository polling for post-merge builds"),
124 new RemoteTrigger()
125 .name("Remote trigger for pre-merge builds")
126 .description("Gerrit")
127 .triggerIPAddresses("5.10.165.218,91.184.35.13"))
128 .variables(
129 new Variable("changeUrl", ""),
130 new Variable("patchset", "")
131 )
132 .planBranchManagement(
133 new PlanBranchManagement()
134 .delete(new BranchCleanup())
135 .notificationForCommitters()
136 );
137 }
138
139 /**
140 * Job creating labels needed for intercept communication
141 */
142 protected Job getJobBuildLabels() {
143 return new Job("Create build labels", new BambooKey("CLFB"))
144 .description("Create changeId and patch set labels from variable access and parsing result of a dummy task")
145 .tasks(
146 new ScriptTask()
147 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
148 .inlineBody("echo \"I'm just here for the labels!\"")
149 );
150 }
151
152 /**
153 * Job checking CGL of last git commit
154 */
155 protected Job getJobCglCheckGitCommit() {
156 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
157 .description("Check coding guidelines by executing Build/Scripts/cglFixMyCommit.sh script")
158 .tasks(
159 this.getTaskGitCloneRepository(),
160 this.getTaskGitCherryPick(),
161 this.getTaskComposerInstall(),
162 new ScriptTask()
163 .description("Execute cgl check script")
164 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
165 .inlineBody(
166 this.getScriptTaskBashInlineBody() +
167 "./Build/Scripts/cglFixMyCommit.sh dryrun\n"
168 )
169 )
170 .requirements(
171 new Requirement("system.phpVersion")
172 .matchValue("7\\.0|7\\.1")
173 .matchType(Requirement.MatchType.MATCHES)
174 );
175 }
176 }