-
Notifications
You must be signed in to change notification settings - Fork 17
/
.travis-ci.sh
executable file
·137 lines (133 loc) · 5.01 KB
/
.travis-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
#!/bin/bash
# This script is triggered from the script section of .travis.yml
# It runs the appropriate commands depending on the task requested.
CPP_LINT_URL="https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py";
COVERITY_SCAN_BUILD_URL="https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh"
if [[ $TASK = 'lint' ]]; then
# run the lint tool only if it is the requested task
# first check we've not got any generic NOLINTs
# count the number of generic NOLINTs
nolints=$(grep -PIR 'NOLINT(?!\()' * | wc -l)
if [[ $nolints -ne 0 ]]; then
# print the output for info
echo $(grep -PIR 'NOLINT(?!\()' *)
echo "Found $nolints generic NOLINTs"
exit 1;
else
echo "Found $nolints generic NOLINTs"
fi;
wget -O cpplint.py $CPP_LINT_URL;
chmod u+x cpplint.py;
# We want the worst exit status when piping
set -o pipefail
# Line buffer stdout and stderr to stop them being mixed together within a line
# We can only do limited lint on the C firmware, as it's not C++
stdbuf -oL -eL ./cpplint.py \
--filter=-legal/copyright,-build/include,-readability/casting \
--extensions=c \
Bootloader/firmware/src/*.c \
$(find common boardcfg tools -name "*.c") \
firmware/src/*.c \
2>&1 | tee -a cpplint.log
if [[ $? -ne 0 ]]; then
exit 1;
fi;
# Use a bit more care on the dummy Harmony headers
stdbuf -oL -eL ./cpplint.py \
--filter=-legal/copyright,-build/include,-readability/braces \
$(find tests/harmony/ -name "*.h" -type f) \
2>&1 | tee -a cpplint.log
if [[ $? -ne 0 ]]; then
exit 1;
fi;
# Check everything else, including the firmware headers, more thoroughly
stdbuf -oL -eL ./cpplint.py \
--filter=-legal/copyright,-build/include \
Bootloader/firmware/src/*.h \
$(find common boardcfg tools -name "*.h" -type f) \
firmware/src/*.h \
tests/{include,sim,system_config,tests,mocks}/*.{h,cpp} \
$(find tests/harmony/ -name "*.cpp" -type f) \
2>&1 | tee -a cpplint.log
if [[ $? -ne 0 ]]; then
exit 1;
fi;
# Check the user_manual utilities
stdbuf -oL -eL ./cpplint.py \
--filter=-legal/copyright,-build/include,-readability/streams \
user_manual/pid_gen/*.{h,cpp} \
2>&1 | tee -a cpplint.log
if [[ $? -ne 0 ]]; then
exit 1;
fi;
./scripts/verify_cpplint_coverge.py ./ ./cpplint.log
elif [[ $TASK = 'check-licences' ]]; then
# check licences only if it is the requested task
./scripts/enforce_licence.py
if [[ $? -ne 0 ]]; then
exit 1;
fi;
elif [[ $TASK = 'doxygen' ]]; then
# check doxygen only if it is the requested task
autoreconf -i && ./configure --without-ola
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for Doxygen to run against
#make builtfiles
# count the number of warnings
warnings=$(make doxygen-doc 2>&1 >/dev/null | wc -l)
if [[ $warnings -ne 0 ]]; then
# print the output for info
make doxygen-doc
echo "Found $warnings doxygen warnings"
exit 1;
else
echo "Found $warnings doxygen warnings"
fi;
elif [[ $TASK = 'doxygen-manual' ]]; then
# check doxygen only if it is the requested task
autoreconf -i && ./configure --without-ola
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for Doxygen to run against
#make builtfiles
# count the number of warnings
cd user_manual
warnings=$(doxygen 2>&1 >/dev/null | wc -l)
if [[ $warnings -ne 0 ]]; then
# print the output for info
doxygen
echo "Found $warnings user manual doxygen warnings"
exit 1;
else
echo "Found $warnings user manual doxygen warnings"
fi;
elif [[ $TASK = 'coverage' ]]; then
# Compile with coverage for coveralls
autoreconf -i && ./configure --enable-gcov && make && make check
elif [[ $TASK = 'coverity' ]]; then
# Run Coverity Scan unless token is zero length
# The Coverity Scan script also relies on a number of other COVERITY_SCAN_
# variables set in .travis.yml
if [[ ${#COVERITY_SCAN_TOKEN} -ne 0 ]]; then
curl -s $COVERITY_SCAN_BUILD_URL | bash
else
echo "Skipping Coverity Scan as no token found, probably a Pull Request"
fi;
elif [[ $TASK = 'codespell' ]]; then
# run codespell only if it is the requested task
spellingfiles=$(find ./ -type f -and ! \( \
-wholename "./.git/*" \
\) | xargs)
# count the number of codespell errors
spellingerrors=$(zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" --exclude-file .codespellignore $spellingfiles 2>&1 | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" --exclude-file .codespellignore $spellingfiles
echo "Found $spellingerrors spelling errors via codespell"
exit 1;
else
echo "Found $spellingerrors spelling errors via codespell"
fi;
else
# Otherwise compile and check as normal
autoreconf -i && ./configure && make check
fi