Replace coala with pre-commit 13/87513/1
authorThanh Ha <zxiiro@gmail.com>
Fri, 7 Feb 2020 20:52:30 +0000 (15:52 -0500)
committerThanh Ha <zxiiro@gmail.com>
Fri, 7 Feb 2020 20:54:28 +0000 (15:54 -0500)
Coala hasn't had a release in years and pre-commit runs a bit faster
and has less requirements (no nodejs).

Additionally pre-commit doesn't just complain about the issues, it
actively resolves the issues for you. Locally a developer can
install the hooks with `pre-commit install` and onwards pre-commit
will automatically run against only the changed files every time
the developer types `git commit`.

A manual run against all files in the repo can be triggered by
running `pre-commit run --all-files`.

Change-Id: I4a065212158665b34da4f269baaa38e3fd4ddb84
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
.coafile [deleted file]
.pre-commit-config.yaml [new file with mode: 0644]
karaf/opendaylight-karaf-resources/src/main/patches/karaf-inc.patch
karaf/opendaylight-karaf-resources/src/main/patches/karaf-instance.bat.patch
karaf/opendaylight-karaf-resources/src/main/patches/karaf-instance.patch
karaf/opendaylight-karaf-resources/src/main/patches/karaf-karaf.bat.patch
karaf/opendaylight-karaf-resources/src/main/patches/karaf-karaf.patch
tox.ini

diff --git a/.coafile b/.coafile
deleted file mode 100644 (file)
index bf97a00..0000000
--- a/.coafile
+++ /dev/null
@@ -1,11 +0,0 @@
-[Git]
-bears = GitCommitBear
-ignore_length_regex = Signed-off-by,
-    Also-by,
-    Co-authored-by,
-    http://,
-    https://
-
-[XML]
-bears = XMLBear
-files = settings.xml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..76ddb43
--- /dev/null
@@ -0,0 +1,17 @@
+---
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v2.5.0
+    hooks:
+      - id: check-xml
+      - id: trailing-whitespace
+
+  - repo: https://github.com/jorisroovers/gitlint
+    rev: v0.12.0
+    hooks:
+      - id: gitlint
+
+  - repo: https://github.com/prettier/prettier
+    rev: 1.19.1
+    hooks:
+      - id: prettier
index 4ed96bf1cb4932653fa20bb5c2e35abe81c073e0..1c880de12e6cb7128e9a0078cea2aa001a17d323 100644 (file)
@@ -1,9 +1,9 @@
 --- target/assembly/bin/inc.orig       2018-08-21 16:15:40.146423070 +0200
 +++ target/assembly/bin/inc    2018-08-21 16:15:43.798408830 +0200
 @@ -243,9 +243,9 @@
+
      VERSION=$("${JAVA}" -version 2>&1 | ${AWK} -F '"' '/version/ {print $2}' | sed -e 's/_.*//g; s/^1\.//g; s/\..*//g; s/-.*//g;')
+
 -    # java must be at least version 8
 -    if [ "${VERSION}" -lt "8" ]; then
 -        die "JVM must be greater than 1.8"
 +        die "JVM must be version 11"
      fi
  }
+
 @@ -271,6 +271,8 @@
      fi
+
      DEFAULT_JAVA_OPTS="-Xms${JAVA_MIN_MEM} -Xmx${JAVA_MAX_MEM} -XX:+UnlockDiagnosticVMOptions "
 +    DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
 +    DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS -XX:+DisableExplicitGC"
+
      #Set the JVM_VENDOR specific JVM flags
      if [ "${JVM_VENDOR}" = "SUN" ]; then
 @@ -285,6 +287,13 @@
          fi
      fi
+
 +    # Add default security file option
 +    if [ "x$ODL_JAVA_SECURITY_PROPERTIES" != "x" ]; then
 +        DEFAULT_JAVA_OPTS="-Djava.security.properties="${ODL_JAVA_SECURITY_PROPERTIES}" $DEFAULT_JAVA_OPTS"
index cdc07f75981b3e780d7567a9d57e39654719ad52..d7b39cd73ee8b9f5dde8fd6770fa17403c2b58c0 100644 (file)
@@ -2,7 +2,7 @@
 +++ bin/instance.bat   2016-10-27 16:55:48.295970858 +0200
 @@ -95,6 +95,11 @@
  )
+
  set DEFAULT_JAVA_OPTS=
 +if not "%ODL_JAVA_SECURITY_PROPERTIES%" == "" (
 +    set DEFAULT_JAVA_OPTS=-Djava.security.properties=%ODL_JAVA_SECURITY_PROPERTIES% %DEFAULT_JAVA_OPTS%
@@ -10,5 +10,5 @@
 +    set DEFAULT_JAVA_OPTS=-Djava.security.properties=%KARAF_ETC%\odl.java.security %DEFAULT_JAVA_OPTS%
 +)
  set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
+
  rem Support for loading native libraries
index 24224a7815ecf7c471fa0002239753e65ae31133..f11ec64ad01cc66d73c97e2d9e021be6b325041f 100644 (file)
@@ -9,7 +9,7 @@
 @@ -291,6 +291,13 @@
          fi
      fi
+
 +    # Add default security file option
 +    if [ "x$ODL_JAVA_SECURITY_PROPERTIES" != "x" ]; then
 +        DEFAULT_JAVA_OPTS="-Djava.security.properties=${ODL_JAVA_SECURITY_PROPERTIES} $DEFAULT_JAVA_OPTS"
index a89435512670e4a2095a57e2879a78b61045ef8d..2f5567755db84d0b3e71bc3c44648efb9e8f6afb 100644 (file)
@@ -3,7 +3,7 @@
 @@ -45,6 +45,12 @@
      set JAVA_MAX_MEM=512M
  )
+
 +rem Check if Windows version == 10.0 to override
 +rem Equinox property fixing karaf startup
 +rem TODO: Remove this hack when we update Karaf to a compatible version
 +if "%WIN_VERSION%" == "10.0" set KARAF_WIN10_FIX=-Dorg.osgi.framework.os.name=Win32
 +
  goto BEGIN
+
  :warn
 @@ -248,6 +254,12 @@
      set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:MaxPermSize=%JAVA_MAX_PERM_MEM%
  )
+
 +if not "%ODL_JAVA_SECURITY_PROPERTIES%" == "" (
 +    set DEFAULT_JAVA_OPTS=-Djava.security.properties=%ODL_JAVA_SECURITY_PROPERTIES% %DEFAULT_JAVA_OPTS%
 +) else (
@@ -24,5 +24,5 @@
 +)
 +
  if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
+
  if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
index 9f722f260c55382c6cd68c8ea26370322c0a93e6..04d1b8c31ece52e79c5cc5ab8bc1022d8fd86176 100644 (file)
@@ -3,7 +3,7 @@
 @@ -181,6 +181,13 @@
          KARAF_EXEC=""
      fi
+
 +    # Use /dev/urandom to avoid blocking on /dev/random
 +    # See http://www.2uo.de/myths-about-urandom/ to understand why this is safe (as long as your VM provisioning seeds
 +    # the PRNG)
@@ -16,7 +16,7 @@
      nodebug=false
 @@ -282,8 +289,12 @@
          fi
+
          if [ "${ROOT_INSTANCE_RUNNING}" = "false" ] || [ "${CHECK_ROOT_INSTANCE_RUNNING}" = "false" ] ; then
 +            # Using command line arguments as java arguments
 +            # (as opposed to arguments for $MAIN)
diff --git a/tox.ini b/tox.ini
index a689c8b1f25536ba577c35e748ce29e1cb409ed0..bfeaf0522974e1b219043ae7655cf36d2df8a529 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,22 +1,17 @@
 [tox]
 minversion = 1.6
-envlist = coala,docs
+envlist = docs,pre-commit
 skipsdist = true
 
-[testenv:coala]
-basepython = python3
-deps =
-    coala==0.11
-    coala-bears==0.11
-    pygments~=2.3.1
-    # Requests 2.16 breaks dependencies
-    requests<2.16
-commands =
-    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
-    coala --non-interactive
-
 [testenv:docs]
 basepython = python3
 deps = -rdocs/requirements.txt
 commands =
     sphinx-build -W -n -b html -d {envtmpdir}/doctrees ./docs/ {envtmpdir}/html
+
+[testenv:pre-commit]
+basepython = python3
+deps = pre-commit
+commands =
+    pre-commit run --all-files
+    pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG