forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
132 lines (130 loc) · 5.35 KB
/
Jenkinsfile
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
128
129
130
131
132
def runPythonTests() {
sshagent(credentials: ['jenkins-worker', 'jenkins-worker-pem'], ignoreMissing: true) {
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '${ghprbActualCommit}']],
doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'jenkins-worker',
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*',
url: '[email protected]:edx/edx-platform.git']]]
console_output = sh(returnStdout: true, script: 'bash scripts/all-tests.sh').trim()
dir('stdout') {
writeFile file: "${TEST_SUITE}-stdout.log", text: console_output
}
stash includes: 'reports/**/*coverage*', name: "${TEST_SUITE}-reports"
}
}
def pythonTestCleanup() {
archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/**/*,test_root/log/**/*.log,**/nosetests.xml,stdout/*.log,*.log'
junit '**/nosetests.xml'
sh '''source $HOME/edx-venv/bin/activate
bash scripts/xdist/terminate_xdist_nodes.sh'''
}
pipeline {
agent { label "coverage-worker" }
options {
timestamps()
timeout(60)
}
environment {
XDIST_CONTAINER_SUBNET = credentials('XDIST_CONTAINER_SUBNET')
XDIST_CONTAINER_SECURITY_GROUP = credentials('XDIST_CONTAINER_SECURITY_GROUP')
XDIST_CONTAINER_TASK_NAME = "jenkins-worker-task"
XDIST_GIT_BRANCH = "${ghprbActualCommit}"
}
stages {
stage('Run Tests') {
parallel {
stage("lms-unit") {
agent { label "jenkins-worker" }
environment {
TEST_SUITE = "lms-unit"
XDIST_NUM_TASKS = 10
XDIST_REMOTE_NUM_PROCESSES = 2
}
steps {
script {
runPythonTests()
}
}
post {
always {
script {
pythonTestCleanup()
}
}
}
}
stage("cms-unit") {
agent { label "jenkins-worker" }
environment {
TEST_SUITE = "cms-unit"
XDIST_NUM_TASKS = 4
XDIST_REMOTE_NUM_PROCESSES = 2
}
steps {
script {
runPythonTests()
}
}
post {
always {
script {
pythonTestCleanup()
}
}
}
}
stage("commonlib-unit") {
agent { label "jenkins-worker" }
environment {
TEST_SUITE = "commonlib-unit"
XDIST_NUM_TASKS = 3
XDIST_REMOTE_NUM_PROCESSES = 2
}
steps {
script {
runPythonTests()
}
}
post {
always {
script {
pythonTestCleanup()
}
}
}
}
}
}
stage('Run coverage') {
environment {
CODE_COV_TOKEN = credentials('CODE_COV_TOKEN')
TARGET_BRANCH = "origin/master"
CI_BRANCH = "${ghprbSourceBranch}"
SUBSET_JOB = "null" // Keep this variable until we can remove the $SUBSET_JOB path from .coveragerc
}
steps {
sshagent(credentials: ['jenkins-worker'], ignoreMissing: true) {
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '${ghprbActualCommit}']],
doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'jenkins-worker',
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*',
url: '[email protected]:edx/edx-platform.git']]]
unstash 'lms-unit-reports'
unstash 'cms-unit-reports'
unstash 'commonlib-unit-reports'
sh "./scripts/jenkins-report.sh"
}
}
post {
always {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true,
reportDir: 'reports', reportFiles: 'diff_coverage_combined.html',
reportName: 'Diff Coverage Report', reportTitles: ''])
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true,
reportDir: 'reports/cover', reportFiles: 'index.html',
reportName: 'Coverage.py Report', reportTitles: ''])
}
}
}
}
}