From 7bc1ec7693c497cfc3a1ab87c321ae192d40d3e1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 4 Apr 2016 14:20:24 +0200 Subject: [PATCH] add jenkins build scripts --- jenkins/README.md | 21 +++++++++++++++ jenkins/build-opm-core.sh | 54 +++++++++++++++++++++++++++++++++++++++ jenkins/build-pr.sh | 36 ++++++++++++++++++++++++++ jenkins/build.sh | 13 ++++++++++ 4 files changed, 124 insertions(+) create mode 100644 jenkins/README.md create mode 100755 jenkins/build-opm-core.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 00000000..a79e17ac --- /dev/null +++ b/jenkins/README.md @@ -0,0 +1,21 @@ +# opm-core jenkins build scripts: + +**build-opm-core.sh**: +This is a helper script which contains a function for building, +testing and cloning opm-core and its dependencies. + +**build.sh**: +This script will build dependencies, then build opm-core 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-core and execute its tests. +It inspects the $ghbPrBuildComment environmental variable to obtain a pull request +to use for ert, opm-common, opm-parser and opm-material (defaults to master) +and then builds $sha1 of opm-core. It is intended for pre-merge builds of pull requests. + +You can optionally specify a given pull request to use for ert, opm-common, +opm-parser and opm-material through the trigger. +The trigger line needs to contain ert=<pull request number> and/or +opm-common=<pull request number> and/or opm-parser=<pull request number> +and/or opm-material=<pull request number>. diff --git a/jenkins/build-opm-core.sh b/jenkins/build-opm-core.sh new file mode 100755 index 00000000..005f2e2b --- /dev/null +++ b/jenkins/build-opm-core.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +function build_opm_core { + # Build ERT + pushd . + mkdir -p $WORKSPACE/deps/ert + cd $WORKSPACE/deps/ert + git init . + git remote add origin https://github.com/Ensembles/ert + git fetch 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 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 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 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-parser + clone_and_build_module opm-parser "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_PARSER_REVISION $WORKSPACE/serial + + # Build opm-material + clone_and_build_module opm-material "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_MATERIAL_REVISION $WORKSPACE/serial + + # Build opm-core + pushd . + mkdir serial/build-opm-core + cd serial/build-opm-core + build_module "-DCMAKE_PREFIX_PATH=$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 00000000..298203ec --- /dev/null +++ b/jenkins/build-pr.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +source `dirname $0`/build-opm-core.sh + +ERT_REVISION=master +OPM_COMMON_REVISION=master +OPM_PARSER_REVISION=master +OPM_MATERIAL_REVISION=master +OPM_CORE_REVISION=$sha1 + +if grep -q "ert=" <<< $ghprbCommentBody +then + ERT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*ert=([0-9]+).*/\1/g'`/merge +fi + +if grep -q "opm-common=" <<< $ghprbCommentBody +then + OPM_COMMON_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge +fi + +if grep -q "opm-parser=" <<< $ghprbCommentBody +then + OPM_PARSER_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-parser=([0-9]+).*/\1/g'`/merge +fi + +if grep -q "opm-material=" <<< $ghprbCommentBody +then + OPM_MATERIAL_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-material=([0-9]+).*/\1/g'`/merge +fi + +echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$OPM_PARSER_REVISION opm-material=$OPM_MATERIAL_REVISION opm-core=$OPM_CORE_REVISION" + +build_opm_core +test $? -eq 0 || exit 1 + +cp serial/build-opm-core/testoutput.xml . diff --git a/jenkins/build.sh b/jenkins/build.sh new file mode 100755 index 00000000..00d21b25 --- /dev/null +++ b/jenkins/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source `dirname $0`/build-opm-core.sh + +ERT_REVISION=master +OPM_COMMON_REVISION=master +OPM_PARSER_REVISION=master +OPM_MATERIAL_REVISION=master + +build_opm_core +test $? -eq 0 || exit 1 + +cp serial/build-opm-core/testoutput.xml .