97 lines
3.4 KiB
Groovy
97 lines
3.4 KiB
Groovy
#!/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 = 15; // how many nodes to run on
|
|
pipeline {
|
|
agent { label 'canvas-docker' }
|
|
options {
|
|
ansiColor('xterm')
|
|
}
|
|
|
|
environment {
|
|
COMPOSE_FILE = 'docker-compose.new-jenkins.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,gems/plugins/*/spec_canvas}/**/*_spec.rb'
|
|
KNAPSACK_EXCLUDE_REGEX = '/selenium/'
|
|
KNAPSACK_TEST_DIR = 'spec'
|
|
RERUNS_RETRY = 1
|
|
MAX_FAIL = 50
|
|
}
|
|
stages {
|
|
stage ('Distribute Rspec Tests') {
|
|
steps {
|
|
script {
|
|
def nodes = [:];
|
|
for(int i = 0; i < ci_node_total; i++) {
|
|
def index = i;
|
|
nodes["rspec set ${(i).toString().padLeft(2, '0')}"] = {
|
|
withEnv(["CI_NODE_INDEX=$index", "CI_NODE_TOTAL=$ci_node_total"]) {
|
|
node('canvas-docker') {
|
|
stage("Running RSpec Set ${index}") {
|
|
try {
|
|
sh 'rm -rf ./tmp/spec_failures'
|
|
checkout scm
|
|
sh 'build/new-jenkins/docker-cleanup.sh'
|
|
timeout(time: 60) {
|
|
sh 'build/new-jenkins/print-env-excluding-secrets.sh'
|
|
sh 'build/new-jenkins/docker-compose-pull.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 {
|
|
def reports = load 'build/new-jenkins/groovy/reports.groovy'
|
|
dir ('tmp') {
|
|
reports.stashSpecFailures(index)
|
|
}
|
|
sh 'rm -rf ./tmp/spec_failures'
|
|
sh 'build/new-jenkins/docker-cleanup.sh --allow-failure'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
parallel(nodes);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
failure {
|
|
script {
|
|
def reports = load 'build/new-jenkins/groovy/reports.groovy'
|
|
reports.publishSpecFailuresAsHTML(ci_node_total)
|
|
}
|
|
}
|
|
}
|
|
}
|