196d08d7ef1b7064bde8f32472c00c94389e3665
[Packages/TYPO3.CMS.git] / Build / bamboo / src / main / java / core / NightlySpec.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.builders.task.ScriptTask;
28 import com.atlassian.bamboo.specs.builders.trigger.ScheduledTrigger;
29 import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
30 import com.atlassian.bamboo.specs.util.BambooServer;
31
32 /**
33 * Core master nightly test plan.
34 */
35 @BambooSpec
36 public class NightlySpec extends AbstractCoreSpec {
37
38 protected static String planName = "Core master nightly";
39 protected static String planKey = "GTN";
40
41 protected int numberOfAcceptanceTestJobs = 8;
42 protected int numberOfFunctionalMysqlJobs = 6;
43 protected int numberOfFunctionalMssqlJobs = 6;
44 protected int numberOfFunctionalPgsqlJobs = 6;
45 protected int numberOfUnitRandomOrderJobs = 4;
46
47 /**
48 * Run main to publish plan on Bamboo
49 */
50 public static void main(final String[] args) throws Exception {
51 // By default credentials are read from the '.credentials' file.
52 BambooServer bambooServer = new BambooServer(bambooServerName);
53 bambooServer.publish(new NightlySpec().createPlan());
54 bambooServer.publish(new NightlySpec().getDefaultPlanPermissions(projectKey, planKey));
55 }
56
57 /**
58 * Core master pre-merge plan is in "TYPO3 core" project of bamboo
59 */
60 Project project() {
61 return new Project().name(projectName).key(projectKey);
62 }
63
64 /**
65 * Returns full Plan definition
66 */
67 Plan createPlan() {
68 // PREPARATION stage
69 ArrayList<Job> jobsPreparationStage = new ArrayList<Job>();
70
71 jobsPreparationStage.add(this.getJobComposerValidate());
72
73 Stage stagePreparation = new Stage("Preparation")
74 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
75
76
77 // MAIN stage
78 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
79
80 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql(this.getRequirementPhpVersion70(), "PHP70"));
81 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql(this.getRequirementPhpVersion71(), "PHP71"));
82
83 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(this.getRequirementPhpVersion70(), "PHP70"));
84 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql(this.getRequirementPhpVersion71(), "PHP71"));
85
86 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, this.getRequirementPhpVersion70(), "PHP70"));
87 jobsMainStage.addAll(this.getJobsAcceptanceTestsMysql(this.numberOfAcceptanceTestJobs, this.getRequirementPhpVersion71(), "PHP71"));
88
89 jobsMainStage.add(this.getJobCglCheckFullCore());
90
91 jobsMainStage.add(this.getJobIntegrationVarious());
92
93 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion70(), "PHP70"));
94 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, this.getRequirementPhpVersion71(), "PHP71"));
95
96 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, this.getRequirementPhpVersion70(), "PHP70"));
97 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, this.getRequirementPhpVersion71(), "PHP71"));
98
99 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, this.getRequirementPhpVersion70(), "PHP70"));
100 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, this.getRequirementPhpVersion71(), "PHP71"));
101
102 jobsMainStage.add(this.getJobUnitJavaScript());
103
104 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion70(), "PHP70"));
105 jobsMainStage.add(this.getJobLintPhp(this.getRequirementPhpVersion71(), "PHP71"));
106
107 jobsMainStage.add(this.getJobLintScssTs());
108
109 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion70(), "PHP70"));
110 jobsMainStage.add(this.getJobUnitPhp(this.getRequirementPhpVersion71(), "PHP71"));
111
112 jobsMainStage.add(this.getJobUnitDeprecatedPhp(this.getRequirementPhpVersion70(), "PHP70"));
113 jobsMainStage.add(this.getJobUnitDeprecatedPhp(this.getRequirementPhpVersion71(), "PHP71"));
114
115 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion70(), "PHP70"));
116 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion71(), "PHP71"));
117
118 Stage stageMainStage = new Stage("Main stage")
119 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
120
121
122 // Compile plan
123 return new Plan(project(), planName, planKey)
124 .description("Execute TYPO3 core master nightly tests. Auto generated! See Build/bamboo of core git repository.")
125 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
126 .stages(
127 stagePreparation,
128 stageMainStage
129 )
130 .linkedRepositories("git.typo3.org Core")
131 .triggers(
132 new ScheduledTrigger()
133 .name("Scheduled")
134 .description("daily at night")
135 // daily 03:23
136 .cronExpression("0 23 3 ? * *")
137 )
138 .variables(
139 new Variable("changeUrl", ""),
140 new Variable("patchset", "")
141 )
142 .planBranchManagement(
143 new PlanBranchManagement()
144 .delete(new BranchCleanup())
145 .notificationForCommitters()
146 );
147 }
148
149 /**
150 * Job checking CGL of all core php files
151 */
152 protected Job getJobCglCheckFullCore() {
153 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
154 .description("Check coding guidelines of full core")
155 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
156 .tasks(
157 this.getTaskGitCloneRepository(),
158 this.getTaskGitCherryPick(),
159 this.getTaskComposerInstall(),
160 new ScriptTask()
161 .description("Execute cgl check")
162 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
163 .inlineBody(
164 this.getScriptTaskBashInlineBody() +
165 this.getScriptTaskBashPhpNoXdebug() +
166 "php_no_xdebug ./bin/php-cs-fixer fix -v --dry-run --path-mode intersection --config=Build/.php_cs typo3/\n" +
167 "exit $?\n"
168 )
169 )
170 .requirements(
171 this.getRequirementPhpVersion70Or71()
172 )
173 .cleanWorkingDirectory(true);
174 }
175 }