Browse Source

Add pre-commit hooks

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 10 years ago
parent
commit
fae6454661
4 changed files with 33 additions and 2 deletions
  1. 18 0
      .pre-commit-config.yaml
  2. 3 0
      Dockerfile
  3. 1 1
      script/test-versions
  4. 11 1
      tox.ini

+ 18 - 0
.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

+ 3 - 0
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
 

+ 1 - 1
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"

+ 11 - 1
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