Skip to content

Commit 42b011e

Browse files
author
cclauss
authored
WIP: DO NOT MERGE: Flake8 tests on Nodejs repos
__DO NOT MERGE__: This will run the [flake8](http://flake8.pycqa.org) linter on several Nodejs repos that contain Python code to detect syntax errors and undefined names which can raise NameError at runtime. There is a discussion in nodejs/node-gyp#1336 about the importance of using tools like Travis CI to automate the discovery of code quality issues. __E901,E999,F821,F822,F823__ are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. Most other flake8 issues are merely "style violations" -- useful for readability but they do not effect runtime safety. This PR therefore demonstrates such a flake8 run these Nodejs codebases. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable `name` referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
1 parent 3095eec commit 42b011e

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

.travis.yml

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1-
language: cpp
2-
compiler:
3-
- clang
4-
sudo: false
5-
cache: ccache
1+
group: travis_latest
2+
dist: xenial # required for Python 3.7
3+
sudo: true # required for Python 3.7
4+
language: python
5+
cache: pip
6+
python:
7+
- 2.7
8+
- 3.7
69
matrix:
7-
include:
8-
- os: linux
9-
node_js: "latest"
10-
install:
11-
- NODE=$(which node) make lint-md-build
12-
script:
13-
- NODE=$(which node) make lint-ci
14-
- os: linux
15-
install:
16-
- ./configure
17-
- make -j2 V=
18-
script:
19-
- make -j2 test-ci
20-
before_install:
21-
- export CXX="ccache clang++ -Qunused-arguments"
22-
- export CC="ccache clang -Qunused-arguments -Wno-unknown-warning-option"
23-
- export JOBS=2
10+
allow_failures:
11+
- python: 2.7
12+
env:
13+
- REPO=nodejs/node
14+
- REPO=nodejs/node-gyp
15+
- REPO=nodejs/node-auto-test
16+
- REPO=nodejs/node-chakracore
17+
- REPO=nodejs/node-v8
18+
- REPO=nodejs/build
19+
- REPO=nodejs/ffi
20+
- REPO=nodejs/nan
21+
- REPO=nodejs/testing
22+
install:
23+
- pip install flake8
24+
before_script:
25+
- URL=https://github.com/${REPO}
26+
- echo ; echo -n "flake8 testing of ${URL} on " ; python -V
27+
- git clone --depth=50 ${URL} ~/${REPO} # --branch=master
28+
- cd ~/${REPO}
29+
script:
30+
- echo stop the build if there are Python syntax errors or undefined names
31+
- echo ; echo -n "flake8 testing of ${URL} on " ; python -V
32+
- time flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
33+
- echo exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
34+
- time flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
notifications:
36+
on_success: change
37+
on_failure: change # `always` will be the setting once code changes slow down

0 commit comments

Comments
 (0)