forked from annoviko/pyclustering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.sh
138 lines (100 loc) · 3.04 KB
/
ci.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
#!/bin/bash
run_build_ccore_job() {
echo "[CI Job] CCORE (C++ code building):"
echo "- Build CCORE library."
#install requirement for the job
sudo apt-get install -qq g++-5
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
# build ccore library
cd ccore/
make ccore
if [ $? -eq 0 ] ; then
echo "Building CCORE library: SUCCESS."
else
echo "Building CCORE library: FAILURE."
exit 1
fi
# return back (keep current folder)
cd ../
}
run_ut_ccore_job() {
echo "[CI Job] UT CCORE (C++ code unit-testing of CCORE library):"
echo "- Build C++ unit-test project for CCORE library."
echo "- Run CCORE library unit-tests."
# install requirements for the job
sudo apt-get install -qq g++-5
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-5 50
pip install cpp-coveralls
# build unit-test project
cd ccore/
make ut
if [ $? -eq 0 ] ; then
echo "Building of CCORE unit-test project: SUCCESS."
else
echo "Building of CCORE unit-test project: FAILURE."
exit 1
fi
# run unit-tests and obtain code coverage
make utrun
coveralls --exclude tst/ --exclude tools/ --gcov-options '\-lp'
# return back (keep current folder)
cd ../
}
run_valgrind_ccore_job() {
echo "[CI Job]: VALGRIND CCORE (C++ code valgrind checking):"
echo "- Run unit-tests of pyclustering."
echo "- Memory leakage detection by valgrind."
# install requirements for the job
sudo apt-get install -qq g++-5
sudo apt-get install -qq valgrind
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
# build and run unit-test project under valgrind to check memory leakage
cd ccore/
make valgrind
# return back (keep current folder)
cd ../
}
run_ut_pyclustering_job() {
echo "[CI Job]: UT PYCLUSTERING (Python code unit-testing):"
echo "- Rebuilt CCORE library."
echo "- Run unit-tests of pyclustering."
echo "- Measure code coverage."
# install requirements for the job
install_miniconda
pip install coveralls
# set path to the tested library
PYTHONPATH=`pwd`
export PYTHONPATH=${PYTHONPATH}
# build ccore library
run_build_ccore_job
# run unit-tests and obtain coverage results
coverage run --source=pyclustering --omit='pyclustering/*/tests/*,pyclustering/*/examples/*,pyclustering/ut/*' pyclustering/ut/__init__.py
coveralls
}
install_miniconda() {
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda install libgfortran
conda create -q -n test-environment python=3.4 numpy scipy matplotlib Pillow
source activate test-environment
}
set -e
set -x
case $CI_JOB in
BUILD_CCORE)
run_build_ccore_job ;;
UT_CCORE)
run_ut_ccore_job ;;
VALGRIND_CCORE)
run_valgrind_ccore_job ;;
UT_PYCLUSTERING)
run_ut_pyclustering_job ;;
*)
echo "[CI Job] Unknown target $CI_JOB"
exit 1 ;;
esac