2020-06-10 18:55:28 +02:00
|
|
|
def projectName = "dft_tools" /* set to app/repo name */
|
2019-04-26 20:25:58 +02:00
|
|
|
|
2020-06-10 17:45:53 +02:00
|
|
|
def dockerName = projectName.toLowerCase();
|
2019-04-26 20:25:58 +02:00
|
|
|
/* which platform to build documentation on */
|
2018-03-23 20:35:56 +01:00
|
|
|
def documentationPlatform = "ubuntu-clang"
|
2019-04-26 20:25:58 +02:00
|
|
|
/* depend on triqs upstream branch/project */
|
2018-02-22 20:16:45 +01:00
|
|
|
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
|
|
|
|
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
|
2019-10-10 19:46:39 +02:00
|
|
|
/* whether to keep and publish the results */
|
|
|
|
def keepInstall = !env.BRANCH_NAME.startsWith("PR-")
|
2018-02-14 22:35:07 +01:00
|
|
|
|
2018-02-12 20:11:41 +01:00
|
|
|
properties([
|
|
|
|
disableConcurrentBuilds(),
|
2018-02-14 22:35:07 +01:00
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
|
2019-10-10 19:46:39 +02:00
|
|
|
pipelineTriggers(keepInstall ? [
|
2018-02-12 20:11:41 +01:00
|
|
|
upstream(
|
|
|
|
threshold: 'SUCCESS',
|
2018-02-14 22:35:07 +01:00
|
|
|
upstreamProjects: triqsProject
|
2018-02-12 20:11:41 +01:00
|
|
|
)
|
2019-10-10 19:46:39 +02:00
|
|
|
] : [])
|
2018-02-12 20:11:41 +01:00
|
|
|
])
|
|
|
|
|
2018-03-23 20:35:56 +01:00
|
|
|
/* map of all builds to run, populated below */
|
2018-02-12 20:11:41 +01:00
|
|
|
def platforms = [:]
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** linux builds (in docker) */
|
|
|
|
/* Each platform must have a cooresponding Dockerfile.PLATFORM in triqs/packaging */
|
2018-02-12 20:11:41 +01:00
|
|
|
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
|
2018-03-23 20:35:56 +01:00
|
|
|
/* .each is currently broken in jenkins */
|
2018-02-12 20:11:41 +01:00
|
|
|
for (int i = 0; i < dockerPlatforms.size(); i++) {
|
|
|
|
def platform = dockerPlatforms[i]
|
2018-03-07 21:27:16 +01:00
|
|
|
platforms[platform] = { -> node('docker') {
|
|
|
|
stage(platform) { timeout(time: 1, unit: 'HOURS') {
|
|
|
|
checkout scm
|
|
|
|
/* construct a Dockerfile for this base */
|
|
|
|
sh """
|
2019-04-26 20:25:58 +02:00
|
|
|
( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins
|
2018-03-07 21:27:16 +01:00
|
|
|
mv -f Dockerfile.jenkins Dockerfile
|
|
|
|
"""
|
|
|
|
/* build and tag */
|
2020-06-15 16:20:40 +02:00
|
|
|
def img = docker.build("flatironinstitute/${dockerName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_DOC=${platform==documentationPlatform} --build-arg BUILD_ID=${env.BUILD_TAG} .")
|
2020-06-10 17:45:53 +02:00
|
|
|
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
|
|
|
|
img.inside() {
|
|
|
|
sh "make -C \$BUILD/${projectName} test CTEST_OUTPUT_ON_FAILURE=1"
|
|
|
|
}
|
|
|
|
}
|
2019-10-10 19:46:39 +02:00
|
|
|
if (!keepInstall) {
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "docker rmi --no-prune ${img.imageName()}"
|
2018-02-12 20:11:41 +01:00
|
|
|
}
|
2018-03-07 21:27:16 +01:00
|
|
|
} }
|
2018-02-22 20:16:45 +01:00
|
|
|
} }
|
2018-02-12 20:11:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** osx builds (on host) */
|
2018-02-14 22:35:07 +01:00
|
|
|
def osxPlatforms = [
|
2020-09-10 01:03:28 +02:00
|
|
|
["gcc", ['CC=gcc-10', 'CXX=g++-10', 'FC=gfortran-10']],
|
|
|
|
["clang", ['CC=$BREW/opt/llvm/bin/clang', 'CXX=$BREW/opt/llvm/bin/clang++', 'FC=gfortran-10', 'CXXFLAGS=-I$BREW/opt/llvm/include', 'LDFLAGS=-L$BREW/opt/llvm/lib']]
|
2018-02-14 22:35:07 +01:00
|
|
|
]
|
|
|
|
for (int i = 0; i < osxPlatforms.size(); i++) {
|
|
|
|
def platformEnv = osxPlatforms[i]
|
|
|
|
def platform = platformEnv[0]
|
2018-03-07 21:27:16 +01:00
|
|
|
platforms["osx-$platform"] = { -> node('osx && triqs') {
|
|
|
|
stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') {
|
|
|
|
def srcDir = pwd()
|
|
|
|
def tmpDir = pwd(tmp:true)
|
|
|
|
def buildDir = "$tmpDir/build"
|
2020-06-15 16:20:40 +02:00
|
|
|
/* install real branches in a fixed predictable place so apps can find them */
|
2019-10-10 19:46:39 +02:00
|
|
|
def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install"
|
2018-03-23 20:35:56 +01:00
|
|
|
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
|
2020-06-15 16:27:45 +02:00
|
|
|
def venv = triqsDir
|
2018-03-07 21:27:16 +01:00
|
|
|
dir(installDir) {
|
|
|
|
deleteDir()
|
|
|
|
}
|
2018-02-14 22:35:07 +01:00
|
|
|
|
2018-03-07 21:27:16 +01:00
|
|
|
checkout scm
|
2020-06-15 16:20:40 +02:00
|
|
|
|
|
|
|
def hdf5 = "${env.BREW}/opt/hdf5@1.10"
|
2018-06-08 18:10:58 +02:00
|
|
|
dir(buildDir) { withEnv(platformEnv[1].collect { it.replace('\$BREW', env.BREW) } + [
|
2020-06-15 16:27:45 +02:00
|
|
|
"PATH=$venv/bin:${env.BREW}/bin:/usr/bin:/bin:/usr/sbin",
|
2020-06-15 16:20:40 +02:00
|
|
|
"HDF5_ROOT=$hdf5",
|
|
|
|
"C_INCLUDE_PATH=$hdf5/include:${env.BREW}/include",
|
2020-06-15 16:27:45 +02:00
|
|
|
"CPLUS_INCLUDE_PATH=$venv/include:$hdf5/include:${env.BREW}/include",
|
|
|
|
"LIBRARY_PATH=$venv/lib:$hdf5/lib:${env.BREW}/lib",
|
2020-06-15 16:20:40 +02:00
|
|
|
"LD_LIBRARY_PATH=$hdf5/lib",
|
2020-09-10 01:32:24 +02:00
|
|
|
"PYTHONPATH=$installDir/lib/python3.8/site-packages",
|
2020-06-15 16:27:45 +02:00
|
|
|
"CMAKE_PREFIX_PATH=$venv/lib/cmake/triqs"]) {
|
2018-03-07 21:27:16 +01:00
|
|
|
deleteDir()
|
2019-10-10 19:46:39 +02:00
|
|
|
/* note: this is installing into the parent (triqs) venv (install dir), which is thus shared among apps and so not be completely safe */
|
2020-06-15 16:20:40 +02:00
|
|
|
sh "pip3 install -U -r $srcDir/requirements.txt"
|
|
|
|
sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir -DBuild_Deps=Always"
|
2020-06-10 17:45:53 +02:00
|
|
|
sh "make -j2"
|
|
|
|
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { try {
|
2018-11-29 22:01:39 +01:00
|
|
|
sh "make test CTEST_OUTPUT_ON_FAILURE=1"
|
2018-03-07 21:27:16 +01:00
|
|
|
} catch (exc) {
|
|
|
|
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
|
|
|
|
throw exc
|
2020-06-10 17:45:53 +02:00
|
|
|
} }
|
2018-03-07 21:27:16 +01:00
|
|
|
sh "make install"
|
|
|
|
} }
|
|
|
|
} }
|
2018-02-22 20:16:45 +01:00
|
|
|
} }
|
2018-02-14 22:35:07 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** wrap-up */
|
2020-08-03 17:23:34 +02:00
|
|
|
def error = null
|
2018-02-22 23:48:32 +01:00
|
|
|
try {
|
|
|
|
parallel platforms
|
2019-10-10 19:46:39 +02:00
|
|
|
if (keepInstall) { node("docker") {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Publish results */
|
2019-10-10 19:46:39 +02:00
|
|
|
stage("publish") { timeout(time: 5, unit: 'MINUTES') {
|
2018-03-23 20:35:56 +01:00
|
|
|
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
2019-04-26 20:25:58 +02:00
|
|
|
def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim()
|
2020-06-10 17:45:53 +02:00
|
|
|
def workDir = pwd(tmp:true)
|
2019-10-10 19:46:39 +02:00
|
|
|
lock('triqs_publish') {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Update documention on gh-pages branch */
|
2018-03-23 20:35:56 +01:00
|
|
|
dir("$workDir/gh-pages") {
|
2018-06-22 17:07:34 +02:00
|
|
|
def subdir = "${projectName}/${env.BRANCH_NAME}"
|
|
|
|
git(url: "ssh://git@github.com/TRIQS/TRIQS.github.io.git", branch: "master", credentialsId: "ssh", changelog: false)
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "rm -rf ${subdir}"
|
2020-06-10 17:45:53 +02:00
|
|
|
docker.image("flatironinstitute/${dockerName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() {
|
|
|
|
sh """#!/bin/bash -ex
|
|
|
|
base=\$INSTALL/share/doc
|
|
|
|
dir="${projectName}"
|
|
|
|
[[ -d \$base/triqs_\$dir ]] && dir=triqs_\$dir || [[ -d \$base/\$dir ]]
|
|
|
|
cp -rp \$base/\$dir ${subdir}
|
|
|
|
"""
|
2018-03-07 21:27:16 +01:00
|
|
|
}
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "git add -A ${subdir}"
|
|
|
|
sh """
|
2018-06-22 17:07:34 +02:00
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}'
|
2018-03-23 20:35:56 +01:00
|
|
|
"""
|
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2019-10-10 19:46:39 +02:00
|
|
|
sh "git push origin master"
|
2018-03-23 20:35:56 +01:00
|
|
|
}
|
2019-04-29 17:55:14 +02:00
|
|
|
/* Update packaging repo submodule */
|
|
|
|
if (release) { dir("$workDir/packaging") { try {
|
|
|
|
git(url: "ssh://git@github.com/TRIQS/packaging.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false)
|
2018-03-23 20:35:56 +01:00
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2019-10-10 19:46:39 +02:00
|
|
|
sh """#!/bin/bash -ex
|
|
|
|
dir="${projectName}"
|
|
|
|
[[ -d triqs_\$dir ]] && dir=triqs_\$dir || [[ -d \$dir ]]
|
|
|
|
echo "160000 commit ${commit}\t\$dir" | git update-index --index-info
|
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
|
|
|
|
git push origin ${env.BRANCH_NAME}
|
|
|
|
"""
|
2018-03-23 20:35:56 +01:00
|
|
|
} catch (err) {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Ignore, non-critical -- might not exist on this branch */
|
2019-04-29 17:55:14 +02:00
|
|
|
echo "Failed to update packaging repo"
|
2019-04-26 20:25:58 +02:00
|
|
|
} } }
|
2019-10-10 19:46:39 +02:00
|
|
|
}
|
2018-03-23 20:35:56 +01:00
|
|
|
} }
|
|
|
|
} }
|
2018-02-22 23:48:32 +01:00
|
|
|
} catch (err) {
|
2020-08-03 17:23:34 +02:00
|
|
|
error = err
|
|
|
|
} finally {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* send email on build failure (declarative pipeline's post section would work better) */
|
2020-08-03 17:23:34 +02:00
|
|
|
if ((error != null || currentBuild.currentResult != 'SUCCESS') && env.BRANCH_NAME != "jenkins") emailext(
|
2018-02-22 23:48:32 +01:00
|
|
|
subject: "\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED",
|
|
|
|
body: """\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED
|
|
|
|
|
|
|
|
Check console output at \$BUILD_URL to view full results.
|
|
|
|
|
|
|
|
Building \$BRANCH_NAME for \$CAUSE
|
|
|
|
\$JOB_DESCRIPTION
|
|
|
|
|
2018-11-29 22:01:39 +01:00
|
|
|
Changes:
|
2018-02-22 23:48:32 +01:00
|
|
|
\$CHANGES
|
|
|
|
|
|
|
|
End of build log:
|
|
|
|
\${BUILD_LOG,maxLines=60}
|
|
|
|
""",
|
2020-08-08 22:23:28 +02:00
|
|
|
to: 'mzingl@flatironinstitute.org, ahampel@flatironinstitute.org, nwentzell@flatironinstitute.org, dsimon@flatironinstitute.org',
|
2018-02-22 23:48:32 +01:00
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'DevelopersRecipientProvider'],
|
|
|
|
],
|
|
|
|
replyTo: '$DEFAULT_REPLYTO'
|
|
|
|
)
|
2020-08-03 17:23:34 +02:00
|
|
|
if (error != null) throw error
|
2018-02-22 23:48:32 +01:00
|
|
|
}
|