forked from OpenLightingProject/ola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis-ci.sh
executable file
·235 lines (228 loc) · 11.1 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
# This script is triggered from the script section of .travis.yml
# It runs the appropriate commands depending on the task requested.
set -e
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"
PYCHECKER_BLACKLIST="threading,unittest,cmd,optparse,google,google.protobuf,ssl,fftpack,lapack_lite,mtrand"
SPELLINGBLACKLIST=$(cat <<-BLACKLIST
-wholename "./.git/*" -or \
-wholename "./aclocal.m4" -or \
-wholename "./config/config.guess" -or \
-wholename "./config/config.sub" -or \
-wholename "./config/depcomp" -or \
-wholename "./config/install-sh" -or \
-wholename "./config/libtool.m4" -or \
-wholename "./config/ltmain.sh" -or \
-wholename "./config/ltoptions.m4" -or \
-wholename "./config/ltsugar.m4" -or \
-wholename "./config/missing" -or \
-wholename "./libtool" -or \
-wholename "./config.status" -or \
-wholename "./Makefile" -or \
-wholename "./Makefile.in" -or \
-wholename "./autom4te.cache/*" -or \
-wholename "./java/Makefile" -or \
-wholename "./java/Makefile.in" -or \
-wholename "./olad/www/new/js/app.min.js" -or \
-wholename "./olad/www/new/js/app.min.js.map" -or \
-wholename "./olad/www/new/libs/angular/js/angular.min.js" -or \
-wholename "./olad/www/new/libs/marked/js/marked.min.js" -or \
-wholename "./olad/www/mobile.js" -or \
-wholename "./olad/www/ola.js" -or \
-wholename "./configure" -or \
-wholename "./common/protocol/Ola.pb.*" -or \
-wholename "./plugins/artnet/messages/ArtNetConfigMessages.pb.*" -or \
-wholename "./tools/ola_trigger/config.tab.*" -or \
-wholename "./tools/ola_trigger/lex.yy.cpp"
BLACKLIST
)
if [[ $TASK = 'lint' ]]; then
# run the lint tool only if it is the requested task
autoreconf -i;
./configure --enable-rdm-tests --enable-ja-rule --enable-e133;
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for linting to run against
make builtfiles
# first check we've not got any generic NOLINTs
# count the number of generic NOLINTs
nolints=$(grep -IR NOLINT * | grep -v "NOLINT(" | wc -l)
if [[ $nolints -ne 0 ]]; then
# print the output for info
echo $(grep -IR NOLINT * | grep -v "NOLINT(")
echo "Found $nolints generic NOLINTs"
exit 1;
else
echo "Found $nolints generic NOLINTs"
fi;
# then fetch and run the main cpplint tool
wget -O cpplint.py $CPP_LINT_URL;
chmod u+x cpplint.py;
./cpplint.py \
--filter=-legal/copyright,-readability/streams,-runtime/arrays \
$(find ./ \( -name "*.h" -or -name "*.cpp" \) -and ! \( \
-wholename "./common/protocol/Ola.pb.*" -or \
-wholename "./common/rpc/Rpc.pb.*" -or \
-wholename "./common/rpc/TestService.pb.*" -or \
-wholename "./common/rdm/Pids.pb.*" -or \
-wholename "./config.h" -or \
-wholename "./plugins/*/messages/*ConfigMessages.pb.*" -or \
-wholename "./tools/ola_trigger/config.tab.*" -or \
-wholename "./tools/ola_trigger/lex.yy.cpp" \) | xargs)
if [[ $? -ne 0 ]]; then
exit 1;
fi;
elif [[ $TASK = 'check-licences' ]]; then
# check licences only if it is the requested task
autoreconf -i;
./configure --enable-rdm-tests --enable-ja-rule --enable-e133;
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for licence checking to run against
make builtfiles
./scripts/enforce_licence.py
if [[ $? -ne 0 ]]; then
exit 1;
fi;
elif [[ $TASK = 'spellintian' ]]; then
# run spellintian only if it is the requested task, ignoring duplicate words
autoreconf -i;
./configure --enable-rdm-tests --enable-ja-rule --enable-e133;
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for spellintian to run against
make builtfiles
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of spellintian errors, ignoring duplicate words
spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | grep -v "\(duplicate word\)" | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun spellintian $spellingfiles | grep -v "\(duplicate word\)"
echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
exit 1;
else
echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
fi;
elif [[ $TASK = 'spellintian-duplicates' ]]; then
# run spellintian only if it is the requested task
autoreconf -i;
./configure --enable-rdm-tests --enable-ja-rule --enable-e133;
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for spellintian to run against
make builtfiles
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of spellintian errors
spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun spellintian $spellingfiles
echo "Found $spellingerrors spelling errors via spellintian"
exit 1;
else
echo "Found $spellingerrors spelling errors via spellintian"
fi;
elif [[ $TASK = 'codespell' ]]; then
# run codespell only if it is the requested task
autoreconf -i;
./configure --enable-rdm-tests --enable-ja-rule --enable-e133;
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for codespell to run against
make builtfiles
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of codespell errors
spellingerrors=$(zrun codespell --check-filenames --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 --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;
elif [[ $TASK = 'doxygen' ]]; then
# check doxygen only if it is the requested task
autoreconf -i;
# Doxygen is C++ only, so don't bother with RDM tests
./configure --enable-ja-rule --enable-e133;
# 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 = 'coverage' ]]; then
# Compile with coverage for coveralls
autoreconf -i;
# Coverage is C++ only, so don't bother with RDM tests
./configure --enable-gcov --enable-ja-rule --enable-e133;
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 = 'jshint' ]]; then
cd ./javascript/new-src;
npm install;
grunt test
elif [[ $TASK = 'flake8' ]]; then
autoreconf -i;
./configure --enable-rdm-tests
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for flake8 to run against
make builtfiles
flake8 --max-line-length 80 --exclude *_pb2.py,.git,__pycache --ignore E111,E114,E121,E127,E129 data/rdm include/ola python scripts tools/ola_mon tools/rdm
elif [[ $TASK = 'pychecker' ]]; then
autoreconf -i;
./configure --enable-rdm-tests
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for pychecker to run against
make builtfiles
PYTHONPATH=./python/:$PYTHONPATH
export PYTHONPATH
mkdir ./python/ola/testing/
ln -s ./tools/rdm ./python/ola/testing/rdm
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" -and \( -wholename "./data/*" -or -wholename "./include/*" -or -wholename "./scripts/*" -or -wholename "./python/examples/rdm_compare.py" -or -wholename "./python/ola/*" \) -and ! \( -name "*_pb2.py" -or -name "OlaClient.py" -or -name "ola_candidate_ports.py" -or -wholename "./scripts/enforce_licence.py" -or -wholename "./python/ola/rpc/*" -or -wholename "./python/ola/ClientWrapper.py" -or -wholename "./python/ola/PidStore.py" -or -wholename "./python/ola/RDMAPI.py" \) | xargs)
# More restricted checking for files that import files that break pychecker
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST --only $(find ./ -name "*.py" -and \( -wholename "./tools/rdm/ModelCollector.py" -or -wholename "./tools/rdm/DMXSender.py" -or -wholename "./tools/rdm/TestCategory.py" -or -wholename "./tools/rdm/TestHelpers.py" -or -wholename "./tools/rdm/TestState.py" -or -wholename "./tools/rdm/TimingStats.py" -or -wholename "./tools/rdm/list_rdm_tests.py" \) | xargs)
# Even more restricted checking for files that import files that break pychecker and have unused parameters
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST --only --no-argsused $(find ./ -name "*.py" -and ! \( -name "*_pb2.py" -or -name "OlaClient.py" -or -name "ola_candidate_ports.py" -or -name "ola_universe_info.py" -or -name "rdm_snapshot.py" -or -name "ClientWrapper.py" -or -name "PidStore.py" -or -name "enforce_licence.py" -or -name "ola_mon.py" -or -name "TestLogger.py" -or -name "TestRunner.py" -or -name "rdm_model_collector.py" -or -name "rdm_responder_test.py" -or -name "rdm_test_server.py" \) | xargs)
elif [[ $TASK = 'pychecker-wip' ]]; then
autoreconf -i;
./configure --enable-rdm-tests
# the following is a bit of a hack to build the files normally built during
# the build, so they are present for pychecker to run against
make builtfiles
PYTHONPATH=./python/:$PYTHONPATH
export PYTHONPATH
mkdir ./python/ola/testing/
ln -s ./tools/rdm ./python/ola/testing/rdm
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" -and ! \( -name "*_pb2.py" -or -name "OlaClient.py" -or -name "ola_candidate_ports.py" \) | xargs)
else
# Otherwise compile and check as normal
export DISTCHECK_CONFIGURE_FLAGS='--enable-rdm-tests --enable-java-libs --enable-ja-rule --enable-e133'
autoreconf -i;
./configure $DISTCHECK_CONFIGURE_FLAGS;
make distcheck;
make dist;
tarball=$(ls -Ut ola*.tar.gz | head -1)
tar -zxf $tarball;
tarball_root=$(echo $tarball | sed 's/.tar.gz$//')
./scripts/verify_trees.py ./ $tarball_root
fi