Switch to using pre-commit instead of coala 65/81965/20
authorThanh Ha <zxiiro@gmail.com>
Thu, 9 May 2019 01:55:16 +0000 (21:55 -0400)
committerThanh Ha <zxiiro@gmail.com>
Tue, 27 Aug 2019 21:54:37 +0000 (17:54 -0400)
Coala hasn't had a release in a long time and pre-commit is a faster
tool for what we are doing with it.

Change-Id: I40b1e592d53472193a63e4dc16bf58d1452550d7
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
.coafile
.pre-commit-config.yaml [new file with mode: 0644]
.yamllint [moved from yamllint.conf with 100% similarity]
tox.ini

index f087a8e75323cbb718dfec277f19972ec4eaa01d..7ec6477705bb0e57a542b87ab594e71817bcd5ca 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -9,36 +9,3 @@ files = **.markdown,
 allow_so_beginning = False
 allow_there_is = False
 allow_cliche_phrases = False
-
-[all.GitCommit]
-bears = GitCommitBear
-ignore_length_regex = Signed-off-by,
-    Also-by,
-    Co-authored-by,
-    http://,
-    https://
-
-[all.JSON]
-bears = JSONFormatBear
-files = **.json
-ignore = .**
-indent_size = 2
-
-[all.ShellCheck]
-bears = ShellCheckBear,
-    SpaceConsistencyBear
-files = **.sh
-ignore = .git/**,
-    .tox/**,
-    jjb/global-jjb/**,
-    jenkins-config/**,
-    jenkins-scripts/*-local-env.sh
-shell = bash
-indent_size = 4
-use_spaces = yeah
-
-[all.YAML]
-bears = YAMLLintBear
-files = jjb/**/*.yaml,openstack-hot/**/*.yaml
-document_start = True
-yamllint_config = yamllint.conf
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..275074f
--- /dev/null
@@ -0,0 +1,30 @@
+---
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v2.2.1
+    hooks:
+      - id: check-json
+      - id: flake8
+        args: ['--max-line-length=88']
+        exclude: docs/*
+      - id: trailing-whitespace
+
+  - repo: https://github.com/jorisroovers/gitlint
+    rev: v0.11.0
+    hooks:
+      - id: gitlint
+
+  - repo: https://github.com/jumanjihouse/pre-commit-hooks
+    sha: 1.11.0
+    hooks:
+      - id: shellcheck
+        exclude: >
+            (?x)^(
+                jjb/global-jjb/.*|
+                jenkins-config/.*
+            )$
+
+  - repo: https://github.com/adrienverge/yamllint
+    rev: v1.15.0
+    hooks:
+      - id: yamllint
similarity index 100%
rename from yamllint.conf
rename to .yamllint
diff --git a/tox.ini b/tox.ini
index 7e1df456ccee3144f6c833a6a6d93693440e86a0..87e40692f98cb2e0cd0aadde0ca4c4170a48022e 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 1.6
-envlist = coala,docs,jjb-version,pep8,prefix,robot
+envlist = coala,docs,jjb-version,pre-commit,prefix,robot
 skipsdist = true
 
 [testenv:coala]
@@ -8,15 +8,10 @@ basepython = python3
 deps =
     coala==0.11
     coala-bears==0.11
-    pygments~=2.3.1
-    # Requests 2.16 breaks dependencies
-    requests<2.16
-    nodeenv==1.1.2
-    numpy
+    nodeenv
 commands =
     nodeenv -p
     npm install --global write-good
-    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
     coala --non-interactive
 
 [testenv:docs]
@@ -32,9 +27,12 @@ commands =
 [testenv:jjb-version]
 commands = python {toxinidir}/check_jjb_version.py
 
-[testenv:pep8]
-deps = flake8
-commands = flake8 scripts/ *.py
+[testenv:pre-commit]
+basepython = python3
+deps = pre-commit
+commands =
+    pre-commit install --hook-type commit-msg
+    pre-commit run --all-files
 
 [testenv:prefix]
 commands = python {toxinidir}/check_prefix.py