78f8515a6cb1a364f32aa01d370bb14f0f0b1847
[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 8.7 nightly test plan.
34 */
35 @BambooSpec
36 public class NightlySpec extends AbstractCoreSpec {
37
38 protected static String planName = "Core 8.7 nightly";
39 protected static String planKey = "GTN87";
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 8.7 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.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion70(), "PHP70"));
113 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, this.getRequirementPhpVersion71(), "PHP71"));
114
115 Stage stageMainStage = new Stage("Main stage")
116 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
117
118
119 // Compile plan
120 return new Plan(project(), planName, planKey)
121 .description("Execute TYPO3 core 8.7 nightly tests. Auto generated! See Build/bamboo of core git repository.")
122 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
123 .stages(
124 stagePreparation,
125 stageMainStage
126 )
127 .linkedRepositories("git.typo3.org Core 8.7")
128 .triggers(
129 new ScheduledTrigger()
130 .name("Scheduled")
131 .description("daily at night")
132 // daily 04:42
133 .cronExpression("0 42 4 ? * *")
134 )
135 .variables(
136 new Variable("changeUrl", ""),
137 new Variable("patchset", "")
138 )
139 .planBranchManagement(
140 new PlanBranchManagement()
141 .delete(new BranchCleanup())
142 .notificationForCommitters()
143 );
144 }
145
146 /**
147 * Job checking CGL of all core php files
148 */
149 protected Job getJobCglCheckFullCore() {
150 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
151 .description("Check coding guidelines of full core")
152 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
153 .tasks(
154 this.getTaskGitCloneRepository(),
155 this.getTaskGitCherryPick(),
156 this.getTaskComposerInstall(),
157 new ScriptTask()
158 .description("Execute cgl check")
159 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
160 .inlineBody(
161 this.getScriptTaskBashInlineBody() +
162 this.getScriptTaskBashPhpNoXdebug() +
163 "php_no_xdebug ./bin/php-cs-fixer fix -v --dry-run --config=Build/.php_cs typo3/\n" +
164 "exit $?\n"
165 )
166 )
167 .requirements(
168 this.getRequirementPhpVersion70Or71()
169 )
170 .cleanWorkingDirectory(true);
171 }
172 }