383613761368eb17337ec1ba2aa3abeee540710b
[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 = 16;
44 protected int numberOfFunctionalPgsqlJobs = 6;
45 protected int numberOfFunctionalSqliteJobs = 6;
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 jobsPreparationStage.add(this.getJobBuildLabels());
72 Stage stagePreparation = new Stage("Preparation")
73 .jobs(jobsPreparationStage.toArray(new Job[jobsPreparationStage.size()]));
74
75 // MAIN stage
76 ArrayList<Job> jobsMainStage = new ArrayList<Job>();
77
78 jobsMainStage.add(this.getJobComposerValidate("PHP72"));
79
80 jobsMainStage.add(this.getJobAcceptanceTestInstallMysql("PHP72"));
81 jobsMainStage.add(this.getJobAcceptanceTestInstallPgsql("PHP72"));
82 jobsMainStage.add(this.getJobAcceptanceTestInstallSqlite("PHP72"));
83
84 jobsMainStage.addAll(this.getJobsAcceptanceTestsBackendMysql(this.numberOfAcceptanceTestJobs, "PHP72"));
85
86 jobsMainStage.add(this.getJobCglCheckFullCore("PHP72"));
87
88 jobsMainStage.add(this.getJobIntegrationAnnotations("PHP72"));
89
90 jobsMainStage.add(this.getJobIntegrationVarious("PHP72"));
91
92 jobsMainStage.addAll(this.getJobsFunctionalTestsMysql(this.numberOfFunctionalMysqlJobs, "PHP72"));
93 jobsMainStage.addAll(this.getJobsFunctionalTestsMssql(this.numberOfFunctionalMssqlJobs, "PHP72"));
94 jobsMainStage.addAll(this.getJobsFunctionalTestsPgsql(this.numberOfFunctionalPgsqlJobs, "PHP72"));
95 jobsMainStage.addAll(this.getJobsFunctionalTestsSqlite(this.numberOfFunctionalSqliteJobs, "PHP72"));
96
97 jobsMainStage.add(this.getJobUnitJavaScript("PHP72"));
98
99 jobsMainStage.add(this.getJobLintPhp("PHP72"));
100
101 jobsMainStage.add(this.getJobLintScssTs("PHP72"));
102
103 jobsMainStage.add(this.getJobUnitPhp("PHP72"));
104 jobsMainStage.add(this.getJobUnitDeprecatedPhp("PHP72"));
105 jobsMainStage.addAll(this.getJobUnitPhpRandom(this.numberOfUnitRandomOrderJobs, "PHP72"));
106
107 Stage stageMainStage = new Stage("Main stage")
108 .jobs(jobsMainStage.toArray(new Job[jobsMainStage.size()]));
109
110
111 // Compile plan
112 return new Plan(project(), planName, planKey)
113 .description("Execute TYPO3 core master nightly tests. Auto generated! See Build/bamboo of core git repository.")
114 .pluginConfigurations(this.getDefaultPlanPluginConfiguration())
115 .stages(
116 stagePreparation,
117 stageMainStage
118 )
119 .linkedRepositories("github TYPO3 TYPO3.CMS")
120 .triggers(
121 new ScheduledTrigger()
122 .name("Scheduled")
123 .description("daily at night")
124 // daily 03:23
125 .cronExpression("0 23 3 ? * *")
126 )
127 .variables(
128 new Variable("changeUrl", ""),
129 new Variable("patchset", "")
130 )
131 .planBranchManagement(
132 new PlanBranchManagement()
133 .delete(new BranchCleanup())
134 .notificationForCommitters()
135 );
136 }
137
138 /**
139 * Job checking CGL of all core php files
140 *
141 * @param String requirementIdentifier
142 */
143 protected Job getJobCglCheckFullCore(String requirementIdentifier) {
144 return new Job("Integration CGL", new BambooKey("CGLCHECK"))
145 .description("Check coding guidelines of full core")
146 .pluginConfigurations(this.getDefaultJobPluginConfiguration())
147 .tasks(
148 this.getTaskGitCloneRepository(),
149 this.getTaskGitCherryPick(),
150 this.getTaskComposerInstall(requirementIdentifier),
151 new ScriptTask()
152 .description("Execute cgl check")
153 .interpreter(ScriptTaskProperties.Interpreter.BINSH_OR_CMDEXE)
154 .inlineBody(
155 this.getScriptTaskBashInlineBody() +
156 "function phpCsFixer() {\n" +
157 " docker run \\\n" +
158 " -u ${HOST_UID} \\\n" +
159 " -v /bamboo-data/${BAMBOO_COMPOSE_PROJECT_NAME}/passwd:/etc/passwd \\\n" +
160 " -v ${BAMBOO_COMPOSE_PROJECT_NAME}_bamboo-data:/srv/bamboo/xml-data/build-dir/ \\\n" +
161 " --name ${BAMBOO_COMPOSE_PROJECT_NAME}sib_adhoc \\\n" +
162 " --rm \\\n" +
163 " typo3gmbh/" + requirementIdentifier.toLowerCase() + ":latest \\\n" +
164 " bin/bash -c \"cd ${PWD}; php -n -c /etc/php/cli-no-xdebug/php.ini bin/php-cs-fixer $*\"\n" +
165 "}\n" +
166 "\n" +
167 "phpCsFixer fix -v --dry-run --path-mode intersection --config=Build/.php_cs typo3/\n" +
168 "exit $?"
169 )
170 )
171 .requirements(
172 this.getRequirementDocker10()
173 )
174 .cleanWorkingDirectory(true);
175 }
176 }