This repository has been archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
testjenkins.sh
163 lines (134 loc) · 3.16 KB
/
testjenkins.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
# This script is designed to be able to run in stages in the Jenkins pipline
#
# You can also run it locally. Note that only the committed code is tested,
# not changes in your working directory.
#
# If you want to run the whole build in one go:
# sh testjenkins.sh build_and_test
#
# If you want to run the build in separate stages:
# sh testjenkins.sh setup
# sh testjenkins.sh build_elc
# etc...
#
# By default it will try to build everything inside a folder 'jenkinsbuild'
# You can override this with the env variable WORKING_DIR e.g.:
# WORKING_DIR=$(mktemp -d) sh testjenkins.sh build_and_test
build_and_test () {
rm -rf jenkinsbuild
mkdir jenkinsbuild
run setup
run build_libecl
run build_libres
run build_res
run run_ctest
run run_pytest_equinor
run run_pytest_normal
}
setup () {
run setup_variables
run create_directories
run create_virtualenv
run source_build_tools
run clone_repos
}
build_libecl () {
run enable_environment
pushd $LIBECL_BUILD
cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL
make -j 6 install
popd
}
build_libres () {
run enable_environment
pushd $LIBRES_BUILD
cmake .. -DEQUINOR_TESTDATA_ROOT=/project/res-testdata/ErtTestData \
-DCMAKE_PREFIX_PATH=$INSTALL \
-DCMAKE_INSTALL_PREFIX=$INSTALL \
-DBUILD_TESTS=ON
make -j 6 install
popd
}
build_res () {
run enable_environment
pip install $LIBRES_ROOT
pip install -r test_requirements.txt
}
source_build_tools() {
export PATH=/opt/rh/devtoolset-8/root/bin:$PATH
python --version
gcc --version
cmake --version
set -e
}
setup_variables () {
ENV=$WORKING_DIR/venv
INSTALL=$WORKING_DIR/install
LIBECL_ROOT=$WORKING_DIR/libecl
LIBECL_BUILD=$LIBECL_ROOT/build
LIBRES_ROOT=$WORKING_DIR/libres
LIBRES_BUILD=$LIBRES_ROOT/build
}
enable_environment () {
run setup_variables
source $ENV/bin/activate
run source_build_tools
export ERT_SHOW_BACKTRACE=Y
export RMS_SITE_CONFIG=/prog/res/komodo/bleeding-py36-rhel7/root/lib/python3.6/site-packages/ert_configurations/resources/rms_config.yml
}
create_directories () {
mkdir $INSTALL
}
clone_repos () {
echo "Cloning into $LIBECL_ROOT"
git clone https://github.com/equinor/libecl $LIBECL_ROOT
mkdir -p $LIBECL_BUILD
echo "Cloning into $LIBRES_ROOT"
git clone . $LIBRES_ROOT
mkdir -p $LIBRES_BUILD
ln -s /project/res-testdata/ErtTestData $LIBRES_ROOT/test-data/Equinor
}
create_virtualenv () {
mkdir $ENV
python3 -m venv $ENV
source $ENV/bin/activate
pip install -U pip wheel setuptools cmake
}
run_ctest () {
run enable_environment
pushd $LIBRES_BUILD
export ERT_SITE_CONFIG=$INSTALL/share/ert/site-config
ctest -j $CTEST_JARG -E Lint --output-on-failure
popd
}
run_pytest_normal () {
run enable_environment
python -m pytest -m "not equinor_test" --durations=10 tests
}
run_pytest_equinor () {
ln -s /project/res-testdata/ErtTestData ./test-data/Equinor
run enable_environment
python -m pytest -m "equinor_test" --durations=10 tests
}
run () {
echo ""
echo "----- Running step: $1 -----"
echo ""
$1
echo ""
echo "----- $1 finished -----"
echo ""
}
if [ -z "$CTEST_JARG" ]
then
CTEST_JARG="6"
fi
if [ -z "$WORKING_DIR" ]
then
WORKING_DIR=$(pwd)/jenkinsbuild
fi
if [ $# -ne 0 ]
then
run $1
fi