From 116770d2523074efd607ef0f078a62d039a5bde5 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 9 Jun 2016 16:46:17 +0200 Subject: [PATCH] add jenkins build scripts --- jenkins/README.md | 20 +++++++++ jenkins/build-opm-flowdiagnostics.sh | 29 +++++++++++++ jenkins/build-pr.sh | 65 ++++++++++++++++++++++++++++ jenkins/build.sh | 10 +++++ 4 files changed, 124 insertions(+) create mode 100644 jenkins/README.md create mode 100755 jenkins/build-opm-flowdiagnostics.sh create mode 100755 jenkins/build-pr.sh create mode 100755 jenkins/build.sh diff --git a/jenkins/README.md b/jenkins/README.md new file mode 100644 index 0000000..5e22cc6 --- /dev/null +++ b/jenkins/README.md @@ -0,0 +1,20 @@ +# opm-flowdiagnostics jenkins build scripts: + +**build-opm-flowdiagnostics.sh**: +This is a helper script which contains a function for building, +testing and cloning opm-flowdiagnostics and its dependencies. + +**build.sh**: +This script will build dependencies, then build opm-flowdiagnostics +and execute its tests. +It is intended for post-merge builds of the master branch. + +**build-pr.sh**: +This script will build dependencies, then build opm-flowdiagnostics and execute its tests. +It inspects the $ghbPrBuildComment environmental variable to obtain a pull request +to use for for opm-common (defaults to master) and then builds $sha1 of opm-flowdiagnostics. + +It is intended for pre-merge builds of pull requests. + +You specify a given pull request to use for opm-common through the trigger. +The trigger line needs to contain opm-common=<pull request number>. diff --git a/jenkins/build-opm-flowdiagnostics.sh b/jenkins/build-opm-flowdiagnostics.sh new file mode 100755 index 0000000..37313a3 --- /dev/null +++ b/jenkins/build-opm-flowdiagnostics.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +function build_opm_flowdiagnostics { + # Build opm-common + pushd . + mkdir -p $WORKSPACE/deps/opm-common + cd $WORKSPACE/deps/opm-common + git init . + git remote add origin https://github.com/OPM/opm-common + git fetch --depth 1 origin $OPM_COMMON_REVISION:branch_to_build + test $? -eq 0 || exit 1 + git checkout branch_to_build + popd + source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh + + pushd . + mkdir -p serial/build-opm-common + cd serial/build-opm-common + build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 0 $WORKSPACE/deps/opm-common + popd + + # Build opm-flowdiagnostics + pushd . + mkdir serial/build-opm-flowdiagnostics + cd serial/build-opm-flowdiagnostics + build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 1 $WORKSPACE + test $? -eq 0 || exit 1 + popd +} diff --git a/jenkins/build-pr.sh b/jenkins/build-pr.sh new file mode 100755 index 0000000..5310a70 --- /dev/null +++ b/jenkins/build-pr.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +source `dirname $0`/build-opm-flowdiagnostics.sh + +# Upstream revisions +OPM_COMMON_REVISION=master + +if grep -q "opm-common=" <<< $ghprbCommentBody +then + OPM_COMMON_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge +fi + +echo "Building with opm-common=$OPM_COMMON_REVISION opm-flowdiagnostics=$sha1" + +build_opm_flowdiagnostics +test $? -eq 0 || exit 1 + +# If no downstream builds we are done +if ! grep -q "with downstreams" <<< $ghprbCommentBody +then + cp serial/build-opm-flowdiagnostics/testoutput.xml . + exit 0 +fi + +# Downstream revisions +declare -a downstreams +downstreams=(opm-parser + opm-material + opm-core + opm-flowdiagnostics-applications) + +declare -A downstreamRev +downstreamRev[opm-parser]=master +downstreamRev[opm-material]=master +downstreamRev[opm-core]=master +downstreamRev[opm-flowdiagnostics-applications]=master + +# Build ERT +ERT_REVISION=master +if grep -q "ert=" <<< $ghprbCommentBody +then + ERT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*ert=([0-9]+).*/\1/g'`/merge +fi + +pushd . +mkdir -p $WORKSPACE/deps/ert +cd $WORKSPACE/deps/ert +git init . +git remote add origin https://github.com/Ensembles/ert +git fetch --depth 1 origin $ERT_REVISION:branch_to_build +test $? -eq 0 || exit 1 +git checkout branch_to_build +popd + +pushd . +mkdir -p serial/build-ert +cd serial/build-ert +cmake $WORKSPACE/deps/ert/devel -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install +cmake --build . --target install +test $? -eq 0 || exit 1 +popd + +build_downstreams opm-flowdiagnostics + +test $? -eq 0 || exit 1 diff --git a/jenkins/build.sh b/jenkins/build.sh new file mode 100755 index 0000000..5391a33 --- /dev/null +++ b/jenkins/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +source `dirname $0`/build-opm-flowdiagnostics.sh + +OPM_COMMON_REVISION=master + +build_opm_flowdiagnostics +test $? -eq 0 || exit 1 + +cp serial/build-opm-flowdiagnostics/testoutput.xml .