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