forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.selenium.chrome
127 lines (120 loc) · 4.4 KB
/
Jenkinsfile.selenium.chrome
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
#!/usr/bin/env groovy
/*
* Copyright (C) 2019 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
def ci_node_total = 20; // how many nodes to run on
pipeline {
agent none
options {
ansiColor('xterm')
}
environment {
COMPOSE_FILE = 'docker-compose.new-jenkins.yml:docker-compose.new-jenkins-selenium.yml'
// 'refs/changes/63/181863/8' -> '63.181863.8'
NAME = "${env.GERRIT_REFSPEC}".minus('refs/changes/').replaceAll('/','.')
PATCHSET_TAG = "$DOCKER_REGISTRY_FQDN/jenkins/canvas-lms:$NAME"
KNAPSACK_ENABLED = 1
KNAPSACK_GENERATE_REPORT = 'false'
KNAPSACK_TEST_FILE_PATTERN = '{spec/selenium,gems/plugins/*/spec_canvas/selenium}/**/*_spec.rb'
KNAPSACK_EXCLUDE_REGEX = '/performance/'
KNAPSACK_TEST_DIR = 'spec'
// for now 1 until we stabilize some of the flaky specs
RERUNS_RETRY = 1
MAX_FAIL = 80
}
stages {
stage ('Distribute Selenium Tests') {
steps {
script {
def nodes = [:];
for(int i = 0; i < ci_node_total; i++) {
def index = i;
nodes["selenium set ${(i+1).toString().padLeft(2, '0')}"] = {
withEnv(["CI_NODE_INDEX=$index", "CI_NODE_TOTAL=$ci_node_total"]) {
node('canvas-docker') {
stage("Running Selenium Set ${index}") {
try {
checkout scm
sh 'rm -rf ./tmp/spec_failures'
timeout(time: 60) {
sh 'printenv | sort'
sh 'build/new-jenkins/docker-compose-pull.sh'
sh 'build/new-jenkins/docker-compose-pull-selenium.sh'
sh 'build/new-jenkins/docker-compose-build-up.sh'
sh 'build/new-jenkins/docker-compose-create-migrate-database.sh'
sh 'build/new-jenkins/rspec-with-retries.sh'
}
}
catch (ex) {
// copy spec failures to local
sh 'mkdir -p tmp'
sh 'docker cp $(docker-compose ps -q web):/usr/src/app/log/spec_failures/ ./tmp/spec_failures/'
throw ex
}
finally {
dir ('tmp') {
stash name: "selenium_failures_${index}", includes: 'spec_failures/**/*', allowEmpty: true
}
sh 'rm -rf ./tmp/spec_failures'
sh 'build/new-jenkins/docker-cleanup.sh'
}
}
}
}
}
}
parallel(nodes);
}
}
}
}
post {
failure {
script {
node {
sh 'rm -rf ./compiled_failures'
def htmlFiles;
dir('compiled_failures') {
for(int i = 0; i < ci_node_total; i++) {
def index = i;
dir ("node_${index}") {
unstash "selenium_failures_${index}"
}
}
htmlFiles = findFiles glob: '**/index.html'
def indexHtml = "<body style=\"font-family:sans-serif;line-height:1.25;font-size:14px\">"
htmlFiles.each {
def spec = (it =~ /.*spec_failures\/(.*)\/index/)[0][1]
indexHtml += "<a href=\"${it}\">${spec}</a><br>"
}
indexHtml += "</body>"
writeFile file: "index.html", text: indexHtml
}
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'compiled_failures',
reportFiles: "index.html," + htmlFiles.join(','),
reportName: 'Test Failures'
]
sh 'rm -rf ./compiled_failures'
}
}
}
}
}