Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jenkins build scripts #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions jenkins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# opm-flowdiagnostics-applications jenkins build scripts:

**build-opm-flowdiagnostics-applications.sh**:
This is a helper script which contains a function for building,
testing and cloning opm-flowdiagnostics-applications and its dependencies.

**build.sh**:
This script will build dependencies, then build opm-flowdiagnostics-applications
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-applications
and execute its tests. It inspects the $ghbPrBuildComment environmental
variable to obtain a pull request to use for ert, opm-common,
opm-flowdiagnostics, opm-parser, opm-material and opm-core (defaults to master)
and then builds $sha1 of opm-flowdiagnostics-applications.

It is intended for pre-merge builds of pull requests.

You specify a given pull request to use for ert, opm-common,
opm-flowdiagnostics, opm-parser, opm-material and opm-core through the trigger.
The trigger line needs to contain <modulename>=<pull request number>.
49 changes: 49 additions & 0 deletions jenkins/build-opm-flowdiagnostics-applications.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

function build_opm_flowdiagnostics_applications {
# 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 --depth 1 origin $ERT: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
make 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 --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 serial/build-opm-common
cd serial/build-opm-common
build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 0 $WORKSPACE/deps/opm-common
popd

build_upstreams

# Build opm-flowdiagnostics-applications
pushd .
mkdir serial/build-opm-flowdiagnostics-applications
cd serial/build-opm-flowdiagnostics-applications
build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 1 $WORKSPACE
test $? -eq 0 || exit 1
popd
}
53 changes: 53 additions & 0 deletions jenkins/build-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

source `dirname $0`/build-opm-flowdiagnostics-applications.sh

# Upstream revisions
declare -a upstreams
upstreams=(opm-flowdiagnostics
opm-parser
opm-material
opm-core)

declare -A upstreamRev
upstreamRev[opm-flowdiagnostics]=master
upstreamRev[opm-parser]=master
upstreamRev[opm-material]=master
upstreamRev[opm-core]=master

ERT_REVISION=master
OPM_COMMON_REVISION=master

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

for upstream in $upstreams
do
if grep -q "$upstream=" <<< $ghprbCommentBody
then
upstreamRev[$upstream]=pull/`echo $ghprbCommentBody | sed -r "s/.*$upstream=([0-9]+).*/\1/g"`/merge
fi
done

echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-flowdiagnostics=${upstreamRev[opm-flowdiagnostics]} opm-parser=${upstreamRev[opm-parser]} opm-material=${upstreamRev[opm-material]} opm-core=${upstreamRev[opm-core]} opm-flowdiagnostics-applications=$sha1"

build_opm_flowdiagnostics_applications
test $? -eq 0 || exit 1

# If no downstream builds we are done
if ! grep -q "with downstreams" <<< $ghprbCommentBody
then
cp serial/build-opm-flowdiagnostics-applications/testoutput.xml .
exit 0
fi

echo "No registered downstreams."

test $? -eq 0 || exit 1
24 changes: 24 additions & 0 deletions jenkins/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

source `dirname $0`/build-opm-flowdiagnostics-applications.sh

# Upstream revisions
declare -a upstreams
upstreams=(opm-flowdiagnostics
opm-parser
opm-material
opm-core)

declare -A upstreamRev
upstreamRev[opm-flowdiagnostics]=master
upstreamRev[opm-parser]=master
upstreamRev[opm-material]=master
upstreamRev[opm-core]=master

ERT_REVISION=master
OPM_COMMON_REVISION=master

build_opm_flowdiagnostics_applications
test $? -eq 0 || exit 1

cp serial/build-opm-flowdiagnostics-applications/testoutput.xml .