From d593a3143d0b78ab61bbc7dddfcc5c4da798e5aa Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Sun, 24 Mar 2019 19:39:43 +0700 Subject: [PATCH] Add flake8 check to Travis-CI matrix Closes https://github.com/kiwix/kiwix-build/issues/263 --- .travis.yml | 35 ++++++++++++++++----------- setup.cfg | 46 ++++++++++++++++++++++++++++++++++++ travis/install_extra_deps.sh | 21 ++++++++++------ 3 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index c72a6439d..95c2dc8f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ if: type != push OR tag IS present before_install: - PATH=$PATH:${HOME}/bin:${HOME}/.local/bin - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then PATH=$PATH:$(brew --prefix)/opt/gettext/bin; fi -- '[ -n "$encrypted_eba2f7543984_iv" ] && openssl aes-256-cbc +- 'if [[ -n "$encrypted_eba2f7543984_iv" ]]; then openssl aes-256-cbc -K $encrypted_eba2f7543984_key -iv $encrypted_eba2f7543984_iv - -in travis/travisci_builder_id_key.enc -out travis/travisci_builder_id_key -d' -- chmod 600 travis/travisci_builder_id_key + -in travis/travisci_builder_id_key.enc -out travis/travisci_builder_id_key -d; fi' +- if [[ -n "$encrypted_eba2f7543984_iv" ]]; then chmod 600 travis/travisci_builder_id_key; fi before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ @@ -30,21 +30,26 @@ cache: install: if [[ $TRAVIS_OS_NAME != "linux" || $DESKTOP_ONLY != 1 ]]; then travis/install_extra_deps.sh; fi script: - | - if [[ $TRAVIS_OS_NAME = "linux" && $DESKTOP_ONLY == 1 ]] + if [[ $TEST_SUITE = "flake8_check" ]] then - if [[ $PLATFORM = "flatpak" ]] - then - docker build -t kiwix/build -f travis/Dockerfile_flatpak . - else - docker build -t kiwix/build -f travis/Dockerfile . - fi - docker run -e PLATFORM -e NIGHTLY_DATE -e TRAVIS_EVENT_TYPE -e DESKTOP_ONLY -e TRAVIS_TAG --device /dev/fuse --cap-add ALL --privileged kiwix/build + flake8 . else - if [[ $TRAVIS_OS_NAME = "linux" ]] + if [[ $TRAVIS_OS_NAME = "linux" && $DESKTOP_ONLY == 1 ]] then - python3.5 travis/compile_all.py + if [[ $PLATFORM = "flatpak" ]] + then + docker build -t kiwix/build -f travis/Dockerfile_flatpak . + else + docker build -t kiwix/build -f travis/Dockerfile . + fi + docker run -e PLATFORM -e NIGHTLY_DATE -e TRAVIS_EVENT_TYPE -e DESKTOP_ONLY -e TRAVIS_TAG --device /dev/fuse --cap-add ALL --privileged kiwix/build else - python3 travis/compile_all.py + if [[ $TRAVIS_OS_NAME = "linux" ]] + then + python3.5 travis/compile_all.py + else + python3 travis/compile_all.py + fi fi fi after_failure: travis/upload_all_log.sh @@ -145,6 +150,8 @@ matrix: os: osx - env: PLATFORM="iOS_i386" os: osx + - env: TEST_SUITE="flake8_check" + os: osx notifications: irc: diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..67cf2b398 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[flake8] +ignore = + E201, # whitespace after '{' + E202, # whitespace before '}' + E501, # line too long + E128, # continuation line under-indented for visual indent + E226, # missing whitespace around arithmetic operator + E126, # continuation line over-indented for hanging indent + E203, # whitespace before ':' + E111, # indentation is not a multiple of four + E261, # at least two spaces before inline comment + E124, # closing bracket does not match visual indentation + E731, # do not assign a lambda expression, use a def + E401, # multiple imports on one line + E302, # expected 2 blank lines, found 1 + W503, # line break before binary operator + E231, # missing whitespace after ':' + E303, # too many blank lines (2) + E302, # expected 2 blank lines, found 1 + E305, # expected 2 blank lines after class or function definition, found 1 + F401, # 'X' imported but unused + F821, # undefined name 'X' + E228, # missing whitespace around modulo operator + E999, # SyntaxError: invalid syntax + E225, # missing whitespace around operator + F403, # 'from .base import *' used; unable to detect undefined names + W391, # blank line at end of file + E122, # continuation line missing indentation or outdented + E251, # unexpected spaces around keyword / parameter equals + E713, # test for membership should be 'not in' + E722, # do not use bare except' + E129, # visually indented line with same indent as next logical line + E301, # expected 1 blank line, found 0 + E121, # continuation line under-indented for hanging indent + E123, # closing bracket does not match indentation of opening bracket's line + E127, # continuation line over-indented for visual indent + E222, # multiple spaces after operator + E265, # block comment should start with '# ' + F811, # redefinition of unused X + E222, # multiple spaces after operator + E117, # over-indented + W504, # line break after binary operator + F405, # 'X' may be undefined, or defined from star imports: X + F841, # local variable 'tlc' is assigned to but never used + W605, # invalid escape sequence '\|' + F402, # import 'X' from line X shadowed by loop variable diff --git a/travis/install_extra_deps.sh b/travis/install_extra_deps.sh index 577703085..2ee39dfe0 100755 --- a/travis/install_extra_deps.sh +++ b/travis/install_extra_deps.sh @@ -4,11 +4,16 @@ set -e if [[ "$TRAVIS_OS_NAME" == "osx" ]] then - pip3 install pillow - pip3 install . + if [[ "$TEST_SUITE" == "flake8_check" ]] + then + pip3 install flake8 + else + pip3 install pillow + pip3 install . - wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip - unzip ninja-mac.zip ninja + wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip + unzip ninja-mac.zip ninja + fi else wget https://bootstrap.pypa.io/get-pip.py python3.5 get-pip.py --user @@ -21,6 +26,8 @@ else unzip ninja-linux.zip ninja fi -mkdir -p $HOME/bin -cp ninja $HOME/bin - +if [[ "$TEST_SUITE" != "flake8_check" ]] +then + mkdir -p $HOME/bin + cp ninja $HOME/bin +fi