-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathJenkinsfile.js
More file actions
106 lines (94 loc) · 3.88 KB
/
Jenkinsfile.js
File metadata and controls
106 lines (94 loc) · 3.88 KB
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
#!/usr/bin/env groovy
/*
* Copyright (C) 2026 - 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/>.
*/
library "canvas-builds-library@${env.CANVAS_BUILDS_REFSPEC}"
loadLocalLibrary('local-lib', 'build/new-jenkins/library')
env.BUILD_REGISTRY_FQDN = configuration.buildRegistryFQDN()
env.COMPOSE_FILE = 'docker-compose.new-jenkins-js.yml'
env.DOCKER_BUILDKIT = 1
env.FORCE_FAILURE = commitMessageFlag('force-failure-js').asBooleanInteger()
env.SELENIUM_NODE_IMAGE = '948781806214.dkr.ecr.us-east-1.amazonaws.com/docker.io/selenium/node-chromium:145.0'
env.SELENIUM_HUB_IMAGE = '948781806214.dkr.ecr.us-east-1.amazonaws.com/docker.io/selenium/hub:4.41.0'
node(nodeLabel()) {
timeout(time: 20, unit: 'MINUTES') {
ansiColor('xterm') {
timestamps {
def tests = [:]
try {
for (int i = 0; i < jsTestsStage.VITEST_NODE_COUNT; i++) {
def indexPadded = String.format('%02d', i)
def stageName = "Vitest ${indexPadded}"
tests[stageName] = {
jsTestsStage.runVitestNode(indexPadded)
}
}
// Packages runs on the main coordinator node
tests['Packages'] = {
def stageName = 'Packages'
def stageStartTime = System.currentTimeMillis()
try {
stage("${stageName} - Cleanup") {
pipelineHelpers.cleanupWorkspace()
}
stage("${stageName} - Setup") {
distribution.unstashBuildScripts()
jsTestsStage.provisionDocker()
jsTestsStage.startServices()
}
def envVars = [
"FORCE_FAILURE=${env.FORCE_FAILURE}",
"RAILS_ENV=test",
"TEST_RESULT_OUTPUT_DIR=js-results/packages"
]
def envFlags = envVars.collect { "-e ${it}" }.join(' ')
stage("${stageName} - Run Tests") {
try {
sh("docker compose -f ${env.COMPOSE_FILE} exec -T ${envFlags} canvas bash -c 'TEST_RESULT_OUTPUT_DIR=/usr/src/app/\$TEST_RESULT_OUTPUT_DIR yarn test:packages'")
} finally {
pipelineHelpers.copyFromContainer('canvas', '/usr/src/app/js-results/packages', './js-results/packages')
archiveArtifacts artifacts: "js-results/packages/**/*.xml"
junit "js-results/packages/**/*.xml"
if (env.COVERAGE == '1') {
jsTestsStage.collectCoverage('Packages')
}
}
}
} finally {
pipelineHelpers.cleanupDocker()
}
}
stage('Checkout') {
jsTestsStage.checkoutCode()
distribution.stashBuildScripts()
}
parallel(tests)
} finally {
// Collect all build summary data on coordinator node after parallel stages complete
stage('Collect Build Summary Data') {
// Analyze the entire JS build from the coordinator node
tests.each { stageName, closure ->
buildSummaryReport.addFailureRun(stageName, currentBuild)
buildSummaryReport.addRunTestActions(stageName, currentBuild)
}
}
buildSummaryReport.saveRunManifest()
}
}
}
}
}