Skip to content

Commit ae0a10e

Browse files
MitchellCashCevap Master
authored and
Cevap Master
committed
Update Travis build checks (#26)
* Add a trailing whitespace and tab char lint check to Travis * Add Travis Python check for all non-violated flake8 rules * Travis: Remove bc tool from dependencies * Run Qt wallet tests on travis * Remove duplicate pyzmq install python3-zmq is already installed which provides python3 bindings for 0MQ library.
1 parent 9d05d8e commit ae0a10e

File tree

4 files changed

+204
-9
lines changed

4 files changed

+204
-9
lines changed

.travis.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,30 @@ env:
2222
- WINEDEBUG=fixme-all
2323
matrix:
2424
# ARM
25-
- HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" python3-pip CHECK_DOC=1 CHECK_LOGPRINT=1 GOAL="install" ION_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
25+
- HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf python3-pip" DEP_OPTS="NO_QT=1" CHECK_DOC=1 CHECK_LOGPRINT=1 GOAL="install" ION_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
2626
# Win32
27-
- HOST=i686-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-i686 wine1.6 bc" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-reduce-exports"
27+
- HOST=i686-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-i686 wine1.6" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-reduce-exports"
2828
# 32-bit + dash
29-
- HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python3-zmq" DEP_OPTS="NO_QT=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash" PYZMQ=true
29+
- HOST=i686-pc-linux-gnu PACKAGES="g++-multilib python3-zmq" DEP_OPTS="NO_QT=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
3030
# Win64
31-
- HOST=x86_64-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine1.6 bc" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-reduce-exports"
32-
# iond
33-
- HOST=x86_64-unknown-linux-gnu PACKAGES="bc python3-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER" PYZMQ=true
34-
# No wallet
35-
# - HOST=x86_64-unknown-linux-gnu PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
31+
- HOST=x86_64-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine1.6" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-reduce-exports"
32+
# x86_64 Linux (uses qt5 dev package instead of depends Qt to speed up build and avoid timeout)
33+
- HOST=x86_64-unknown-linux-gnu PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools protobuf-compiler libdbus-1-dev libharfbuzz-dev" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-zmq --with-gui=qt5 --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
34+
# x86_64 Linux, No wallet
35+
# - HOST=x86_64-unknown-linux-gnu PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" ION_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
3636
# Cross-Mac
3737
- HOST=x86_64-apple-darwin11 PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev" ION_CONFIG="--enable-gui --enable-reduce-exports" OSX_SDK=10.11 GOAL="deploy"
3838

3939
before_install:
4040
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
4141
install:
42-
- if [ "$PYZMQ" = "true" ]; then pip install pyzmq --user ; fi
4342
- if [ -n "$DPKG_ADD_ARCH" ]; then sudo dpkg --add-architecture "$DPKG_ADD_ARCH" ; fi
4443
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
4544
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
45+
- if [ "$CHECK_DOC" = 1 -a "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then travis_retry pip3 install flake8 --user; fi
4646
before_script:
4747
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
48+
- if [ "$CHECK_DOC" = 1 -a "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then contrib/devtools/lint-all.sh; fi
4849
- if [ "$CHECK_LOGPRINT" = 1 ]; then contrib/devtools/logprint-scanner.py; fi
4950
- unset CC; unset CXX
5051
- mkdir -p depends/SDKs depends/sdk-sources

contrib/devtools/lint-all.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2017 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# This script runs all contrib/devtools/lint-*.sh files, and fails if any exit
8+
# with a non-zero status code.
9+
10+
set -u
11+
12+
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
13+
LINTALL=$(basename "${BASH_SOURCE[0]}")
14+
15+
for f in "${SCRIPTDIR}"/lint-*.sh; do
16+
if [ "$(basename "$f")" != "$LINTALL" ]; then
17+
if ! "$f"; then
18+
echo "^---- failure generated from $f"
19+
exit 1
20+
fi
21+
fi
22+
done

contrib/devtools/lint-python.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2017 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Check for specified flake8 warnings in python files.
8+
9+
# E112 expected an indented block
10+
# E113 unexpected indentation
11+
# E115 expected an indented block (comment)
12+
# E116 unexpected indentation (comment)
13+
# E125 continuation line with same indent as next logical line
14+
# E131 continuation line unaligned for hanging indent
15+
# E133 closing bracket is missing indentation
16+
# E223 tab before operator
17+
# E224 tab after operator
18+
# E271 multiple spaces after keyword
19+
# E272 multiple spaces before keyword
20+
# E273 tab after keyword
21+
# E274 tab before keyword
22+
# E275 missing whitespace after keyword
23+
# E304 blank lines found after function decorator
24+
# E502 the backslash is redundant between brackets
25+
# E702 multiple statements on one line (semicolon)
26+
# E714 test for object identity should be "is not"
27+
# E721 do not compare types, use "isinstance()"
28+
# E741 do not use variables named "l", "O", or "I"
29+
# E742 do not define classes named "l", "O", or "I"
30+
# E743 do not define functions named "l", "O", or "I"
31+
# F402 import module from line N shadowed by loop variable
32+
# F404 future import(s) name after other statements
33+
# F406 "from module import *" only allowed at module level
34+
# F407 an undefined __future__ feature name was imported
35+
# F601 dictionary key name repeated with different values
36+
# F602 dictionary key variable name repeated with different values
37+
# F621 too many expressions in an assignment with star-unpacking
38+
# F622 two or more starred expressions in an assignment (a, *b, *c = d)
39+
# F631 assertion test is a tuple, which are always True
40+
# F701 a break statement outside of a while or for loop
41+
# F702 a continue statement outside of a while or for loop
42+
# F703 a continue statement in a finally block in a loop
43+
# F704 a yield or yield from statement outside of a function
44+
# F705 a return statement with arguments inside a generator
45+
# F706 a return statement outside of a function/method
46+
# F707 an except: block as not the last exception handler
47+
# F811 redefinition of unused name from line N
48+
# F812 list comprehension redefines 'foo' from line N
49+
# F822 undefined name name in __all__
50+
# F823 local variable name … referenced before assignment
51+
# F831 duplicate argument name in function definition
52+
# W292 no newline at end of file
53+
# W504 line break after binary operator
54+
# W601 .has_key() is deprecated, use "in"
55+
# W602 deprecated form of raising exception
56+
# W603 "<>" is deprecated, use "!="
57+
# W604 backticks are deprecated, use "repr()"
58+
# W605 invalid escape sequence "x"
59+
60+
flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E271,E272,E273,E274,E275,E304,E502,E702,E714,E721,E741,E742,E743,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F822,F823,F831,W292,W504,W601,W602,W603,W604,W605 .

contrib/devtools/lint-whitespace.sh

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2017 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
#
7+
# Check for new lines in diff that introduce trailing whitespace.
8+
9+
# We can't run this check unless we know the commit range for the PR.
10+
11+
while getopts "?" opt; do
12+
case $opt in
13+
?)
14+
echo "Usage: .lint-whitespace.sh [N]"
15+
echo " TRAVIS_COMMIT_RANGE='<commit range>' .lint-whitespace.sh"
16+
echo " .lint-whitespace.sh -?"
17+
echo "Checks unstaged changes, the previous N commits, or a commit range."
18+
echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh"
19+
exit 0
20+
;;
21+
esac
22+
done
23+
24+
if [ -z "${TRAVIS_COMMIT_RANGE}" ]; then
25+
if [ "$1" ]; then
26+
TRAVIS_COMMIT_RANGE="HEAD~$1...HEAD"
27+
else
28+
TRAVIS_COMMIT_RANGE="HEAD"
29+
fi
30+
fi
31+
32+
showdiff() {
33+
if ! git diff -U0 "${TRAVIS_COMMIT_RANGE}" -- "." ":(exclude)depends/patches/" ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/"; then
34+
echo "Failed to get a diff"
35+
exit 1
36+
fi
37+
}
38+
39+
showcodediff() {
40+
if ! git diff -U0 "${TRAVIS_COMMIT_RANGE}" -- *.cpp *.h *.md *.py *.sh ":(exclude)src/leveldb/" ":(exclude)src/secp256k1/" ":(exclude)src/univalue/" ":(exclude)doc/release-notes/"; then
41+
echo "Failed to get a diff"
42+
exit 1
43+
fi
44+
}
45+
46+
RET=0
47+
48+
# Check if trailing whitespace was found in the diff.
49+
if showdiff | grep -E -q '^\+.*\s+$'; then
50+
echo "This diff appears to have added new lines with trailing whitespace."
51+
echo "The following changes were suspected:"
52+
FILENAME=""
53+
SEEN=0
54+
SEENLN=0
55+
while read -r line; do
56+
if [[ "$line" =~ ^diff ]]; then
57+
FILENAME="$line"
58+
SEEN=0
59+
elif [[ "$line" =~ ^@@ ]]; then
60+
LINENUMBER="$line"
61+
SEENLN=0
62+
else
63+
if [ "$SEEN" -eq 0 ]; then
64+
# The first time a file is seen with trailing whitespace, we print the
65+
# filename (preceded by a newline).
66+
echo
67+
echo "$FILENAME"
68+
SEEN=1
69+
fi
70+
if [ "$SEENLN" -eq 0 ]; then
71+
echo "$LINENUMBER"
72+
SEENLN=1
73+
fi
74+
echo "$line"
75+
fi
76+
done < <(showdiff | grep -E '^(diff --git |@@|\+.*\s+$)')
77+
RET=1
78+
fi
79+
80+
# Check if tab characters were found in the diff.
81+
if showcodediff | perl -nle '$MATCH++ if m{^\+.*\t}; END{exit 1 unless $MATCH>0}' > /dev/null; then
82+
echo "This diff appears to have added new lines with tab characters instead of spaces."
83+
echo "The following changes were suspected:"
84+
FILENAME=""
85+
SEEN=0
86+
SEENLN=0
87+
while read -r line; do
88+
if [[ "$line" =~ ^diff ]]; then
89+
FILENAME="$line"
90+
SEEN=0
91+
elif [[ "$line" =~ ^@@ ]]; then
92+
LINENUMBER="$line"
93+
SEENLN=0
94+
else
95+
if [ "$SEEN" -eq 0 ]; then
96+
# The first time a file is seen with a tab character, we print the
97+
# filename (preceded by a newline).
98+
echo
99+
echo "$FILENAME"
100+
SEEN=1
101+
fi
102+
if [ "$SEENLN" -eq 0 ]; then
103+
echo "$LINENUMBER"
104+
SEENLN=1
105+
fi
106+
echo "$line"
107+
fi
108+
done < <(showcodediff | perl -nle 'print if m{^(diff --git |@@|\+.*\t)}')
109+
RET=1
110+
fi
111+
112+
exit $RET

0 commit comments

Comments
 (0)