diff --git a/jenkins/README.md b/jenkins/README.md new file mode 100644 index 0000000..1b61194 --- /dev/null +++ b/jenkins/README.md @@ -0,0 +1,25 @@ +# opm-upscaling jenkins build scripts: + +**build-opm-upscaling.sh**: +This is a helper script which contains functions for building, +testing and cloning opm-upscaling and its dependencies. + +**build.sh**: +This script will build dependencies, then build opm-upscaling 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-upscaling and execute its tests. +It inspects the $ghbPrBuildComment environmental variable to obtain a pull request +to use for ert, opm-common, opm-parser, opm-material, opm-core, opm-output +and dune-cornerpoint (defaults to master) and then builds $sha1 of opm-upscaling. + +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, opm-material, opm-core and dune-cornerpoint 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> and/or opm-core=<pull request number> +and/or opm-output=<pull request number> +and/or dune-cornerpoint=<pull request number>. diff --git a/jenkins/build-opm-upscaling.sh b/jenkins/build-opm-upscaling.sh new file mode 100755 index 0000000..d142cd8 --- /dev/null +++ b/jenkins/build-opm-upscaling.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +function build_opm_upscaling { + # 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 + 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 + clone_and_build_module opm-core "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_CORE_REVISION $WORKSPACE/serial + + # Build dune-cornerpoint + clone_and_build_module dune-cornerpoint "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $DUNE_CORNERPOINT_REVISION $WORKSPACE/serial + + # Build opm-output + clone_and_build_module opm-output "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_OUTPUT_REVISION $WORKSPACE/serial + + # Build opm-upscaling + pushd . + mkdir serial/build-opm-upscaling + cd serial/build-opm-upscaling + build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install" 1 $WORKSPACE + popd +} diff --git a/jenkins/build-pr.sh b/jenkins/build-pr.sh new file mode 100755 index 0000000..afad6de --- /dev/null +++ b/jenkins/build-pr.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +source `dirname $0`/build-opm-upscaling.sh + +ERT_REVISION=master +OPM_COMMON_REVISION=master +OPM_PARSER_REVISION=master +OPM_MATERIAL_REVISION=master +OPM_CORE_REVISION=master +DUNE_CORNERPOINT_REVISION=master +OPM_OUTPUT_REVISION=master +OPM_UPSCALING_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 + +if grep -q "opm-core=" <<< $ghprbCommentBody +then + OPM_CORE_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-core=([0-9]+).*/\1/g'`/merge +fi + +if grep -q "dune-cornerpoint=" <<< $ghprbCommentBody +then + DUNE_CORNERPOINT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*dune-cornerpoint=([0-9]+).*/\1/g'`/merge +fi + +if grep -q "opm-output=" <<< $ghprbCommentBody +then + OPM_OUTPUT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-output=([0-9]+).*/\1/g'`/merge +fi + +echo "Building with ert=$ERT_REVSIION opm-common=$OPM_COMMON_REVISION opm-parser=$OPM_PARSER_REVISION opm-material=$OPM_MATERIAL_REVISION opm-core=$OPM_CORE_REVISION dune-cornerpoint=$DUNE_CORNERPOINT_REVISION opm-output=$OPM_OUTPUT_REVISION opm-upscaling=$OPM_UPSCALING_REVISION" + +build_opm_upscaling +test $? -eq 0 || exit 1 + +cp serial/build-opm-upscaling/testoutput.xml . diff --git a/jenkins/build.sh b/jenkins/build.sh new file mode 100755 index 0000000..d0e35a2 --- /dev/null +++ b/jenkins/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +source `dirname $0`/build-opm-upscaling.sh + +ERT_REVISION=master +OPM_COMMON_REVISION=master +OPM_PARSER_REVISION=master +OPM_MATERIAL_REVISION=master +OPM_CORE_REVISION=master +DUNE_CORNERPOINT_REVISION=master +OPM_OUTPUT_REVISION=master + +build_opm_upscaling +test $? -eq 0 || exit 1 + +cp serial/build-opm-upscaling/testoutput.xml .