2019-08-15 02:43:09 +08:00
|
|
|
#!/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/>.
|
|
|
|
*/
|
|
|
|
|
2020-06-17 02:23:25 +08:00
|
|
|
library "canvas-builds-library"
|
2019-12-21 04:37:59 +08:00
|
|
|
|
2020-07-14 06:22:08 +08:00
|
|
|
def COFFEE_NODE_COUNT = 2
|
2020-07-10 06:43:39 +08:00
|
|
|
def DEFAULT_NODE_COUNT = 1
|
|
|
|
def JSG_NODE_COUNT = 3
|
|
|
|
|
2020-04-16 23:02:58 +08:00
|
|
|
def copyFiles(dockerName, dockerPath, hostPath) {
|
|
|
|
sh "mkdir -vp ./$hostPath"
|
|
|
|
sh "docker cp \$(docker ps -qa -f name=$dockerName):/usr/src/app/$dockerPath ./$hostPath"
|
2020-01-07 03:31:16 +08:00
|
|
|
}
|
|
|
|
|
2020-07-10 06:43:39 +08:00
|
|
|
def makeKarmaStage(group, ciNode, ciTotal) {
|
|
|
|
return {
|
|
|
|
withEnv([
|
|
|
|
"CI_NODE_INDEX=${ciNode}",
|
|
|
|
"CI_NODE_TOTAL=${ciTotal}",
|
|
|
|
"CONTAINER_NAME=tests-karma-${group}-${ciNode}",
|
|
|
|
"JSPEC_GROUP=${group}"
|
|
|
|
]) {
|
|
|
|
try {
|
|
|
|
credentials.withSentryCredentials {
|
|
|
|
sh 'build/new-jenkins/js/tests-karma.sh'
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-15 02:43:09 +08:00
|
|
|
pipeline {
|
2019-09-07 02:03:00 +08:00
|
|
|
agent { label 'canvas-docker' }
|
2020-02-15 06:02:23 +08:00
|
|
|
options { ansiColor('xterm') }
|
2019-08-15 02:43:09 +08:00
|
|
|
|
|
|
|
environment {
|
2020-05-02 05:04:18 +08:00
|
|
|
COMPOSE_FILE = 'docker-compose.new-jenkins.canvas.yml:docker-compose.new-jenkins-karma.yml'
|
2020-06-17 02:23:25 +08:00
|
|
|
FORCE_FAILURE = configuration.forceFailureJS()
|
2020-01-07 03:31:16 +08:00
|
|
|
SENTRY_URL="https://sentry.insops.net"
|
|
|
|
SENTRY_ORG="instructure"
|
|
|
|
SENTRY_PROJECT="master-javascript-build"
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
2020-02-15 06:02:23 +08:00
|
|
|
|
2019-08-15 02:43:09 +08:00
|
|
|
stages {
|
2020-04-16 23:02:58 +08:00
|
|
|
stage('Setup') {
|
2019-11-28 05:22:59 +08:00
|
|
|
steps {
|
2020-06-17 02:23:25 +08:00
|
|
|
cleanAndSetup()
|
2020-04-16 23:02:58 +08:00
|
|
|
timeout(time: 10) {
|
2020-03-10 23:14:44 +08:00
|
|
|
sh 'rm -vrf ./tmp/*'
|
2020-07-01 23:25:02 +08:00
|
|
|
sh './build/new-jenkins/docker-with-flakey-network-protection.sh pull $PATCHSET_TAG'
|
2020-01-18 04:22:04 +08:00
|
|
|
sh 'docker-compose build'
|
2019-12-03 03:14:11 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
2019-09-07 05:01:43 +08:00
|
|
|
}
|
2020-01-18 04:22:04 +08:00
|
|
|
|
|
|
|
stage('Test Stage Coordinator') {
|
|
|
|
steps {
|
2020-04-16 23:02:58 +08:00
|
|
|
timeout(time: 60) {
|
|
|
|
script {
|
|
|
|
def tests = [:]
|
|
|
|
|
2020-07-02 21:15:23 +08:00
|
|
|
if(env.TEST_SUITE == 'jest') {
|
|
|
|
tests['Jest'] = {
|
|
|
|
withEnv(['CONTAINER_NAME=tests-jest']) {
|
|
|
|
try {
|
|
|
|
credentials.withSentryCredentials {
|
|
|
|
sh 'build/new-jenkins/js/tests-jest.sh'
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
2020-04-16 23:02:58 +08:00
|
|
|
}
|
2020-01-17 03:16:25 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2020-01-18 04:22:04 +08:00
|
|
|
|
2020-07-02 21:15:23 +08:00
|
|
|
if(env.TEST_SUITE == 'karma') {
|
|
|
|
tests['Packages'] = {
|
|
|
|
withEnv(['CONTAINER_NAME=tests-packages']) {
|
|
|
|
try {
|
|
|
|
credentials.withSentryCredentials {
|
|
|
|
sh 'build/new-jenkins/js/tests-packages.sh'
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'packages', "./tmp/${env.CONTAINER_NAME}")
|
2020-06-17 02:23:25 +08:00
|
|
|
}
|
2020-01-17 03:16:25 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 05:43:54 +08:00
|
|
|
|
2020-07-02 21:15:23 +08:00
|
|
|
tests['canvas_quizzes'] = {
|
|
|
|
sh 'build/new-jenkins/js/tests-quizzes.sh'
|
|
|
|
}
|
2020-01-30 05:43:54 +08:00
|
|
|
|
2020-07-14 06:22:08 +08:00
|
|
|
for(int i = 0; i < COFFEE_NODE_COUNT; i++) {
|
|
|
|
tests["Karma - Spec Group - coffee${i}"] = makeKarmaStage('coffee', i, COFFEE_NODE_COUNT)
|
|
|
|
}
|
|
|
|
|
2020-07-10 06:43:39 +08:00
|
|
|
for(int i = 0; i < JSG_NODE_COUNT; i++) {
|
|
|
|
tests["Karma - Spec Group - jsg${i}"] = makeKarmaStage('jsg', i, JSG_NODE_COUNT)
|
|
|
|
}
|
|
|
|
|
2020-07-14 06:22:08 +08:00
|
|
|
['jsa', 'jsh'].each { group ->
|
2020-07-10 06:43:39 +08:00
|
|
|
tests["Karma - Spec Group - ${group}"] = makeKarmaStage(group, 0, DEFAULT_NODE_COUNT)
|
2020-01-17 03:16:25 +08:00
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2020-01-18 04:22:04 +08:00
|
|
|
|
2020-06-17 02:23:25 +08:00
|
|
|
parallel(tests)
|
2020-04-16 23:02:58 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
2020-03-10 23:14:44 +08:00
|
|
|
|
2019-08-22 03:12:19 +08:00
|
|
|
post {
|
2019-12-21 04:37:59 +08:00
|
|
|
always {
|
|
|
|
script {
|
2020-07-09 10:38:45 +08:00
|
|
|
archiveArtifacts artifacts: 'tmp/**/*.xml'
|
2020-01-16 22:55:14 +08:00
|
|
|
junit allowEmptyResults: true, testResults: 'tmp/**/*.xml'
|
2020-01-09 06:30:07 +08:00
|
|
|
sh 'find ./tmp -path "*.xml"'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-22 03:12:19 +08:00
|
|
|
cleanup {
|
2020-06-17 02:23:25 +08:00
|
|
|
execute 'bash/docker-cleanup.sh --allow-failure'
|
2019-08-22 03:12:19 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-16 22:55:14 +08:00
|
|
|
}
|