forked from tinymce/tinymce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
154 lines (125 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
#!groovy
@Library('[email protected]') _
def runTests(name, bedrockCommand, 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 successfulTests = execHandle(command)
echo "Writing JUnit results for " + name + " on node: $NODE_NAME"
junit allowEmptyResults: true, testResults: 'scratch/TEST-*.xml'
if (!successfulTests) {
echo "Tests failed for " + name + " so passing failure as exit code for node: $NODE_NAME"
exec("exit 1")
}
}
def runBrowserTests(name, browser, os, bucket, buckets, runAll) {
def bedrockCommand =
"yarn grunt browser-auto" +
" --chunk=200" +
" --bedrock-os=" + os +
" --bedrock-browser=" + browser +
" --bucket=" + bucket +
" --buckets=" + buckets;
runTests(name, bedrockCommand, runAll);
}
def runPhantomTests(runAll) {
def bedrockCommand = "yarn grunt phantomjs-auto";
runTests("PhantomJS", bedrockCommand, runAll);
}
standardProperties()
def gitMerge(String primaryBranch) {
if (BRANCH_NAME != primaryBranch) {
echo "Merging ${primaryBranch} into this branch to run tests"
exec("git merge --no-commit --no-ff origin/${primaryBranch}")
}
}
node("primary") {
timestamps {
checkout scm
def props = readProperties file: 'build.properties'
def primaryBranch = props.primaryBranch
assert primaryBranch != null && primaryBranch != ""
def runAllTests = BRANCH_NAME == primaryBranch
stage ("Merge") {
// cancel build if primary branch doesn't merge cleanly
gitMerge(primaryBranch)
}
def browserPermutations = [
[ name: "win10Chrome", os: "windows-10", browser: "chrome", buckets: 1 ],
[ name: "win10FF", os: "windows-10", browser: "firefox", buckets: 1 ],
[ name: "win10Edge", os: "windows-10", browser: "MicrosoftEdge", buckets: 1 ],
[ name: "win10IE", os: "windows-10", browser: "ie", buckets: 3 ],
[ name: "macSafari", os: "macos", browser: "safari", buckets: 1 ],
[ name: "macChrome", os: "macos", browser: "chrome", buckets: 1 ],
[ name: "macFirefox", os: "macos", browser: "firefox", buckets: 1 ]
]
def cleanAndInstall = {
echo "Installing tools"
exec("git clean -fdx modules scratch js dist")
yarnInstall()
}
def processes = [:]
// Browser tests
for (int i = 0; i < browserPermutations.size(); i++) {
def permutation = browserPermutations.get(i)
def buckets = permutation.buckets
for (int bucket = 1; bucket <= buckets; bucket++) {
def suffix = buckets == 1 ? "" : "-" + bucket
// closure variable - don't inline
def c_bucket = bucket
processes[permutation.name + suffix] = {
stage (permutation.os + " " + permutation.browser + suffix) {
node("bedrock-" + permutation.os) {
echo "name: " + permutation.name + " bucket: " + c_bucket + "/" + buckets
echo "Node checkout on node $NODE_NAME"
checkout scm
// windows tends to not have username or email set
exec("git config user.email \"[email protected]\"")
exec("git config user.name \"irrelevant\"")
gitMerge(primaryBranch)
cleanAndInstall()
exec("yarn ci")
echo "Platform: browser tests for " + permutation.name + " on node: $NODE_NAME"
runBrowserTests(permutation.name, permutation.browser, permutation.os, c_bucket, buckets, runAllTests)
}
}
}
}
}
processes["phantom-and-archive"] = {
stage ("PhantomJS") {
// PhantomJS is a browser, but runs on the same node as the pipeline
// we are re-using the state prepared by `ci-all` below
// if we ever change these tests to run on a different node, rollup is required in addition to the normal CI command
echo "Platform: PhantomJS tests on node: $NODE_NAME"
runPhantomTests(runAllTests)
}
if (BRANCH_NAME != primaryBranch) {
stage ("Archive Build") {
exec("yarn tinymce-grunt prodBuild symlink:js")
archiveArtifacts artifacts: 'js/**', onlyIfSuccessful: true
}
}
}
// our linux nodes have multiple executors, sometimes yarn creates conflicts
lock("Don't run yarn simultaneously") {
stage ("Install tools") {
cleanAndInstall()
}
}
stage ("Type check") {
exec("yarn ci-all")
}
stage ("Run Tests") {
grunt("list-changed-phantom list-changed-browser")
// Run all the tests in parallel
parallel processes
}
}
}