From 6ef318d4b9c6a66239790d578827236a5578bf6c Mon Sep 17 00:00:00 2001 From: Dylan Simon Date: Fri, 23 Mar 2018 15:35:56 -0400 Subject: [PATCH] [jenkins] build osx against persistent triqs; dockerhub Also sync with app4triqs --- Dockerfile | 9 +++--- Jenkinsfile | 80 ++++++++++++++++++++++++++++------------------------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b28ea52..55102072 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ # See ../triqs/packaging for other options FROM flatironinstitute/triqs:master-ubuntu-clang -COPY . ${SRC}/dft_tools -WORKDIR ${BUILD}/dft_tools +ARG APPNAME=dft_tools +COPY . $SRC/$APPNAME +WORKDIR $BUILD/$APPNAME RUN chown build . USER build -ARG Build_Documentation=0 -RUN cmake ${SRC}/dft_tools -DTRIQS_ROOT=${INSTALL} -DBuild_Documentation=${Build_Documentation} && make -j2 && make test +ARG BUILD_DOC=0 +RUN cmake $SRC/$APPNAME -DTRIQS_ROOT=${INSTALL} -DBuild_Documentation=${BUILD_DOC} && make -j2 && make test USER root RUN make install diff --git a/Jenkinsfile b/Jenkinsfile index 9274b8d0..9be25fcc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,8 @@ def projectName = "dft_tools" +def documentationPlatform = "ubuntu-clang" def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F') -def documentationPlatform = "ubuntu-clang" +def publish = !env.BRANCH_NAME.startsWith("PR-") properties([ disableConcurrentBuilds(), @@ -14,9 +15,11 @@ properties([ ]) ]) +/* 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') { @@ -28,10 +31,10 @@ for (int i = 0; i < dockerPlatforms.size(); i++) { mv -f Dockerfile.jenkins Dockerfile """ /* build and tag */ - def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg Build_Documentation=${platform==documentationPlatform} .") - if (env.BRANCH_NAME.startsWith("PR-") || platform != documentationPlatform) { + def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg BUILD_DOC=${platform==documentationPlatform} .") + if (!publish || platform != documentationPlatform) { /* but we don't need the tag so clean it up (except for documentation) */ - sh "docker rmi ${img.imageName()}" + sh "docker rmi --no-prune ${img.imageName()}" } } } } } @@ -50,26 +53,20 @@ for (int i = 0; i < osxPlatforms.size(); i++) { def tmpDir = pwd(tmp:true) def buildDir = "$tmpDir/build" def installDir = "$tmpDir/install" - + def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}" dir(installDir) { deleteDir() } - copyArtifacts(projectName: triqsProject, selector: upstream(fallbackToLastSuccessful: true), filter: "osx-${platform}.zip") - unzip(zipFile: "osx-${platform}.zip", dir: installDir) - /* fixup zip-stripped permissions (JENKINS-13128) */ - sh "chmod +x $installDir/bin/*" - checkout scm - dir(buildDir) { withEnv(platformEnv[1]+[ - "PATH=$installDir/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin", - "CPATH=$installDir/include", - "LIBRARY_PATH=$installDir/lib", - "CMAKE_PREFIX_PATH=$installDir/share/cmake"]) { + "PATH=$triqsDir/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin", + "CPATH=$triqsDir/include", + "LIBRARY_PATH=$triqsDir/lib", + "CMAKE_PREFIX_PATH=$triqsDir/share/cmake"]) { deleteDir() - sh "cmake $srcDir -DTRIQS_ROOT=$installDir" - sh "make -j2" + sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir" + sh "make -j3" try { sh "make test" } catch (exc) { @@ -78,34 +75,43 @@ for (int i = 0; i < osxPlatforms.size(); i++) { } sh "make install" } } - // zip(zipFile: "osx-${platform}.zip", archive: true, dir: installDir) } } } } } try { parallel platforms - if (!env.BRANCH_NAME.startsWith("PR-")) { - node("docker") { - stage("documentation") { timeout(time: 1, unit: 'HOURS') { - def workDir = pwd() - dir("$workDir/gh-pages") { - def subdir = env.BRANCH_NAME - git(url: "ssh://git@github.com/TRIQS/${projectName}.git", branch: "gh-pages", 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 ' --allow-empty -m 'Generated documentation for ${env.BRANCH_NAME}' -m "`git --git-dir ${workDir}/.git rev-parse HEAD`" - """ - // note: credentials used above don't work (need JENKINS-28335) - sh "git push origin gh-pages" + if (publish) { 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 = env.BRANCH_NAME + git(url: "ssh://git@github.com/TRIQS/${projectName}.git", branch: "gh-pages", 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 ' --allow-empty -m 'Generated documentation for ${env.BRANCH_NAME}' -m '${env.BUILD_TAG} ${commit}' + """ + // note: credentials used above don't work (need JENKINS-28335) + sh "git push origin gh-pages" + } + dir("$workDir/docker") { try { + git(url: "ssh://git@github.com/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 ' --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",