forked from chrisstaite/TeensyDmx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis-ci.sh
executable file
·84 lines (79 loc) · 3.04 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
#!/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";
SPELLINGBLACKLIST=$(cat <<-BLACKLIST
-wholename "./.git/*"
BLACKLIST
)
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 -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" \) | xargs)
if [[ $? -ne 0 ]]; then
exit 1;
fi;
elif [[ $TASK = 'spellintian' ]]; then
# run spellintian only if it is the requested task, ignoring duplicate words
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
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
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]" $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]" $spellingfiles
echo "Found $spellingerrors spelling errors via codespell"
exit 1;
else
echo "Found $spellingerrors spelling errors via codespell"
fi;
else
platformio ci --lib="." --board=$BOARD
fi