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-01-07 03:31:16 +08:00
|
|
|
def runCoverage() {
|
|
|
|
def flags = load 'build/new-jenkins/groovy/commit-flags.groovy'
|
2020-01-17 23:53:44 +08:00
|
|
|
return env.RUN_COVERAGE == '1' || flags.forceRunCoverage() ? '1' : ''
|
2019-09-07 05:01:43 +08:00
|
|
|
}
|
|
|
|
|
2020-01-15 23:56:55 +08:00
|
|
|
def isForceFailure() {
|
|
|
|
def flags = load 'build/new-jenkins/groovy/commit-flags.groovy'
|
|
|
|
return flags.isForceFailure() ? "1" : ''
|
|
|
|
}
|
|
|
|
|
2019-12-21 04:37:59 +08:00
|
|
|
def getImageTagVersion() {
|
|
|
|
def flags = load 'build/new-jenkins/groovy/commit-flags.groovy'
|
2020-01-21 02:22:25 +08:00
|
|
|
// total hack, we shouldnt do it like this. but until there is a better
|
|
|
|
// way of passing info across builds, this is path of least resistance..
|
|
|
|
// also, it didnt seem to work with multiple return statements, so i'll
|
|
|
|
// just go ahead and leave this monstrosity here.
|
|
|
|
return env.RUN_COVERAGE == '1' ? 'master' : flags.getImageTagVersion()
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
|
2020-01-17 03:16:25 +08:00
|
|
|
def copyFiles(docker_name, docker_dir, host_dir) {
|
|
|
|
sh "mkdir -p ./$host_dir"
|
|
|
|
sh "docker cp \$(docker ps -qa -f name=$docker_name):/usr/src/app/$docker_dir ./$host_dir"
|
2020-01-07 03:31:16 +08:00
|
|
|
}
|
|
|
|
|
2019-08-15 02:43:09 +08:00
|
|
|
pipeline {
|
2019-09-07 02:03:00 +08:00
|
|
|
agent { label 'canvas-docker' }
|
2019-08-15 02:43:09 +08:00
|
|
|
options {
|
|
|
|
ansiColor('xterm')
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
2019-12-03 03:14:11 +08:00
|
|
|
COMPOSE_FILE = 'docker-compose.new-jenkins-web.yml:docker-compose.new-jenkins-karma.yml'
|
2020-01-07 03:31:16 +08:00
|
|
|
COVERAGE = runCoverage()
|
2020-01-15 23:56:55 +08:00
|
|
|
FORCE_FAILURE = isForceFailure()
|
2019-12-21 04:37:59 +08:00
|
|
|
NAME = getImageTagVersion()
|
2019-08-27 01:48:19 +08:00
|
|
|
PATCHSET_TAG = "$DOCKER_REGISTRY_FQDN/jenkins/canvas-lms:$NAME"
|
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
|
|
|
}
|
|
|
|
stages {
|
2019-12-10 02:37:05 +08:00
|
|
|
stage('Pre-Cleanup') {
|
2019-11-28 05:22:59 +08:00
|
|
|
steps {
|
2019-12-10 02:37:05 +08:00
|
|
|
timeout(time: 2) {
|
|
|
|
sh 'build/new-jenkins/docker-cleanup.sh'
|
2020-01-21 02:22:25 +08:00
|
|
|
sh 'printenv | sort'
|
|
|
|
sh 'rm -rf ./tmp/*'
|
2019-12-10 02:37:05 +08:00
|
|
|
}
|
2019-11-28 05:22:59 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
stage('Tests Setup') {
|
|
|
|
steps {
|
2019-12-03 03:14:11 +08:00
|
|
|
timeout(time: 60) {
|
|
|
|
sh 'build/new-jenkins/docker-compose-pull.sh'
|
|
|
|
sh 'build/new-jenkins/docker-compose-build-up.sh'
|
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
2019-09-07 05:01:43 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
stage('Tests') {
|
|
|
|
parallel {
|
|
|
|
stage('Jest') {
|
2020-01-09 06:30:07 +08:00
|
|
|
environment {
|
|
|
|
CONTAINER_NAME = 'tests-jest'
|
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-jest.sh'
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
2019-12-21 04:37:59 +08:00
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
script {
|
|
|
|
if (env.COVERAGE == "1") {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-jest', "./tmp/${env.CONTAINER_NAME}-coverage")
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
stage('Packages') {
|
2020-01-09 06:30:07 +08:00
|
|
|
environment {
|
|
|
|
CONTAINER_NAME = 'tests-packages'
|
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-packages.sh'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'packages', "./tmp/${env.CONTAINER_NAME}")
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-14 02:29:13 +08:00
|
|
|
stage('canvas_quizzes') {
|
|
|
|
steps {
|
|
|
|
sh 'build/new-jenkins/js/tests-quizzes.sh'
|
|
|
|
}
|
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
stage('Karma - Spec Group - coffee') {
|
|
|
|
environment {
|
|
|
|
JSPEC_GROUP = 'coffee'
|
2020-01-09 06:30:07 +08:00
|
|
|
CONTAINER_NAME = 'tests-karma-coffee'
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-karma.sh'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
script {
|
|
|
|
if (env.COVERAGE == "1") {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-karma', "./tmp/${env.CONTAINER_NAME}-coverage")
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Karma - Spec Group - jsa - A-F') {
|
|
|
|
environment {
|
|
|
|
JSPEC_GROUP = 'jsa'
|
2020-01-09 06:30:07 +08:00
|
|
|
CONTAINER_NAME = 'tests-karma-jsa'
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-karma.sh'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
script {
|
|
|
|
if (env.COVERAGE == "1") {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-karma', "./tmp/${env.CONTAINER_NAME}-coverage")
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Karma - Spec Group - jsg - G') {
|
|
|
|
environment {
|
|
|
|
JSPEC_GROUP = 'jsg'
|
2020-01-09 06:30:07 +08:00
|
|
|
CONTAINER_NAME = 'tests-karma-jsg'
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-karma.sh'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
script {
|
|
|
|
if (env.COVERAGE == "1") {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-karma', "./tmp/${env.CONTAINER_NAME}-coverage")
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Karma - Spec Group - jsh - H-Z') {
|
|
|
|
environment {
|
|
|
|
JSPEC_GROUP = 'jsh'
|
2020-01-09 06:30:07 +08:00
|
|
|
CONTAINER_NAME = 'tests-karma-jsh'
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
steps {
|
2019-11-28 05:22:59 +08:00
|
|
|
sh 'build/new-jenkins/js/tests-karma.sh'
|
2019-12-21 04:37:59 +08:00
|
|
|
}
|
|
|
|
post {
|
2020-01-09 06:30:07 +08:00
|
|
|
always {
|
2020-01-17 03:16:25 +08:00
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-js', "./tmp/${env.CONTAINER_NAME}")
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
script {
|
|
|
|
if (env.COVERAGE == "1") {
|
|
|
|
copyFiles(env.CONTAINER_NAME, 'coverage-karma', "./tmp/${env.CONTAINER_NAME}-coverage")
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 06:30:07 +08:00
|
|
|
}
|
2019-08-30 06:03:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-07 03:31:16 +08:00
|
|
|
stage('Upload Coverage') {
|
|
|
|
when { expression { env.COVERAGE == '1' } }
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/js/coverage-report.sh'
|
|
|
|
archiveArtifacts(artifacts: 'coverage-report-js/**/*')
|
|
|
|
uploadCoverage([
|
|
|
|
uploadSource: "/coverage-report-js/report-html",
|
|
|
|
uploadDest: "canvas-lms-js/coverage"
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
2019-08-22 03:12:19 +08:00
|
|
|
post {
|
2019-12-21 04:37:59 +08:00
|
|
|
always {
|
|
|
|
script {
|
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 {
|
2019-12-11 03:58:45 +08:00
|
|
|
sh 'build/new-jenkins/docker-cleanup.sh --allow-failure'
|
2019-08-22 03:12:19 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-16 22:55:14 +08:00
|
|
|
}
|