-
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathJenkinsfile
More file actions
154 lines (144 loc) · 5.94 KB
/
Copy pathJenkinsfile
File metadata and controls
154 lines (144 loc) · 5.94 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
properties([
disableConcurrentBuilds(abortPrevious: !params.downstream),
buildDiscarder(logRotator(numToKeepStr: '20', daysToKeepStr: '30')),
parameters([
string(defaultValue: '', name: 'stan_pr',
description: "Stan PR to test against. Will check out this PR in the downstream Stan repo."),
string(defaultValue: '', name: 'math_pr',
description: "Math PR to test against. Will check out this PR in the downstream Math repo."),
string(defaultValue: 'nightly', name: 'stanc3_bin_url',
description: 'Custom stanc3 binary url'),
booleanParam(defaultValue: false, name: 'downsteam', description: 'Run downstream tests from stan (was previously downstream_hotfix [master]/downstream_tests [develop])'),
booleanParam(defaultValue: false, name: 'run_all', description: 'Pretend all files changes'),
])
])
def commit
def runRemainingStages = false
def WIN_CXX = 'g++'
def MPI_CXX = 'mpicxx.openmpi'
def MAC_CXX = 'clang++'
def WINSETENV = '''
SET "PATH=%RTOOLS%\\x86_64-w64-mingw32.static.posix\\bin;%RTOOLS%;%RTOOLS%\\usr\\bin;%CONDA%;%PATH%"
'''
catchError {
withEnv([
'GIT_AUTHOR_NAME=Stan Jenkins',
'GIT_AUTHOR_EMAIL=mc.stanislaw@gmail.com',
'GIT_COMMITTER_NAME=Stan Jenkins',
'GIT_COMMITTER_EMAIL=mc.stanislaw@gmail.com'
]) {
runPod(image: "stanorg/ci:gpu", cpus: 2) {
commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
runRemainingStages = params.downstream || params.run_all || filesChanged('src/cmdstan', 'src/test', 'lib', 'examples', 'make', 'stan', 'install-tbb.bat', 'makefile', 'runCmdStanTests.py', 'test-all.sh', 'Jenkinsfile')
stage('clang-format') {
def dirty = sh returnStatus: true, script: """
clang-format --version
git ls-files 'src/*.hpp' 'src/*.cpp' | xargs -n20 -P\$PARALLEL clang-format -i
git diff --exit-code
"""
if (dirty) {
def branch = env.CHANGE_BRANCH ?: env.BRANCH_NAME
def repo = env.CHANGE_FORK ?: "stan-dev"
if (!("/" in repo))
repo += "/cmdstan.git"
echo "Exiting build because clang-format found changes."
emailext (
subject: "[StanJenkins] Autoformattted: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """
Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' has been autoformatted and the
changes committed to your branch, if permissions allowed. Please pull these
changes before continuing.
See https://github.com/stan-dev/stan/wiki/Coding-Style-and-Idioms for setting
up the autoformatter locally. (Check console output at ${env.BUILD_URL})
""",
recipientProviders: [[$class: 'RequesterRecipientProvider']],
to: env.CHANGE_AUTHOR_EMAIL)
sh '''
git add -u src
git commit -m "[Jenkins] auto-formatting by `clang-format --version`"
'''
gitPush(gitScm: scmGit(
userRemoteConfigs: [[credentialsId: "stan-github", name: 'dest', url: "https://github.com/$repo"]],
branches: [[name: "refs/heads/$branch"]]),
targetBranch: branch,
targetRepo: 'dest')
echo "Those changes are now found on stan-dev/cmdstan under $repo branch $branch"
echo "Please 'git pull' before continuing to develop."
error "clang-format changes"
}
}
}
def scmFull = scmGit(
branches: scm.branches,
userRemoteConfigs: scm.userRemoteConfigs,
extensions: scm.extensions + [cleanBeforeCheckout(),
submodule(recursiveSubmodules: true, shallow: true, depth: 2)])
def prepTests = { extra ->
checkout scmFull
checkoutPR("stan", params.stan_pr)
checkoutPR("stan/lib/stan_math", params.math_pr)
def local = "CXXFLAGS+=-Wp,-D_GLIBCXX_ASSERTIONS -Werror -Wno-unused-command-line-argument\n"
if (params.stanc3_bin_url != "nightly") {
local += "STANC3_TEST_BIN_URL=${params.stanc3_bin_url}\n"
}
writeFile(file: "make/local", text: local + extra)
}
if (runRemainingStages) {
parallel windows: {
node('windows') {
stage('Windows interface tests') {
prepTests("CXX=${WIN_CXX}")
withEnv(["PATH+TBB=${WORKSPACE}\\stan\\lib\\stan_math\\lib\\tbb"]) {
bat """$WINSETENV
python runCmdStanTests.py -j%PARALLEL% src/test/interface
"""
}
}
}
}, linux: {
runPod(image: "stanorg/ci:gpu", checkout: false) {
stage('Linux interface tests with MPI') {
prepTests("""CXX=${MPI_CXX}
STAN_MPI=true
CXX_TYPE=gcc""")
sh "make build-mpi > build-mpi.log 2>&1"
sh './runCmdStanTests.py -j$PARALLEL src/test/interface'
}
}
}, mac: {
node('macos') {
stage('Mac interface tests') {
prepTests("CXX=${MAC_CXX}")
sh 'python3 ./runCmdStanTests.py -j$PARALLEL src/test/interface'
}
}
}, upstream: {
if (params.downstream || env.CHANGE_TARGET) {
stage('Upstream CmdStan Performance tests') {
build(
job: "CCM/Stan/performance-tests-cmdstan/master",
parameters: [
booleanParam(name: 'downstream', value: true),
string(name: 'cmdstan_pr', value: env.BRANCH_NAME),
string(name: 'stan_pr', value: params.stan_pr),
string(name: 'math_pr', value: params.math_pr),
string(name: 'stanc3_bin_url', value: params.stanc3_bin_url),
],
wait: true)
}
}
}
/* TODO recordIssues? */
}
if (env.BRANCH_NAME == 'develop') {
podTemplate(inheritFrom: 'jnlp') {
node(POD_LABEL) {
stage('Update performance tests submodule') {
updateSubmodule('performance-tests-cmdstan', 'master', 'cmdstan', commit)
}
}
}
}
}
}
emailFailure()