forked from tinymce/tinymce
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
169 lines (138 loc) · 4.73 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!groovy
@Library('waluigi@release/7') _
standardProperties()
def runTests(String name, String bedrockCommand, Boolean runAll) {
// Clean out the old XML files before running tests, since we junit import *.XML files
dir('scratch') {
if (isUnix()) {
sh "rm -f *.xml"
} else {
bat "del *.xml"
}
}
def command = runAll ? bedrockCommand + ' --ignore-lerna-changed=true' : bedrockCommand
def testStatus = exec(script: command, returnStatus: true)
echo "Writing JUnit results for ${name} on node: $NODE_NAME"
junit allowEmptyResults: true, testResults: 'scratch/TEST-*.xml'
// If the tests failed (exit code 4) then just mark it as unstable
if (testStatus == 4) {
unstable("Tests failed for ${name}")
} else if (testStatus != 0) {
error("Unexpected error running tests for ${name} so passing failure as exit code")
}
}
def runBrowserTests(String name, String browser, String os, Integer bucket, Integer buckets, Boolean runAll) {
def bedrockCommand =
"yarn grunt browser-auto" +
" --chunk=400" +
" --bedrock-os=" + os +
" --bedrock-browser=" + browser +
" --bucket=" + bucket +
" --buckets=" + buckets;
runTests(name, bedrockCommand, runAll);
}
def runHeadlessTests(Boolean runAll) {
def bedrockCommand = "yarn grunt headless-auto";
runTests("chrome-headless", bedrockCommand, runAll);
}
def gitMerge(String primaryBranch) {
if (env.BRANCH_NAME != primaryBranch) {
echo "Merging ${primaryBranch} into this branch to run tests"
exec("git merge --no-commit --no-ff origin/${primaryBranch}")
}
}
timestamps {
// TinyMCE builds need more CPU and RAM (especially eslint)
// NOTE: Ensure not to go over 7.5 CPU/RAM due to EC2 node sizes and the jnlp container requirements
tinyPods.nodeBrowser([
resourceRequestCpu: '6',
resourceRequestMemory: '4Gi',
resourceLimitCpu: '7.5',
resourceLimitMemory: '4Gi'
]) {
def props = readProperties(file: 'build.properties')
String primaryBranch = props.primaryBranch
assert primaryBranch != null && primaryBranch != ""
def runAllTests = env.BRANCH_NAME == primaryBranch
stage("Merge") {
// cancel build if primary branch doesn't merge cleanly
gitMerge(primaryBranch)
}
def platforms = [
[ os: "windows", browser: "chrome" ],
[ os: "windows", browser: "firefox" ],
[ os: "windows", browser: "MicrosoftEdge" ],
[ os: "macos", browser: "safari" ],
[ os: "macos", browser: "chrome" ],
[ os: "macos", browser: "firefox" ]
]
def cleanAndInstall = {
echo "Installing tools"
exec("git clean -fdx modules scratch js dist")
yarnInstall()
}
def processes = [:]
// Browser tests
for (int i = 0; i < platforms.size(); i++) {
def platform = platforms.get(i)
def buckets = platform.buckets ?: 1
for (int bucket = 1; bucket <= buckets; bucket++) {
def suffix = buckets == 1 ? "" : "-" + bucket
// closure variable - don't inline
def c_bucket = bucket
def name = "${platform.os}-${platform.browser}${suffix}"
processes[name] = {
stage(name) {
node("bedrock-${platform.os}") {
echo("Bedrock tests for ${name}")
echo("Checking out code on build node: $NODE_NAME")
checkout(scm)
// windows tends to not have username or email set
tinyGit.addAuthorConfig()
gitMerge(primaryBranch)
cleanAndInstall()
exec("yarn ci")
echo("Running browser tests")
runBrowserTests(name, platform.browser, platform.os, c_bucket, buckets, runAllTests)
}
}
}
}
}
processes["headless-and-archive"] = {
stage("headless tests") {
node('headless-macos') {
// Prepare the branch on the node
lock('headless tests') {
checkout(scm)
gitMerge(primaryBranch)
cleanAndInstall()
exec("yarn ci -s tinymce-rollup")
echo "Platform: chrome-headless tests on node: $NODE_NAME"
runHeadlessTests(runAllTests)
}
}
}
if (env.BRANCH_NAME != primaryBranch) {
stage("Archive Build") {
exec("yarn tinymce-grunt prodBuild symlink:js")
archiveArtifacts artifacts: 'js/**', onlyIfSuccessful: true
}
}
}
stage("Install tools") {
cleanAndInstall()
}
stage("Type check") {
exec("yarn ci-all")
}
stage("Moxiedoc check") {
exec("yarn tinymce-grunt shell:moxiedoc")
}
stage("Run Tests") {
grunt("list-changed-headless list-changed-browser")
// Run all the tests in parallel
parallel processes
}
}
}