Adopt use of pre-commit hooks
- rename pep8 target to more generic linters - migrates flake8 execution to pre-commit - adds yaml linting - hardening flake8 rules - setting max-line-lengh to 120 instead of ignoring it. - bumped minimal sphinx version - configured sphinx with warnings as errors Change-Id: I4c598c07297ae6a2160ba6754cec860adbfeb6f2 Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
14
.pre-commit-config.yaml
Normal file
14
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v1.3.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
- id: check-yaml
|
||||||
|
files: .*\.(yaml|yml)$
|
||||||
|
# args: [--unsafe]
|
||||||
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
|
rev: v1.11.1
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
files: \.(yaml|yml)$
|
||||||
17
.zuul.yaml
17
.zuul.yaml
@@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
- job:
|
- job:
|
||||||
name: jjb-tox-cross-jenkins-job-builder
|
name: jjb-tox-cross-jenkins-job-builder
|
||||||
description: Tests compatibility with master branch of jenkins-job-builder
|
description: Tests compatibility with master branch of jenkins-job-builder
|
||||||
@@ -9,6 +10,22 @@
|
|||||||
failure-message: WARNING
|
failure-message: WARNING
|
||||||
|
|
||||||
- project:
|
- project:
|
||||||
|
templates:
|
||||||
|
- docs-on-readthedocs
|
||||||
|
- publish-to-pypi
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
|
- openstack-tox-linters
|
||||||
|
- openstack-tox-py27
|
||||||
|
- openstack-tox-py35
|
||||||
|
- openstack-tox-py36
|
||||||
|
- openstack-tox-pypy:
|
||||||
|
nodeset: ubuntu-bionic
|
||||||
- jjb-tox-cross-jenkins-job-builder
|
- jjb-tox-cross-jenkins-job-builder
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- build-openstack-sphinx-docs
|
||||||
|
- openstack-tox-linters
|
||||||
|
- openstack-tox-py27
|
||||||
|
- openstack-tox-py35
|
||||||
|
- openstack-tox-py36
|
||||||
|
|||||||
@@ -68,11 +68,8 @@ More details on how you can contribute is available on our wiki at:
|
|||||||
Writing a patch
|
Writing a patch
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
We ask that all code submissions be flake8_ clean. The
|
Be sure that you lint code before created an code review.
|
||||||
easiest way to do that is to run tox_ before submitting code for
|
The easiest way to do this is to install git pre-commit_ hooks.
|
||||||
review in Gerrit. It will run ``flake8`` in the same
|
|
||||||
manner as the automated test suite that will run on proposed
|
|
||||||
patchsets.
|
|
||||||
|
|
||||||
Installing without setup.py
|
Installing without setup.py
|
||||||
---------------------------
|
---------------------------
|
||||||
@@ -81,9 +78,9 @@ Then install the required python packages using pip_::
|
|||||||
|
|
||||||
$ sudo pip install python-jenkins
|
$ sudo pip install python-jenkins
|
||||||
|
|
||||||
.. _flake8: https://pypi.org/project/flake8
|
|
||||||
.. _tox: https://testrun.org/tox
|
.. _tox: https://testrun.org/tox
|
||||||
.. _pip: https://pypi.org/project/pip
|
.. _pip: https://pypi.org/project/pip
|
||||||
|
.. _pre-commit: https://pre-commit.com/#install
|
||||||
|
|
||||||
|
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from jenkins.version import version_info as python_jenkins_version
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
@@ -58,7 +59,6 @@ copyright = u'2010, Willow Garage'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# Version info
|
# Version info
|
||||||
from jenkins.version import version_info as python_jenkins_version
|
|
||||||
release = python_jenkins_version.version_string_with_vcs()
|
release = python_jenkins_version.version_string_with_vcs()
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = python_jenkins_version.canonical_version_string()
|
version = python_jenkins_version.canonical_version_string()
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ class Jenkins(object):
|
|||||||
>>> build_info = server.get_build_info('build_name', next_build_number)
|
>>> build_info = server.get_build_info('build_name', next_build_number)
|
||||||
>>> print(build_info)
|
>>> print(build_info)
|
||||||
{u'building': False, u'changeSet': {u'items': [{u'date': u'2011-12-19T18:01:52.540557Z', u'msg': u'test', u'revision': 66, u'user': u'unknown', u'paths': [{u'editType': u'edit', u'file': u'/branches/demo/index.html'}]}], u'kind': u'svn', u'revisions': [{u'module': u'http://eaas-svn01.i3.level3.com/eaas', u'revision': 66}]}, u'builtOn': u'', u'description': None, u'artifacts': [{u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war', u'fileName': u'eaas-87-2011-12-19_18-01-57.war'}, {u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war.zip', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war.zip', u'fileName': u'eaas-87-2011-12-19_18-01-57.war.zip'}], u'timestamp': 1324317717000, u'number': 87, u'actions': [{u'parameters': [{u'name': u'SERVICE_NAME', u'value': u'eaas'}, {u'name': u'PROJECT_NAME', u'value': u'demo'}]}, {u'causes': [{u'userName': u'anonymous', u'shortDescription': u'Started by user anonymous'}]}, {}, {}, {}], u'id': u'2011-12-19_18-01-57', u'keepLog': False, u'url': u'http://eaas-jenkins01.i3.level3.com:9080/job/build_war/87/', u'culprits': [{u'absoluteUrl': u'http://eaas-jenkins01.i3.level3.com:9080/user/unknown', u'fullName': u'unknown'}], u'result': u'SUCCESS', u'duration': 8826, u'fullDisplayName': u'build_war #87'}
|
{u'building': False, u'changeSet': {u'items': [{u'date': u'2011-12-19T18:01:52.540557Z', u'msg': u'test', u'revision': 66, u'user': u'unknown', u'paths': [{u'editType': u'edit', u'file': u'/branches/demo/index.html'}]}], u'kind': u'svn', u'revisions': [{u'module': u'http://eaas-svn01.i3.level3.com/eaas', u'revision': 66}]}, u'builtOn': u'', u'description': None, u'artifacts': [{u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war', u'fileName': u'eaas-87-2011-12-19_18-01-57.war'}, {u'relativePath': u'dist/eaas-87-2011-12-19_18-01-57.war.zip', u'displayPath': u'eaas-87-2011-12-19_18-01-57.war.zip', u'fileName': u'eaas-87-2011-12-19_18-01-57.war.zip'}], u'timestamp': 1324317717000, u'number': 87, u'actions': [{u'parameters': [{u'name': u'SERVICE_NAME', u'value': u'eaas'}, {u'name': u'PROJECT_NAME', u'value': u'demo'}]}, {u'causes': [{u'userName': u'anonymous', u'shortDescription': u'Started by user anonymous'}]}, {}, {}, {}], u'id': u'2011-12-19_18-01-57', u'keepLog': False, u'url': u'http://eaas-jenkins01.i3.level3.com:9080/job/build_war/87/', u'culprits': [{u'absoluteUrl': u'http://eaas-jenkins01.i3.level3.com:9080/user/unknown', u'fullName': u'unknown'}], u'result': u'SUCCESS', u'duration': 8826, u'fullDisplayName': u'build_war #87'}
|
||||||
'''
|
''' # noqa: E501
|
||||||
folder_url, short_name = self._get_job_folder(name)
|
folder_url, short_name = self._get_job_folder(name)
|
||||||
try:
|
try:
|
||||||
response = self.jenkins_open(requests.Request(
|
response = self.jenkins_open(requests.Request(
|
||||||
@@ -703,7 +703,7 @@ class Jenkins(object):
|
|||||||
>>> queue_info = server.get_queue_info()
|
>>> queue_info = server.get_queue_info()
|
||||||
>>> print(queue_info[0])
|
>>> print(queue_info[0])
|
||||||
{u'task': {u'url': u'http://your_url/job/my_job/', u'color': u'aborted_anime', u'name': u'my_job'}, u'stuck': False, u'actions': [{u'causes': [{u'shortDescription': u'Started by timer'}]}], u'buildable': False, u'params': u'', u'buildableStartMilliseconds': 1315087293316, u'why': u'Build #2,532 is already in progress (ETA:10 min)', u'blocked': True}
|
{u'task': {u'url': u'http://your_url/job/my_job/', u'color': u'aborted_anime', u'name': u'my_job'}, u'stuck': False, u'actions': [{u'causes': [{u'shortDescription': u'Started by timer'}]}], u'buildable': False, u'params': u'', u'buildableStartMilliseconds': 1315087293316, u'why': u'Build #2,532 is already in progress (ETA:10 min)', u'blocked': True}
|
||||||
'''
|
''' # noqa: E501
|
||||||
return json.loads(self.jenkins_open(
|
return json.loads(self.jenkins_open(
|
||||||
requests.Request('GET', self._build_url(Q_INFO))
|
requests.Request('GET', self._build_url(Q_INFO))
|
||||||
))['items']
|
))['items']
|
||||||
@@ -1540,7 +1540,8 @@ class Jenkins(object):
|
|||||||
:param remoteFS: Remote filesystem location to use, ``str``
|
:param remoteFS: Remote filesystem location to use, ``str``
|
||||||
:param labels: Labels to associate with node, ``str``
|
:param labels: Labels to associate with node, ``str``
|
||||||
:param exclusive: Use this node for tied jobs only, ``bool``
|
:param exclusive: Use this node for tied jobs only, ``bool``
|
||||||
:param launcher: The launch method for the slave, ``jenkins.LAUNCHER_COMMAND``, ``jenkins.LAUNCHER_SSH``, ``jenkins.LAUNCHER_JNLP``, ``jenkins.LAUNCHER_WINDOWS_SERVICE``
|
:param launcher: The launch method for the slave, ``jenkins.LAUNCHER_COMMAND``, \
|
||||||
|
``jenkins.LAUNCHER_SSH``, ``jenkins.LAUNCHER_JNLP``, ``jenkins.LAUNCHER_WINDOWS_SERVICE``
|
||||||
:param launcher_params: Additional parameters for the launcher, ``dict``
|
:param launcher_params: Additional parameters for the launcher, ``dict``
|
||||||
'''
|
'''
|
||||||
if self.node_exists(name):
|
if self.node_exists(name):
|
||||||
|
|||||||
@@ -34,3 +34,8 @@ warnerrors = True
|
|||||||
all_files = 1
|
all_files = 1
|
||||||
build-dir = doc/build
|
build-dir = doc/build
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
show-source = True
|
||||||
|
exclude = .venv,.tox,dist,build,*.egg
|
||||||
|
max-line-length = 120
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
cmd2!=0.8.3,<0.9.0;python_version<'3.0' # MIT
|
cmd2!=0.8.3,<0.9.0;python_version<'3.0' # MIT
|
||||||
cmd2!=0.8.3;python_version>='3.0' # MIT
|
cmd2!=0.8.3;python_version>='3.0' # MIT
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
hacking>=0.5.6,<0.11
|
|
||||||
mock<1.1
|
mock<1.1
|
||||||
unittest2
|
unittest2
|
||||||
python-subunit
|
python-subunit
|
||||||
requests-mock>=1.4.0
|
requests-mock>=1.4.0
|
||||||
requests-kerberos
|
requests-kerberos
|
||||||
sphinx>=1.2,<1.3.0
|
sphinx>=1.6.0
|
||||||
stestr>=2.0.0
|
stestr>=2.0.0
|
||||||
testscenarios
|
testscenarios
|
||||||
testtools
|
testtools
|
||||||
|
pre-commit
|
||||||
|
|||||||
22
tox.ini
22
tox.ini
@@ -1,7 +1,7 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
envlist = py{34,27,35}, pep8, pypy
|
envlist = py{34,27,35}, linters, pypy
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv =
|
setenv =
|
||||||
@@ -39,27 +39,25 @@ commands =
|
|||||||
coverage html -d cover
|
coverage html -d cover
|
||||||
coverage xml -o cover/coverage.xml
|
coverage xml -o cover/coverage.xml
|
||||||
|
|
||||||
|
[testenv:linters]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
pre-commit run --all
|
||||||
|
|
||||||
|
# pep8 was replaced by linter, kept here till we remove it from project-config
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = flake8
|
commands =
|
||||||
|
pre-commit run --all
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx -W
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[flake8]
|
|
||||||
; E501 line too long (80 > 79 characters)
|
|
||||||
; H301 one import per line
|
|
||||||
; H405 multi line docstring summary not separated with an empty line
|
|
||||||
; H501 Do not use locals() for string formatting
|
|
||||||
ignore = E501,H301,H405,H501
|
|
||||||
show-source = True
|
|
||||||
exclude = .venv,.tox,dist,doc,build,*.egg
|
|
||||||
|
|
||||||
[testenv:bindep]
|
[testenv:bindep]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
# Do not install any requirements. We want this to be fast and work even if
|
# Do not install any requirements. We want this to be fast and work even if
|
||||||
|
|||||||
Reference in New Issue
Block a user