2018-04-06 17:27:06 +02:00
|
|
|
def projectName = "app4triqs" /* set to app/repo name */
|
|
|
|
|
2020-01-28 17:33:55 +01:00
|
|
|
def dockerName = projectName.toLowerCase();
|
2018-04-06 17:27:06 +02:00
|
|
|
/* which platform to build documentation on */
|
2018-03-23 20:30:28 +01:00
|
|
|
def documentationPlatform = "ubuntu-clang"
|
2018-04-06 17:27:06 +02:00
|
|
|
/* depend on triqs upstream branch/project */
|
2018-03-23 20:30:28 +01:00
|
|
|
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
|
|
|
|
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
|
2019-07-26 20:01:22 +02:00
|
|
|
/* whether to keep and publish the results */
|
|
|
|
def keepInstall = !env.BRANCH_NAME.startsWith("PR-")
|
2018-03-22 18:11:39 +01:00
|
|
|
|
|
|
|
properties([
|
|
|
|
disableConcurrentBuilds(),
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
|
2019-08-20 22:01:55 +02:00
|
|
|
pipelineTriggers(keepInstall ? [
|
2018-03-22 18:11:39 +01:00
|
|
|
upstream(
|
|
|
|
threshold: 'SUCCESS',
|
2018-03-23 20:30:28 +01:00
|
|
|
upstreamProjects: triqsProject
|
2018-03-22 18:11:39 +01:00
|
|
|
)
|
2019-08-20 22:01:55 +02:00
|
|
|
] : [])
|
2018-03-22 18:11:39 +01:00
|
|
|
])
|
|
|
|
|
2018-03-23 20:30:28 +01:00
|
|
|
/* map of all builds to run, populated below */
|
2018-03-22 18:11:39 +01:00
|
|
|
def platforms = [:]
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** linux builds (in docker) */
|
|
|
|
/* Each platform must have a cooresponding Dockerfile.PLATFORM in triqs/packaging */
|
2018-03-22 18:11:39 +01:00
|
|
|
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
|
2018-03-23 20:30:28 +01:00
|
|
|
/* .each is currently broken in jenkins */
|
2018-03-22 18:11:39 +01:00
|
|
|
for (int i = 0; i < dockerPlatforms.size(); i++) {
|
|
|
|
def platform = dockerPlatforms[i]
|
2021-06-03 20:39:01 +02:00
|
|
|
platforms[platform] = { -> node('linux && docker && triqs') {
|
|
|
|
stage(platform) { timeout(time: 1, unit: 'HOURS') { ansiColor('xterm') {
|
2018-06-22 17:15:27 +02:00
|
|
|
checkout scm
|
|
|
|
/* construct a Dockerfile for this base */
|
|
|
|
sh """
|
|
|
|
( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins
|
|
|
|
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-05-20 01:19:19 +02:00
|
|
|
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
|
|
|
|
img.inside() {
|
|
|
|
sh "make -C \$BUILD/${projectName} test CTEST_OUTPUT_ON_FAILURE=1"
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 20:01:22 +02:00
|
|
|
if (!keepInstall) {
|
2018-03-23 20:30:28 +01:00
|
|
|
sh "docker rmi --no-prune ${img.imageName()}"
|
2018-06-01 17:10:49 +02:00
|
|
|
}
|
2021-06-03 20:39:01 +02:00
|
|
|
} } }
|
2018-03-23 20:30:28 +01:00
|
|
|
} }
|
2018-03-22 18:11:39 +01:00
|
|
|
}
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** osx builds (on host) */
|
2018-03-22 18:11:39 +01:00
|
|
|
def osxPlatforms = [
|
2021-05-27 23:27:11 +02:00
|
|
|
["gcc", ['CC=gcc-11', 'CXX=g++-11', 'FC=gfortran-11']],
|
|
|
|
["clang", ['CC=$BREW/opt/llvm/bin/clang', 'CXX=$BREW/opt/llvm/bin/clang++', 'FC=gfortran-11', 'CXXFLAGS=-I$BREW/opt/llvm/include', 'LDFLAGS=-L$BREW/opt/llvm/lib']]
|
2018-03-22 18:11:39 +01:00
|
|
|
]
|
|
|
|
for (int i = 0; i < osxPlatforms.size(); i++) {
|
|
|
|
def platformEnv = osxPlatforms[i]
|
|
|
|
def platform = platformEnv[0]
|
2018-03-23 20:30:28 +01:00
|
|
|
platforms["osx-$platform"] = { -> node('osx && triqs') {
|
2021-06-03 20:39:01 +02:00
|
|
|
stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') { ansiColor('xterm') {
|
2018-03-23 20:30:28 +01:00
|
|
|
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-07-26 20:01:22 +02:00
|
|
|
def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install"
|
2018-03-23 20:30:28 +01:00
|
|
|
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
|
2020-06-15 16:27:45 +02:00
|
|
|
def venv = triqsDir
|
2018-03-23 20:30:28 +01:00
|
|
|
dir(installDir) {
|
|
|
|
deleteDir()
|
|
|
|
}
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2018-03-23 20:30:28 +01:00
|
|
|
checkout scm
|
2020-06-15 16:20:40 +02:00
|
|
|
|
|
|
|
def hdf5 = "${env.BREW}/opt/hdf5@1.10"
|
2018-06-08 16:40:39 +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-23 20:30:28 +01:00
|
|
|
deleteDir()
|
2019-07-29 20:42:20 +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-01-28 17:33:55 +01:00
|
|
|
sh "make -j2"
|
2020-05-20 01:19:19 +02:00
|
|
|
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { try {
|
2018-11-29 20:20:35 +01:00
|
|
|
sh "make test CTEST_OUTPUT_ON_FAILURE=1"
|
2018-03-23 20:30:28 +01:00
|
|
|
} catch (exc) {
|
|
|
|
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
|
|
|
|
throw exc
|
2020-05-20 01:19:19 +02:00
|
|
|
} }
|
2018-03-23 20:30:28 +01:00
|
|
|
sh "make install"
|
|
|
|
} }
|
2021-06-03 20:39:01 +02:00
|
|
|
} } }
|
2018-03-22 18:11:39 +01:00
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** wrap-up */
|
2020-08-03 17:23:34 +02:00
|
|
|
def error = null
|
2018-03-22 18:11:39 +01:00
|
|
|
try {
|
|
|
|
parallel platforms
|
2021-06-03 20:39:01 +02:00
|
|
|
if (keepInstall) { node('linux && docker && triqs') {
|
2018-04-06 17:27:06 +02:00
|
|
|
/* Publish results */
|
2019-08-27 23:37:02 +02:00
|
|
|
stage("publish") { timeout(time: 5, unit: 'MINUTES') {
|
2018-03-23 20:30:28 +01:00
|
|
|
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
2019-04-16 23:41:46 +02:00
|
|
|
def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim()
|
2020-01-14 21:49:38 +01:00
|
|
|
def workDir = pwd(tmp:true)
|
2019-08-27 23:37:02 +02:00
|
|
|
lock('triqs_publish') {
|
2018-04-06 17:27:06 +02:00
|
|
|
/* Update documention on gh-pages branch */
|
2018-03-23 20:30:28 +01:00
|
|
|
dir("$workDir/gh-pages") {
|
2018-06-22 17:15:27 +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:30:28 +01:00
|
|
|
sh "rm -rf ${subdir}"
|
2020-01-28 17:33:55 +01: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 ]]
|
2020-01-28 17:38:56 +01:00
|
|
|
cp -rp \$base/\$dir ${subdir}
|
2020-01-28 17:33:55 +01:00
|
|
|
"""
|
2018-03-23 20:30:28 +01:00
|
|
|
}
|
|
|
|
sh "git add -A ${subdir}"
|
|
|
|
sh """
|
2018-06-22 17:15:27 +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:30:28 +01:00
|
|
|
"""
|
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2019-08-27 23:37:02 +02:00
|
|
|
sh "git push origin master"
|
2018-03-23 20:30:28 +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)
|
2019-04-29 20:51:15 +02:00
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
|
|
|
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
|
2019-05-02 19:42:36 +02:00
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
|
2019-08-27 23:37:02 +02:00
|
|
|
git push origin ${env.BRANCH_NAME}
|
2018-03-23 20:30:28 +01:00
|
|
|
"""
|
|
|
|
} catch (err) {
|
2018-06-22 17:15:27 +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-01-28 21:04:03 +01:00
|
|
|
} } }
|
2019-08-27 23:37:02 +02:00
|
|
|
}
|
2018-03-23 20:30:28 +01:00
|
|
|
} }
|
|
|
|
} }
|
2018-03-22 18:11:39 +01:00
|
|
|
} catch (err) {
|
2020-08-03 17:23:34 +02:00
|
|
|
error = err
|
|
|
|
} finally {
|
2018-04-06 17:27:06 +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-03-22 18:11:39 +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-09-17 19:41:37 +02:00
|
|
|
Changes:
|
2018-03-22 18:11:39 +01:00
|
|
|
\$CHANGES
|
|
|
|
|
|
|
|
End of build log:
|
|
|
|
\${BUILD_LOG,maxLines=60}
|
|
|
|
""",
|
2020-08-03 17:23:34 +02:00
|
|
|
to: 'nwentzell@flatironinstitute.org, dsimon@flatironinstitute.org',
|
2018-03-22 18:11:39 +01:00
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'DevelopersRecipientProvider'],
|
|
|
|
],
|
|
|
|
replyTo: '$DEFAULT_REPLYTO'
|
|
|
|
)
|
2020-08-03 17:23:34 +02:00
|
|
|
if (error != null) throw error
|
2018-03-22 18:11:39 +01:00
|
|
|
}
|