forked from TRIQS/triqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
146 lines (132 loc) · 5.22 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def projectName = "triqs"
def documentationPlatform = "ubuntu-clang"
def keepInstall = !env.BRANCH_NAME.startsWith("PR-")
properties([
disableConcurrentBuilds(),
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30'))
])
/* map of all builds to run, populated below */
def platforms = [:]
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
/* .each is currently broken in jenkins */
for (int i = 0; i < dockerPlatforms.size(); i++) {
def platform = dockerPlatforms[i]
platforms[platform] = { -> node('docker') {
stage(platform) { timeout(time: 1, unit: 'HOURS') {
checkout scm
/* construct a Dockerfile for this base */
sh """
( cat packaging/Dockerfile.${env.STAGE_NAME} ; sed '0,/^FROM /d' Dockerfile.build ) > Dockerfile
"""
/* build and tag */
def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg BUILD_DOC=${platform==documentationPlatform} .")
if (!keepInstall) {
sh "docker rmi --no-prune ${img.imageName()}"
}
} }
} }
}
def osxPlatforms = [
["gcc", ['CC=gcc-7', 'CXX=g++-7']],
["clang", ['CC=$BREW/opt/llvm/bin/clang', 'CXX=$BREW/opt/llvm/bin/clang++', 'CXXFLAGS=-I$BREW/opt/llvm/include', 'LDFLAGS=-L$BREW/opt/llvm/lib']]
]
for (int i = 0; i < osxPlatforms.size(); i++) {
def platformEnv = osxPlatforms[i]
def platform = platformEnv[0]
platforms["osx-$platform"] = { -> node('osx && triqs') {
stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') {
def workDir = pwd()
def tmpDir = pwd(tmp:true)
def cpp2pyDir = "$tmpDir/cpp2py"
def buildDir = "$tmpDir/build"
/* install real branches in a fixed predictable place so apps can find them */
def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install"
checkout scm
dir(cpp2pyDir) {
/* should we make this a proper submodule? */
git(url: 'https://github.com/TRIQS/cpp2py', branch: 'master')
}
dir(buildDir) { withEnv(platformEnv[1].collect { it.replace('\$BREW', env.BREW) } + [
"PATH=$installDir/bin:${env.BREW}/bin:/usr/bin:/bin:/usr/sbin",
"C_INCLUDE_PATH=${env.BREW}/include",
"CPLUS_INCLUDE_PATH=$installDir/include:${env.BREW}/include",
"LIBRARY_PATH=$installDir/lib:${env.BREW}/lib",
"CMAKE_PREFIX_PATH=$installDir/lib/cmake/triqs"]) {
deleteDir()
sh """#!/bin/bash -ex
virtualenv $installDir
pip install --no-binary=h5py,mpi4py -r $workDir/packaging/requirements.txt
cmake $cpp2pyDir -DCMAKE_INSTALL_PREFIX=$installDir
make -j3
make install
rm -rf *
"""
sh "cmake $workDir -DCMAKE_INSTALL_PREFIX=$installDir"
sh "make -j3"
try {
sh "make test CTEST_OUTPUT_ON_FAILURE=1"
} catch (exc) {
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
throw exc
}
sh "make install"
} }
} }
} }
}
try {
parallel platforms
if (keepInstall) {
node("docker") {
stage("publish") { timeout(time: 1, unit: 'HOURS') {
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def workDir = pwd()
dir("$workDir/gh-pages") {
def subdir = "${projectName}/${env.BRANCH_NAME}"
git(url: "ssh://[email protected]/TRIQS/TRIQS.github.io.git", branch: "master", credentialsId: "ssh", changelog: false)
sh "rm -rf ${subdir}"
docker.image("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() {
sh "cp -rp \$INSTALL/share/doc/${projectName} ${subdir}"
}
sh "git add -A ${subdir}"
sh """
git commit --author='Flatiron Jenkins <[email protected]>' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}'
"""
// note: credentials used above don't work (need JENKINS-28335)
sh "git push origin master"
}
dir("$workDir/docker") { try {
git(url: "ssh://[email protected]/TRIQS/docker.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false)
sh "echo '160000 commit ${commit}\t${projectName}' | git update-index --index-info"
sh """
git commit --author='Flatiron Jenkins <[email protected]>' --allow-empty -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
"""
// note: credentials used above don't work (need JENKINS-28335)
sh "git push origin ${env.BRANCH_NAME}"
} catch (err) {
echo "Failed to update docker repo"
} }
} }
}
}
} catch (err) {
if (env.BRANCH_NAME != "jenkins") emailext(
subject: "\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED",
body: """\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED
$err
Check console output at \$BUILD_URL to view full results.
Building \$BRANCH_NAME for \$CAUSE
\$JOB_DESCRIPTION
Chages:
\$CHANGES
End of build log:
\${BUILD_LOG,maxLines=60}
""",
recipientProviders: [
[$class: 'DevelopersRecipientProvider'],
],
replyTo: '$DEFAULT_REPLYTO'
)
throw err
}