-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjson_benchmarks_1
308 lines (271 loc) · 12.5 KB
/
json_benchmarks_1
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
pipeline {
agent {
node {
label 'khjson1'
}
}
// agent {
// docker {
// image 'cppalliance/boost_superproject_build:24.04-v3'
// // label 'jenkinspool1'
// }
// }
stages {
stage('Preclean Workspace') {
steps {
sh """#!/bin/bash
set -xe
rm -rf * .*
"""
// checkout scm
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: scm.userRemoteConfigs[0].credentialsId, url: scm.userRemoteConfigs[0].url, refspec: scm.userRemoteConfigs[0].refspec + ' +refs/heads/*:refs/remotes/origin/*' ]]
])
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'Infrastructure-Docs']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'github-cppalliance-bot', url: 'https://github.com/cppalliance/Infrastructure-Docs']]
])
}
}
stage('Set Variables') {
steps {
sh '''#!/bin/bash -xe
echo "" > jenkinsjobinfo.sh
chmod 777 jenkinsjobinfo.sh
REPONAME=$(basename -s .git "$(git config --get remote.origin.url)")
# REPONAME=$(basename `git rev-parse --show-toplevel`)
DNSREPONAME=$(echo $REPONAME | tr '_' '-')
ORGANIZATION=$(basename $(dirname "${GIT_URL}"))
if [[ "${GIT_URL}" =~ sdarwin ]]; then
# testing environment
echo "export JENKINS_CI_REPO=sdarwin/jenkins-ci" >> jenkinsjobinfo.sh
echo "export JENKINS_CI_REPO_BRANCH=testing" >> jenkinsjobinfo.sh
else
# standard
echo "export JENKINS_CI_REPO=cppalliance/jenkins-ci" >> jenkinsjobinfo.sh
echo "export JENKINS_CI_REPO_BRANCH=master" >> jenkinsjobinfo.sh
fi
echo "export REPONAME=${REPONAME}" >> jenkinsjobinfo.sh
echo "export DNSREPONAME=${DNSREPONAME}" >> jenkinsjobinfo.sh
echo "export ORGANIZATION=${ORGANIZATION}" >> jenkinsjobinfo.sh
'''
}
}
stage('Diagnostics') {
steps {
sh '''#!/bin/bash
set -x
# not set -e. errors may occur in diagnostics
cat jenkinsjobinfo.sh
. jenkinsjobinfo.sh
ls -al
cat /etc/os-release
pwd
env
whoami
touch $(date "+%A-%B-%d-%T-%y")
mount | grep ^/dev/ | grep -v /etc | awk '{print \$3}'
git branch
git branch -avv
true
'''
}
}
stage('Prebuild script') {
when {
anyOf{
branch 'develop'
branch 'master'
expression { env.CHANGE_ID != null }
}
}
steps {
sh '''#!/bin/bash
set -xe
. jenkinsjobinfo.sh
curl -f -o jenkins_prebuild_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_benchmarks_prebuild.sh || true
if [ -f jenkins_prebuild_script.sh ]; then
chmod 755 jenkins_prebuild_script.sh
./jenkins_prebuild_script.sh
fi
'''
}
}
// To skip this step, and actually all steps, adjust the job's Filter regex in the Jenkins UI
// (develop|master|PR-.*) will build all branches
// (PR-.*) will build pull requests. Etc.
stage('Run benchmarks') {
when {
anyOf{
expression { env.CHANGE_ID != null }
}
}
steps {
sh '''#!/bin/bash
set -xe
. jenkinsjobinfo.sh
export pythonvirtenvpath=/opt/venvboostdocs
if [ -f ${pythonvirtenvpath}/bin/activate ]; then
source ${pythonvirtenvpath}/bin/activate
fi
# Is there a custom build script? Often not. But let's check:
curl -f -o jenkins_build_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_benchmarks_build.sh || true
if [ -f jenkins_build_script.sh ]; then
chmod 755 jenkins_build_script.sh
./jenkins_build_script.sh
exit 0
fi
# Otherwise, proceed using standard build steps:
export WORKSPACE_ROOT=$(pwd -P)
# update json bench submodules
cd bench
./clone.sh
cd $WORKSPACE_ROOT
# /opt/github/boost needs to already be present. Manual setup.
cd /opt/github/boost
export BOOST_ROOT=$(pwd -P)
git pull
git submodule update --init -f
# Obsolete comments: this type of section could be used to download boost manually:
# if [ ! -d boost-root ]; then
# git clone -b master https://github.com/boostorg/boost.git boost-root
# fi
# cd boost-root
# export BOOST_ROOT=$(pwd -P)
# git pull
# git submodule update --init --recursive
rsync -av --delete $WORKSPACE_ROOT/ libs/json > /dev/null 2>&1
./bootstrap.sh
# ./b2 headers
./b2 toolset=clang variant=release cxxstd=latest headers
cd $WORKSPACE_ROOT/Infrastructure-Docs/benchmarks/json
# heredoc is not disrupting indentation
cat >config.ini <<EOL
[section1]
resultdestinationdir = /var/www/html/jsonbenchmarks-pullrequests/${CHANGE_ID}
initialcheckoutrepository = false
jsonhome = "$BOOST_ROOT/libs/json"
numberofcommitstoparse = 1
numberofrunstocompare = 1
printpullrequests = true
# benchcommand = "sudo cset shield --exec -- nice -n -20 sudo -u nodejenkins ./bench -i:b *.json"
benchcommand = "sudo cgexec -g memory,cpu:shield sudo -u nodejenkins ./bench -n:6 -i:b *.json"
rsyncdestinationdir = "/var/www/html/jsonbenchmarks-pullrequests/"
pinnedcommits = ""
pullrequest = true
mergemsvc = false
EOL
# printmergedresultspercommit = false
# printmergedresultsacrosscommits = false
# benchcommand = "./bench -t:s -i:b -n:1 twitter.json"
# benchcommand = "./bench -n:1 *.json"
# earlier production benchcommand:
# benchcommand = "sudo nice -n -20 sudo -u nodejenkins ./bench -i:b *.json"
# Unfortunately, there seem to be difficulties injecting env variables
# into docker containers. Consider changing this later.
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Place the 'benchmarks' ssh private key in ~/.ssh/benchmarks
# Already done on that server. Removing the step from the job since
# this file will be hosted in a gh public repository.
# echo ___ | base64 -d > ~/.ssh/benchmarks
# chmod 600 ~/.ssh/benchmarks
./runbenchmarks.py
'''
}
}
stage('Postbuild script') {
when {
anyOf{
branch 'develop'
branch 'master'
expression { env.CHANGE_ID != null }
}
}
steps {
sh '''#!/bin/bash
set -xe
. jenkinsjobinfo.sh
curl -f -o jenkins_postbuild_script.sh https://raw.githubusercontent.com/${JENKINS_CI_REPO}/${JENKINS_CI_REPO_BRANCH}/scripts/${ORGANIZATION}_${REPONAME}_benchmarks_postbuild.sh || true
if [ -f jenkins_postbuild_script.sh ]; then
chmod 755 jenkins_postbuild_script.sh
./jenkins_postbuild_script.sh
fi
'''
}
}
stage('Pull requests: comment in PR') {
when {
anyOf{
expression { env.CHANGE_ID != null }
}
}
environment {
// See https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
PNGNAME = """${sh(
returnStdout: true,
script: '#!/bin/bash \n' + 'source Infrastructure-Docs/benchmarks/json/tmp/pngpropertiesfile; echo -n "${PNGNAME}"'
)}"""
}
steps {
script {
commenttext = "![pullrequest](https://benchmark.cppalliance.org/jsonbenchmarks-pullrequests/${env.CHANGE_ID}/${env.PNGNAME})\n Benchmark test results. More info at [https://benchmark.cppalliance.org/jsonbenchmarks-pullrequests/${env.CHANGE_ID}/pullrequest.html](https://benchmark.cppalliance.org/jsonbenchmarks-pullrequests/${env.CHANGE_ID}/pullrequest.html)"
pullRequest.comment(commenttext)
}
}
}
stage('Post Diagnostics') {
steps {
sh '''#!/bin/bash
set -x
# not set -e. errors may occur in diagnostics
cat jenkinsjobinfo.sh
. jenkinsjobinfo.sh
ls -al
cat /etc/os-release
pwd
env
whoami
touch $(date "+%A-%B-%d-%T-%y")
mount | grep ^/dev/ | grep -v /etc | awk '{print \$3}'
git branch
git branch -avv
true
'''
}
}
}
post {
always {
echo 'This will always run'
}
success {
echo 'This will run only if successful'
// no email on success
// mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "SUCCESS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
}
failure {
echo 'This will run only if failure'
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
}
unstable {
echo 'This will run only if the run was marked as unstable'
mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "UNSTABLE STATUS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
// no email on changed status
// mail bcc: '', body: "<b>Example</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL of the build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "CHANGED STATUS CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
}
}
}