forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-ci.sh
executable file
·85 lines (73 loc) · 1.31 KB
/
github-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
#!/bin/bash
set -e
PARALLEL=2
PARALLEL_MAKE=-j"$PARALLEL"
PARALLEL_CTEST=-j"$PARALLEL"
BUILDDIR=b
GCOVRDIR=c
do_enable_python() {
echo "do_enable_python()"
PYTHON_DEFINE="-DENABLE_PYTHON=ON"
}
do_build() {
echo "do_build()"
rm -rf "$BUILDDIR"
mkdir "$BUILDDIR"
(
cd "$BUILDDIR"
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=ON -DEXPERIMENTAL=ON -DPROFILE=ON -DUSE_BUILTIN_OPENCSG=1 ${PYTHON_DEFINE} .. && make $PARALLEL_MAKE
)
if [[ $? != 0 ]]; then
echo "Build failure"
exit 1
fi
}
do_test() {
echo "do_test()"
(
cd "$BUILDDIR"
ctest $PARALLEL_CTEST
if [[ $? != 0 ]]; then
exit 1
fi
if [ -d tests/.gcov ]; then
tar -C tests/.gcov -c -f - . | tar -x -f -
fi
)
if [[ $? != 0 ]]; then
echo "Test failure"
exit 1
fi
}
do_coverage() {
echo "do_coverage()"
case $(gcovr --version | head -n1 | awk '{ print $2 }') in
[4-9].*)
PARALLEL_GCOVR=-j"$PARALLEL"
;;
*)
PARALLEL_GCOVR=
;;
esac
rm -rf "$GCOVRDIR"
mkdir "$GCOVRDIR"
(
cd "$BUILDDIR"
echo "Generating code coverage report..."
gcovr -r .. $PARALLEL_GCOVR --html --html-details -p -o coverage.html
if [[ $? != 0 ]]; then
exit 1
fi
mv coverage*.html ../"$GCOVRDIR"
echo "done."
)
if [[ $? != 0 ]]; then
echo "Coverage failure"
exit 1
fi
}
for func in $@
do
"do_$func"
done
exit 0