[stable/1.0] Add zuul CI

Change-Id: I6dba518b88d7e287cdbaeced97c979427fdca981
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..fa37d02
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,3 @@
+[flake8]
+max-line-length = 120
+exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build
diff --git a/.github/workflows/linters.yaml b/.github/workflows/linters.yaml
deleted file mode 100644
index 193eabe..0000000
--- a/.github/workflows/linters.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-name: linters
-on: push 
-
-jobs:
-  super-lint:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v2
-      - uses: github/super-linter@v4
-        env:
-          DEFAULT_BRANCH: main
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          VALIDATE_ALL_CODEBASE: true
-          VALIDATE_PYTHON_MYPY: false
-          VALIDATE_JSCPD: false
diff --git a/.gitignore b/.gitignore
index 32e35b0..1ae05e4 100755
--- a/.gitignore
+++ b/.gitignore
@@ -68,4 +68,4 @@
 *.log
 
 # envvar openrc file
-*openrc.sh
\ No newline at end of file
+*openrc.sh
diff --git a/.gitreview b/.gitreview
index 745b451..a421f9e 100755
--- a/.gitreview
+++ b/.gitreview
@@ -1,4 +1,5 @@
 [gerrit]
-host=review.opendev.org
+host=review.vexxhost.dev
 port=29418
-project=openstack/staffeln.git
+project=staffeln.git
+defaultbranch=stable/1.0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..4975271
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,30 @@
+repos:
+  - repo: https://github.com/compilerla/conventional-pre-commit
+    rev: v2.0.0
+    hooks:
+      - id: conventional-pre-commit
+        stages:
+          - commit-msg
+
+  - repo: https://github.com/psf/black
+    rev: 24.8.0
+    hooks:
+      - id: black
+
+  - repo: https://github.com/pycqa/flake8
+    rev: 5.0.4
+    hooks:
+      - id: flake8
+
+  - repo: https://github.com/pycqa/isort
+    rev: 5.13.2
+    hooks:
+      - id: isort
+
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.3.0
+    hooks:
+      - id: check-yaml
+        args: [--allow-multiple-documents]
+      - id: end-of-file-fixer
+      - id: trailing-whitespace
diff --git a/README.md b/README.md
index d5cdcac..f707938 100755
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 ## Project Description
 
-This solution is a volume-level scheduled backup to implement a non-intrusive automatic backup for Openstack VMs.  
+This solution is a volume-level scheduled backup to implement a non-intrusive automatic backup for Openstack VMs.
 
 All volumes attached to the specified VMs are backed up periodically.
 
diff --git a/etc/staffeln/staffeln.conf b/etc/staffeln/staffeln.conf
index 19a214a..728bfa8 100644
--- a/etc/staffeln/staffeln.conf
+++ b/etc/staffeln/staffeln.conf
@@ -30,4 +30,4 @@
 [notification]
 # receiver = reciever@gmail.com
 # sender_email = sender@vexxhost.com
-# smtp_server_domain = localhost
\ No newline at end of file
+# smtp_server_domain = localhost
diff --git a/requirements.txt b/requirements.txt
index 1b57644..3dd3d48 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,5 +14,3 @@
 openstacksdk>0.28.0
 pymysql
 parse
-# email
-# smtplib
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
index 5466daa..53df199 100755
--- a/setup.cfg
+++ b/setup.cfg
@@ -17,6 +17,8 @@
     Programming Language :: Python :: 3
     Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
+    Programming Language :: Python :: 3.9
+    Programming Language :: Python :: 3.10
     Programming Language :: Python :: 3 :: Only
     Programming Language :: Python :: Implementation :: CPython
 
@@ -35,4 +37,4 @@
 wsgi_scripts =
     staffeln-api-wsgi = staffeln.api:app
 staffeln.database.migration_backend =
-    sqlalchemy = staffeln.db.sqlalchemy.migration
\ No newline at end of file
+    sqlalchemy = staffeln.db.sqlalchemy.migration
diff --git a/staffeln/api/app.py b/staffeln/api/app.py
index 87d2684..8f364b8 100755
--- a/staffeln/api/app.py
+++ b/staffeln/api/app.py
@@ -1,5 +1,6 @@
 from flask import Flask, Response, request

 from oslo_log import log

+

 from staffeln import objects

 from staffeln.common import context

 

diff --git a/staffeln/api/middleware/parsable_error.py b/staffeln/api/middleware/parsable_error.py
index 2b49f83..05297b2 100755
--- a/staffeln/api/middleware/parsable_error.py
+++ b/staffeln/api/middleware/parsable_error.py
@@ -19,6 +19,7 @@
 """

 

 from oslo_serialization import jsonutils

+

 from staffeln.i18n import _

 

 

diff --git a/staffeln/cmd/api.py b/staffeln/cmd/api.py
index a46656c..db20d46 100755
--- a/staffeln/cmd/api.py
+++ b/staffeln/cmd/api.py
@@ -1,9 +1,11 @@
 """Starter script for Staffeln API service"""

+

 import os

 import sys

 

-import staffeln.conf

 from oslo_log import log as logging

+

+import staffeln.conf

 from staffeln.api import app as api_app

 from staffeln.common import service

 from staffeln.i18n import _

diff --git a/staffeln/cmd/conductor.py b/staffeln/cmd/conductor.py
index f4c9579..70a3563 100755
--- a/staffeln/cmd/conductor.py
+++ b/staffeln/cmd/conductor.py
@@ -1,8 +1,9 @@
 """Starter script for the staffeln conductor service."""

 

 import cotyledon

-import staffeln.conf

 from cotyledon import oslo_config_glue

+

+import staffeln.conf

 from staffeln.common import service

 from staffeln.conductor import manager

 

diff --git a/staffeln/cmd/dbmanage.py b/staffeln/cmd/dbmanage.py
index 2331261..d88962f 100644
--- a/staffeln/cmd/dbmanage.py
+++ b/staffeln/cmd/dbmanage.py
@@ -5,6 +5,7 @@
 import sys
 
 from oslo_config import cfg
+
 from staffeln import conf
 from staffeln.common import service
 from staffeln.db import migration
diff --git a/staffeln/common/openstack.py b/staffeln/common/openstack.py
index 01e5ff5..2a63e7e 100644
--- a/staffeln/common/openstack.py
+++ b/staffeln/common/openstack.py
@@ -1,5 +1,6 @@
 from openstack import exceptions, proxy

 from oslo_log import log

+

 from staffeln.common import auth

 from staffeln.i18n import _

 

diff --git a/staffeln/common/service.py b/staffeln/common/service.py
index d2ad7a5..bc3f795 100755
--- a/staffeln/common/service.py
+++ b/staffeln/common/service.py
@@ -12,8 +12,9 @@
 # See the License for the specific language governing permissions and

 # limitations under the License.

 

-import staffeln.conf

 from oslo_log import log as logging

+

+import staffeln.conf

 from staffeln import objects

 from staffeln.common import config

 

diff --git a/staffeln/common/short_id.py b/staffeln/common/short_id.py
index 18be04c..21edd0d 100755
--- a/staffeln/common/short_id.py
+++ b/staffeln/common/short_id.py
@@ -6,6 +6,7 @@
 import uuid

 

 import six

+

 from staffeln.i18n import _

 

 

diff --git a/staffeln/conductor/backup.py b/staffeln/conductor/backup.py
index 70db2b5..fd29068 100755
--- a/staffeln/conductor/backup.py
+++ b/staffeln/conductor/backup.py
@@ -1,11 +1,12 @@
 import collections
 
 import parse
-import staffeln.conf
 from openstack.exceptions import HttpException as OpenstackHttpException
 from openstack.exceptions import ResourceNotFound as OpenstackResourceNotFound
 from openstack.exceptions import SDKException as OpenstackSDKException
 from oslo_log import log
+
+import staffeln.conf
 from staffeln import objects
 from staffeln.common import constants, context, openstack
 from staffeln.conductor import result
diff --git a/staffeln/conductor/manager.py b/staffeln/conductor/manager.py
index a6e93a9..942a4ba 100755
--- a/staffeln/conductor/manager.py
+++ b/staffeln/conductor/manager.py
@@ -2,9 +2,10 @@
 import time

 

 import cotyledon

-import staffeln.conf

 from futurist import periodics

 from oslo_log import log

+

+import staffeln.conf

 from staffeln.common import constants, context

 from staffeln.common import time as xtime

 from staffeln.conductor import backup

diff --git a/staffeln/conductor/result.py b/staffeln/conductor/result.py
index 1414347..1c6fdaf 100644
--- a/staffeln/conductor/result.py
+++ b/staffeln/conductor/result.py
@@ -1,7 +1,8 @@
 # Email notification package

 # This should be upgraded by integrating with mail server to send batch

-import staffeln.conf

 from oslo_log import log

+

+import staffeln.conf

 from staffeln.common import email

 from staffeln.common import time as xtime

 from staffeln.conductor import backup

diff --git a/staffeln/conf/__init__.py b/staffeln/conf/__init__.py
index 3289b63..3601762 100755
--- a/staffeln/conf/__init__.py
+++ b/staffeln/conf/__init__.py
@@ -1,4 +1,5 @@
 from oslo_config import cfg

+

 from staffeln.conf import api, conductor, database, notify, paths

 

 CONF = cfg.CONF

diff --git a/staffeln/conf/api.py b/staffeln/conf/api.py
index e405d6a..3f9c7dc 100755
--- a/staffeln/conf/api.py
+++ b/staffeln/conf/api.py
@@ -1,4 +1,5 @@
 from oslo_config import cfg
+
 from staffeln.i18n import _
 
 api_group = cfg.OptGroup(
diff --git a/staffeln/conf/conductor.py b/staffeln/conf/conductor.py
index 3924beb..7aef60b 100755
--- a/staffeln/conf/conductor.py
+++ b/staffeln/conf/conductor.py
@@ -1,4 +1,5 @@
 from oslo_config import cfg
+
 from staffeln.common import constants
 from staffeln.i18n import _
 
diff --git a/staffeln/conf/database.py b/staffeln/conf/database.py
index 761aa15..7530542 100644
--- a/staffeln/conf/database.py
+++ b/staffeln/conf/database.py
@@ -1,5 +1,6 @@
 from oslo_config import cfg
 from oslo_db import options as oslo_db_options
+
 from staffeln.conf import paths
 from staffeln.i18n import _
 
diff --git a/staffeln/conf/notify.py b/staffeln/conf/notify.py
index 890796a..27fb649 100644
--- a/staffeln/conf/notify.py
+++ b/staffeln/conf/notify.py
@@ -1,4 +1,5 @@
 from oslo_config import cfg
+
 from staffeln.i18n import _
 
 notify_group = cfg.OptGroup(
diff --git a/staffeln/conf/paths.py b/staffeln/conf/paths.py
index 7dbd9a1..21c918d 100644
--- a/staffeln/conf/paths.py
+++ b/staffeln/conf/paths.py
@@ -1,6 +1,7 @@
 import os
 
 from oslo_config import cfg
+
 from staffeln.i18n import _
 
 PATH_OPTS = [
diff --git a/staffeln/db/api.py b/staffeln/db/api.py
index 2d10a05..aca6b4d 100644
--- a/staffeln/db/api.py
+++ b/staffeln/db/api.py
@@ -1,4 +1,5 @@
 """Base classes for storage engines"""
+
 from oslo_config import cfg
 from oslo_db import api as db_api
 
diff --git a/staffeln/db/migration.py b/staffeln/db/migration.py
index c75952d..d13ba20 100644
--- a/staffeln/db/migration.py
+++ b/staffeln/db/migration.py
@@ -1,7 +1,9 @@
 """Database setup command"""
-import staffeln.conf
+
 from stevedore import driver
 
+import staffeln.conf
+
 CONF = staffeln.conf.CONF
 
 _IMPL = None
diff --git a/staffeln/db/sqlalchemy/api.py b/staffeln/db/sqlalchemy/api.py
index adfa7a7..b73c523 100644
--- a/staffeln/db/sqlalchemy/api.py
+++ b/staffeln/db/sqlalchemy/api.py
@@ -11,6 +11,7 @@
 from oslo_utils import strutils, timeutils, uuidutils
 from sqlalchemy.inspection import inspect
 from sqlalchemy.orm import exc
+
 from staffeln.common import short_id
 from staffeln.db.sqlalchemy import models
 
diff --git a/staffeln/db/sqlalchemy/models.py b/staffeln/db/sqlalchemy/models.py
index a93bd6e..b4f4911 100644
--- a/staffeln/db/sqlalchemy/models.py
+++ b/staffeln/db/sqlalchemy/models.py
@@ -1,11 +1,13 @@
 """
 SQLAlchemy models for staffeln service
 """
+
 import urllib.parse as urlparse
 
 from oslo_db.sqlalchemy import models
 from sqlalchemy import Column, Integer, String, UniqueConstraint
 from sqlalchemy.ext.declarative import declarative_base
+
 from staffeln import conf
 
 CONF = conf.CONF
diff --git a/staffeln/objects/base.py b/staffeln/objects/base.py
index 8dd6f94..ab17199 100755
--- a/staffeln/objects/base.py
+++ b/staffeln/objects/base.py
@@ -3,6 +3,7 @@
 from oslo_utils import versionutils

 from oslo_versionedobjects import base as ovoo_base

 from oslo_versionedobjects import fields as ovoo_fields

+

 from staffeln import objects

 

 remotable_classmethod = ovoo_base.remotable_classmethod

diff --git a/staffeln/objects/fields.py b/staffeln/objects/fields.py
index 3f6c2a7..31fb47d 100644
--- a/staffeln/objects/fields.py
+++ b/staffeln/objects/fields.py
@@ -1,4 +1,5 @@
 """Utility method for objects"""
+
 from oslo_serialization import jsonutils
 from oslo_versionedobjects import fields
 
diff --git a/staffeln/tests/base.py b/staffeln/tests/base.py
index 1c30cdb..3054386 100755
--- a/staffeln/tests/base.py
+++ b/staffeln/tests/base.py
@@ -19,5 +19,4 @@
 
 
 class TestCase(base.BaseTestCase):
-
     """Test case base class for all unit tests."""
diff --git a/test-requirements.txt b/test-requirements.txt
index f09cf7f..2c28785 100755
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -9,3 +9,4 @@
 oslotest>=1.10.0 # Apache-2.0
 stestr>=1.0.0 # Apache-2.0
 testtools>=1.4.0 # MIT
+pre-commit
diff --git a/tox.ini b/tox.ini
index 4812539..6e73414 100755
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
 [tox]
-envlist = py37,pep8
+envlist = py3,py37,py38,py39,py310,linters
 skipsdist = True
 sitepackages = False
 skip_missing_interpreters = True
@@ -21,14 +21,17 @@
     pip install {opts} {packages}
 
 
-[testenv:py3]
+[testenv:{py3,py37,py38,py39,py310}]
 basepython = python3
 deps = -r{toxinidir}/test-requirements.txt
 commands = stestr run --slowest {posargs}
 
-[testenv:pep8]
-commands =   
-    flake8
+[testenv:linters]
+skipsdist = True
+deps =
+  pre-commit
+commands =
+  pre-commit run --all-files --show-diff-on-failure
 
 [testenv:cover]
 basepython = python3
@@ -48,11 +51,3 @@
 
 [testenv:venv]
 commands = {posargs}
-
-[flake8]
-# E123, E125 skipped as they are invalid PEP-8.
-
-show-source = True
-ignore = E123,E125
-builtins = _
-exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
new file mode 100644
index 0000000..d7e620d
--- /dev/null
+++ b/zuul.d/jobs.yaml
@@ -0,0 +1,9 @@
+- job:
+    name: staffeln-linters
+    parent: tox-linters
+
+- job:
+    name: staffeln-unit
+    parent: tox
+    vars:
+      tox_envlist: py3
diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml
new file mode 100644
index 0000000..a62642a
--- /dev/null
+++ b/zuul.d/project.yaml
@@ -0,0 +1,9 @@
+- project:
+    check:
+      jobs:
+        - staffeln-linters
+        - staffeln-unit
+    gate:
+      jobs:
+        - staffeln-linters
+        - staffeln-unit