3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-07 06:33:48 +01:00

[jenkins] Synchronize Jenkinsfile with app4triqs

This commit is contained in:
Nils Wentzell 2019-10-10 13:46:39 -04:00
parent 2d491050cc
commit 9bca12d1ea
2 changed files with 21 additions and 16 deletions

36
Jenkinsfile vendored
View File

@ -5,18 +5,18 @@ def documentationPlatform = "ubuntu-clang"
/* depend on triqs upstream branch/project */ /* depend on triqs upstream branch/project */
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F') def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
/* whether to publish the results (disabled for template project) */ /* whether to keep and publish the results */
def publish = !env.BRANCH_NAME.startsWith("PR-") def keepInstall = !env.BRANCH_NAME.startsWith("PR-")
properties([ properties([
disableConcurrentBuilds(), disableConcurrentBuilds(),
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')), buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
pipelineTriggers([ pipelineTriggers(keepInstall ? [
upstream( upstream(
threshold: 'SUCCESS', threshold: 'SUCCESS',
upstreamProjects: triqsProject upstreamProjects: triqsProject
) )
]) ] : [])
]) ])
/* map of all builds to run, populated below */ /* map of all builds to run, populated below */
@ -38,8 +38,7 @@ for (int i = 0; i < dockerPlatforms.size(); i++) {
""" """
/* build and tag */ /* build and tag */
def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_DOC=${platform==documentationPlatform} .") def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_DOC=${platform==documentationPlatform} .")
if (!publish || platform != documentationPlatform) { if (!keepInstall) {
/* but we don't need the tag so clean it up (except for documentation) */
sh "docker rmi --no-prune ${img.imageName()}" sh "docker rmi --no-prune ${img.imageName()}"
} }
} } } }
@ -59,7 +58,7 @@ for (int i = 0; i < osxPlatforms.size(); i++) {
def srcDir = pwd() def srcDir = pwd()
def tmpDir = pwd(tmp:true) def tmpDir = pwd(tmp:true)
def buildDir = "$tmpDir/build" def buildDir = "$tmpDir/build"
def installDir = "$tmpDir/install" def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install"
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}" def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
dir(installDir) { dir(installDir) {
deleteDir() deleteDir()
@ -72,6 +71,8 @@ for (int i = 0; i < osxPlatforms.size(); i++) {
"LIBRARY_PATH=$triqsDir/lib:${env.BREW}/lib", "LIBRARY_PATH=$triqsDir/lib:${env.BREW}/lib",
"CMAKE_PREFIX_PATH=$triqsDir/lib/cmake/triqs"]) { "CMAKE_PREFIX_PATH=$triqsDir/lib/cmake/triqs"]) {
deleteDir() deleteDir()
/* note: this is installing into the parent (triqs) venv (install dir), which is thus shared among apps and so not be completely safe */
sh "pip install -r $srcDir/requirements.txt"
sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir" sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir"
sh "make -j3" sh "make -j3"
try { try {
@ -89,12 +90,13 @@ for (int i = 0; i < osxPlatforms.size(); i++) {
/****************** wrap-up */ /****************** wrap-up */
try { try {
parallel platforms parallel platforms
if (publish) { node("docker") { if (keepInstall) { node("docker") {
/* Publish results */ /* Publish results */
stage("publish") { timeout(time: 1, unit: 'HOURS') { stage("publish") { timeout(time: 5, unit: 'MINUTES') {
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim() def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim() def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim()
def workDir = pwd() def workDir = pwd()
lock('triqs_publish') {
/* Update documention on gh-pages branch */ /* Update documention on gh-pages branch */
dir("$workDir/gh-pages") { dir("$workDir/gh-pages") {
def subdir = "${projectName}/${env.BRANCH_NAME}" def subdir = "${projectName}/${env.BRANCH_NAME}"
@ -108,22 +110,24 @@ try {
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}' git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}'
""" """
// note: credentials used above don't work (need JENKINS-28335) // note: credentials used above don't work (need JENKINS-28335)
sh "git push origin master || { git pull --rebase origin master && git push origin master ; }" sh "git push origin master"
} }
/* Update packaging repo submodule */ /* Update packaging repo submodule */
if (release) { dir("$workDir/packaging") { try { if (release) { dir("$workDir/packaging") { try {
git(url: "ssh://git@github.com/TRIQS/packaging.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false) git(url: "ssh://git@github.com/TRIQS/packaging.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false)
sh "test -d triqs_${projectName}"
sh "echo '160000 commit ${commit}\ttriqs_${projectName}' | git update-index --index-info"
sh """
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
"""
// note: credentials used above don't work (need JENKINS-28335) // note: credentials used above don't work (need JENKINS-28335)
sh "git push origin ${env.BRANCH_NAME} || { git pull --rebase origin ${env.BRANCH_NAME} && git push origin ${env.BRANCH_NAME} ; }" 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}
"""
} catch (err) { } catch (err) {
/* Ignore, non-critical -- might not exist on this branch */ /* Ignore, non-critical -- might not exist on this branch */
echo "Failed to update packaging repo" echo "Failed to update packaging repo"
} } } } } }
}
} } } }
} } } }
} catch (err) { } catch (err) {

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
# Required python packages for this application (these should also be added to Dockerfile for Jenkins)