-
Notifications
You must be signed in to change notification settings - Fork 11
/
.travis-ci.sh
76 lines (73 loc) · 3.35 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
#!/bin/bash
PYCHECKER_BLACKLIST=""
#threading,unittest,cmd,optparse,google,google.protobuf,ssl,fftpack,lapack_lite,mtrand
SPELLINGBLACKLIST=$(cat <<-BLACKLIST
-wholename "./.codespellignore" -or \
-wholename "./.git/*" -or \
-wholename "./node_modules/*" -or \
-wholename "./tools/update_and_commit_manufacturer_data.log"
BLACKLIST
)
if [[ $TASK = 'nosetests' ]]; then
nosetests --verbosity=3 --detailed-errors
elif [[ $TASK = 'karma' ]]; then
grunt --verbose unit-test
elif [[ $TASK = 'lint' ]]; then
grunt --verbose lint
elif [[ $TASK = 'closure-compiler' ]]; then
grunt --verbose closure-compiler
elif [[ $TASK = 'data-check' ]]; then
./tools/make_manufacturer_data.sh > data/manufacturer_data.py && git diff --exit-code data/manufacturer_data.py
elif [[ $TASK = 'spellintian' ]]; then
# run the spellchecker only if it is the requested task
spellingfiles=$(eval "find ./ -type f -and ! \( \
$SPELLINGBLACKLIST \
\) | xargs")
# count the number of spellchecker errors
spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | \
grep -v "./README.md: Tasks Tasks (duplicate word)" | \
grep -v "./model.py: label label (duplicate word)" | \
grep -v "./data/manufacturer_data.py: Eletronic -> Electronic" | \
grep -v "./.travis-ci.sh: Eletronic -> Electronic" | \
wc -l)
if [[ $spellingerrors -ne 0 ]]; then
# print the output for info
zrun spellintian $spellingfiles 2>&1 | \
grep -v "./README.md: Tasks Tasks (duplicate word)" | \
grep -v "./model.py: label label (duplicate word)" | \
grep -v "./data/manufacturer_data.py: Eletronic -> Electronic" | \
grep -v "./.travis-ci.sh: Eletronic -> Electronic"
echo "Found $spellingerrors spelling errors"
exit 1;
else
echo "Found $spellingerrors spelling errors"
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 --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" --exclude-file .codespellignore -L thead,hsi $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 -L thead,hsi $spellingfiles
echo "Found $spellingerrors spelling errors via codespell"
exit 1;
else
echo "Found $spellingerrors spelling errors via codespell"
fi;
elif [[ $TASK = 'flake8' ]]; then
flake8 --max-line-length 80 --exclude .git,__pycache,node_modules/* --ignore E111,E114,E121,E124,E126,E129,E501,W504 $(find ./ -name "*.py" | xargs)
elif [[ $TASK = 'flake8-wip' ]]; then
flake8 --max-line-length 80 --exclude .git,__pycache,node_modules/* --ignore E111,E114,E121,E129,W504 $(find ./ -name "*.py" | xargs)
#,E121,E127
elif [[ $TASK = 'pychecker' ]]; then
PYTHONPATH=./:$PYTHONPATH
export PYTHONPATH
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" | xargs)
elif [[ $TASK = 'pychecker-wip' ]]; then
PYTHONPATH=./:$PYTHONPATH
export PYTHONPATH
pychecker --quiet --limit 500 --blacklist $PYCHECKER_BLACKLIST $(find ./ -name "*.py" | xargs)
fi