Add pre-commit hooks

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2015-08-24 15:15:08 -04:00
parent 2da8b7e511
commit fae6454661
4 changed files with 33 additions and 2 deletions

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 'v0.4.2'
hooks:
- id: check-added-large-files
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: flake8
- id: name-tests-test
exclude: 'tests/integration/testcases.py'
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: git://github.com/asottile/reorder_python_imports
sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10
hooks:
- id: reorder-python-imports

View File

@ -14,6 +14,7 @@ RUN set -ex; \
curl \ curl \
lxc \ lxc \
iptables \ iptables \
libsqlite3-dev \
; \ ; \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
@ -68,6 +69,8 @@ RUN pip install -r requirements.txt
ADD requirements-dev.txt /code/ ADD requirements-dev.txt /code/
RUN pip install -r requirements-dev.txt RUN pip install -r requirements-dev.txt
RUN pip install tox==2.1.1
ADD . /code/ ADD . /code/
RUN python setup.py install RUN python setup.py install

View File

@ -5,7 +5,7 @@
set -e set -e
>&2 echo "Running lint checks" >&2 echo "Running lint checks"
flake8 compose tests setup.py tox -e pre-commit
if [ "$DOCKER_VERSIONS" == "" ]; then if [ "$DOCKER_VERSIONS" == "" ]; then
DOCKER_VERSIONS="default" DOCKER_VERSIONS="default"

12
tox.ini
View File

@ -1,8 +1,10 @@
[tox] [tox]
envlist = py26,py27 envlist = py27,pre-commit
[testenv] [testenv]
usedevelop=True usedevelop=True
passenv =
LD_LIBRARY_PATH
deps = deps =
-rrequirements.txt -rrequirements.txt
-rrequirements-dev.txt -rrequirements-dev.txt
@ -10,6 +12,14 @@ commands =
nosetests -v {posargs} nosetests -v {posargs}
flake8 compose tests setup.py flake8 compose tests setup.py
[testenv:pre-commit]
skip_install = True
deps =
pre-commit
commands =
pre-commit install
pre-commit run --all-files
[flake8] [flake8]
# ignore line-length for now # ignore line-length for now
ignore = E501,E203 ignore = E501,E203