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:
parent
f7fa4ce059
commit
e5e7a097b1
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:
|
||||
name: jjb-tox-cross-jenkins-job-builder
|
||||
description: Tests compatibility with master branch of jenkins-job-builder
|
||||
@ -9,6 +10,22 @@
|
||||
failure-message: WARNING
|
||||
|
||||
- project:
|
||||
templates:
|
||||
- docs-on-readthedocs
|
||||
- publish-to-pypi
|
||||
check:
|
||||
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
|
||||
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
|
||||
---------------
|
||||
|
||||
We ask that all code submissions be flake8_ clean. The
|
||||
easiest way to do that is to run tox_ before submitting code for
|
||||
review in Gerrit. It will run ``flake8`` in the same
|
||||
manner as the automated test suite that will run on proposed
|
||||
patchsets.
|
||||
Be sure that you lint code before created an code review.
|
||||
The easiest way to do this is to install git pre-commit_ hooks.
|
||||
|
||||
Installing without setup.py
|
||||
---------------------------
|
||||
@ -81,9 +78,9 @@ Then install the required python packages using pip_::
|
||||
|
||||
$ sudo pip install python-jenkins
|
||||
|
||||
.. _flake8: https://pypi.org/project/flake8
|
||||
.. _tox: https://testrun.org/tox
|
||||
.. _pip: https://pypi.org/project/pip
|
||||
.. _pre-commit: https://pre-commit.com/#install
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
from jenkins.version import version_info as python_jenkins_version
|
||||
|
||||
# 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
|
||||
@ -58,7 +59,6 @@ copyright = u'2010, Willow Garage'
|
||||
# built documents.
|
||||
#
|
||||
# Version info
|
||||
from jenkins.version import version_info as python_jenkins_version
|
||||
release = python_jenkins_version.version_string_with_vcs()
|
||||
# The short X.Y version.
|
||||
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)
|
||||
>>> 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'}
|
||||
'''
|
||||
''' # noqa: E501
|
||||
folder_url, short_name = self._get_job_folder(name)
|
||||
try:
|
||||
response = self.jenkins_open(requests.Request(
|
||||
@ -703,7 +703,7 @@ class Jenkins(object):
|
||||
>>> queue_info = server.get_queue_info()
|
||||
>>> 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}
|
||||
'''
|
||||
''' # noqa: E501
|
||||
return json.loads(self.jenkins_open(
|
||||
requests.Request('GET', self._build_url(Q_INFO))
|
||||
))['items']
|
||||
@ -1540,7 +1540,8 @@ class Jenkins(object):
|
||||
:param remoteFS: Remote filesystem location to use, ``str``
|
||||
:param labels: Labels to associate with node, ``str``
|
||||
: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``
|
||||
'''
|
||||
if self.node_exists(name):
|
||||
|
@ -34,3 +34,8 @@ warnerrors = True
|
||||
all_files = 1
|
||||
build-dir = doc/build
|
||||
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;python_version>='3.0' # MIT
|
||||
coverage>=3.6
|
||||
hacking>=0.5.6,<0.11
|
||||
mock<1.1
|
||||
unittest2
|
||||
python-subunit
|
||||
requests-mock>=1.4.0
|
||||
requests-kerberos
|
||||
sphinx>=1.2,<1.3.0
|
||||
sphinx>=1.6.0
|
||||
stestr>=2.0.0
|
||||
testscenarios
|
||||
testtools
|
||||
pre-commit
|
||||
|
22
tox.ini
22
tox.ini
@ -1,7 +1,7 @@
|
||||
[tox]
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
envlist = py{34,27,35}, pep8, pypy
|
||||
envlist = py{34,27,35}, linters, pypy
|
||||
|
||||
[testenv]
|
||||
setenv =
|
||||
@ -39,27 +39,25 @@ commands =
|
||||
coverage html -d cover
|
||||
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]
|
||||
basepython = python3
|
||||
commands = flake8
|
||||
commands =
|
||||
pre-commit run --all
|
||||
|
||||
[testenv:docs]
|
||||
basepython = python3
|
||||
commands = python setup.py build_sphinx
|
||||
commands = python setup.py build_sphinx -W
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
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]
|
||||
basepython = python3
|
||||
# Do not install any requirements. We want this to be fast and work even if
|
||||
|
Loading…
Reference in New Issue
Block a user