Merge pull request #8078 from aabadie/pr/python_style_check
dist/tools: add Python style check in static tests
This commit is contained in:
commit
a40e9bac5c
@ -1,7 +1,7 @@
|
|||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get install coreutils realpath doxygen graphviz python-lesscpy cppcheck coccinelle pcregrep
|
- sudo apt-get install coreutils realpath doxygen graphviz python-lesscpy cppcheck coccinelle pcregrep python3-flake8
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make static-test
|
- make static-test
|
||||||
|
|||||||
1
dist/tools/ci/build_and_test.sh
vendored
1
dist/tools/ci/build_and_test.sh
vendored
@ -91,6 +91,7 @@ then
|
|||||||
run ./dist/tools/cppcheck/check.sh
|
run ./dist/tools/cppcheck/check.sh
|
||||||
run ./dist/tools/pr_check/pr_check.sh ${CI_BASE_BRANCH}
|
run ./dist/tools/pr_check/pr_check.sh ${CI_BASE_BRANCH}
|
||||||
run ./dist/tools/coccinelle/check.sh
|
run ./dist/tools/coccinelle/check.sh
|
||||||
|
run ./dist/tools/flake8/check.sh
|
||||||
QUIET=1 run ./dist/tools/headerguards/check.sh
|
QUIET=1 run ./dist/tools/headerguards/check.sh
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
fi
|
fi
|
||||||
|
|||||||
38
dist/tools/flake8/check.sh
vendored
Executable file
38
dist/tools/flake8/check.sh
vendored
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017 Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
#
|
||||||
|
|
||||||
|
if tput colors &> /dev/null && [ $(tput colors) -ge 8 ]; then
|
||||||
|
CERROR="\e[1;31m"
|
||||||
|
CRESET="\e[0m"
|
||||||
|
else
|
||||||
|
CERROR=
|
||||||
|
CRESET=
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIST_TOOLS=${RIOTBASE:-.}/dist/tools
|
||||||
|
|
||||||
|
. ${DIST_TOOLS}/ci/changed_files.sh
|
||||||
|
|
||||||
|
FILES=$(FILEREGEX='*.py$' changed_files)
|
||||||
|
|
||||||
|
if [ -z "${FILES}" ]
|
||||||
|
then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ERRORS=$(flake8 --config=${DIST_TOOLS}/flake8/flake8.cfg ${FILES})
|
||||||
|
|
||||||
|
if [ -n "${ERRORS}" ]
|
||||||
|
then
|
||||||
|
printf "${CERROR}There are style issues in the following Python scripts:${CRESET}\n\n"
|
||||||
|
printf "${ERRORS}\n"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
3
dist/tools/flake8/flake8.cfg
vendored
Normal file
3
dist/tools/flake8/flake8.cfg
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[flake8]
|
||||||
|
# Allow 119 characters width per line to simplify test output parsing
|
||||||
|
max-line-length = 119
|
||||||
Loading…
x
Reference in New Issue
Block a user