forked from ipqa-research/yaeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.sh
104 lines (88 loc) · 2.3 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
#!/bin/bash
DESIRED_COVERAGE=90
DID_TEST=0
COVER=0
echoerr() { echo -e "$@" 1>&2; }
install_fpm() {
apt install pipx
pipx install fpm
}
green() {
echo -e "\e[1;32m$@\e[m"
}
red() {
echo -e "\e[1;31m$@\e[m"
}
run_test() {
echo y | fpm clean
DID_TEST=1
echo Checking tests files names...
NAMING_ERRORS=0
for file in $(find test/*f90); do
filename="$(basename $file)"
prefix="$(echo $filename | cut -d '_' -f1)"
if [ "$prefix" = "test" ]; then
green "$file [OK]"
else
NAMING_ERRORS=$((NAMING_ERRORS + 1))
red "$file [X]"
fi
done
[ $NAMING_ERRORS -ge 1 ] &&
echoerr "There are wrongly named files in the test directory"
echo Running tests...
fpm test --flag "--coverage"
}
run_coverage() {
gcovr \
--exclude "build" \
--exclude "test/test_runner.f90" \
--exclude "test/fixtures/taperobinson.f90" \
--exclude "src/adiff/hyperdual.f90" \
--exclude "example" \
--exclude "src/legacy/*" \
--exclude "src/models/excess_gibbs/nrtl.f90" \
--exclude "app"\
--exclude "tools" \
--fail-under-line 90 \
--jacoco coverage.xml
gcovr \
--exclude "build" \
--exclude "test/test_runner.f90" \
--exclude "test/fixtures/taperobinson.f90" \
--exclude "src/adiff/hyperdual.f90" \
--exclude "example" \
--exclude "src/legacy/*" \
--exclude "src/models/excess_gibbs/nrtl.f90" \
--exclude "app"\
--exclude "tools" \
--fail-under-line 90
}
python_wrappers(){
BUILD_DIR="build/python"
fpm install --profile release --prefix "$BUILD_DIR"
cd python/yaeos
f2py \
-I ../../$BUILD_DIR/include \
-L ../../$BUILD_DIR/lib/libyaeos.a \
-m yaeos -c ../yaeos_c.f90 ../../$BUILD_DIR/lib/libyaeos.a
}
resumee() {
[ $DID_TEST = 1 ] &&
echo There has been $NAMING_ERRORS test naming errors
if [ ${COVER} -le 90 ]; then
echo "COVERAGE: " $(red $COVER)
else
echo "COVERAGE: " $(green $COVER)
fi
}
case $1 in
"install") install_fpm;;
"test") run_test;;
"coverage") run_coverage;;
"python") python_wrappers;;
*)
run_test
run_coverage
resumee;;
esac