From fae645466115045f3801cd3926afe752c08840ec Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 24 Aug 2015 15:15:08 -0400 Subject: [PATCH] Add pre-commit hooks Signed-off-by: Daniel Nephin --- .pre-commit-config.yaml | 18 ++++++++++++++++++ Dockerfile | 3 +++ script/test-versions | 2 +- tox.ini | 12 +++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..832be6ab8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile index ed23e75ac..a4cc99fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN set -ex; \ curl \ lxc \ iptables \ + libsqlite3-dev \ ; \ rm -rf /var/lib/apt/lists/* @@ -68,6 +69,8 @@ RUN pip install -r requirements.txt ADD requirements-dev.txt /code/ RUN pip install -r requirements-dev.txt +RUN pip install tox==2.1.1 + ADD . /code/ RUN python setup.py install diff --git a/script/test-versions b/script/test-versions index ae9620e38..d67a6f5e1 100755 --- a/script/test-versions +++ b/script/test-versions @@ -5,7 +5,7 @@ set -e >&2 echo "Running lint checks" -flake8 compose tests setup.py +tox -e pre-commit if [ "$DOCKER_VERSIONS" == "" ]; then DOCKER_VERSIONS="default" diff --git a/tox.ini b/tox.ini index 33cdee167..3a69c5784 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,10 @@ [tox] -envlist = py26,py27 +envlist = py27,pre-commit [testenv] usedevelop=True +passenv = + LD_LIBRARY_PATH deps = -rrequirements.txt -rrequirements-dev.txt @@ -10,6 +12,14 @@ commands = nosetests -v {posargs} flake8 compose tests setup.py +[testenv:pre-commit] +skip_install = True +deps = + pre-commit +commands = + pre-commit install + pre-commit run --all-files + [flake8] # ignore line-length for now ignore = E501,E203