From 10ce88ed2b86cb0e11dc5d0a0f12bb25829233d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Tue, 21 Jul 2020 13:36:45 +0200 Subject: [PATCH 1/8] Adding pre-commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced changes: - pre-commit config and rules - Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks. - Applying fixes for pre-commit compliance in all code. Also commit hash will be used instead of version tags in pre-commit to prevend arbitrary code from running in developer's machines. pre-commit will be used to: - trailing whitespace; - Replaces or checks mixed line ending (mixed-line-ending); - Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker); - Checks that non-binary executables have a proper shebang (check-executables-have-shebangs); - Check for files that contain merge conflict strings (check-merge-conflict); - Check for debugger imports and py37+ breakpoint() calls in python source (debug-statements); - Attempts to load all yaml files to verify syntax (check-yaml); - Run flake8 checks (flake8) (local) For further details about tests please refer to: https://github.com/pre-commit/pre-commit-hooks Change-Id: Ib18f38dbec90c62e870307bf22a8b4f193237bce Signed-off-by: Moisés Guimarães de Medeiros --- .pre-commit-config.yaml | 35 ++++++++++++++++++++++++++++++ doc/source/conf.py | 5 ++--- oslo_service/tests/test_service.py | 4 ++-- releasenotes/source/conf.py | 2 ++ test-requirements.txt | 2 ++ tox.ini | 2 +- 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9d94556 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +# We from the Oslo project decided to pin repos based on the +# commit hash instead of the version tag to prevend arbitrary +# code from running in developer's machines. To update to a +# newer version, run `pre-commit autoupdate` and then replace +# the newer versions with their commit hash. + +default_language_version: + python: python3 + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0 + hooks: + - id: trailing-whitespace + # Replaces or checks mixed line ending + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + # Forbid files which have a UTF-8 byte-order marker + - id: check-byte-order-marker + # Checks that non-binary executables have a proper shebang + - id: check-executables-have-shebangs + # Check for files that contain merge conflict strings. + - id: check-merge-conflict + # Check for debugger imports and py37+ breakpoint() + # calls in python source + - id: debug-statements + - id: check-yaml + files: .*\.(yaml|yml)$ + - repo: https://gitlab.com/pycqa/flake8 + rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3 + hooks: + - id: flake8 + additional_dependencies: + - hacking>=3.0.1,<3.1.0 diff --git a/doc/source/conf.py b/doc/source/conf.py index cdfe733..3e96e80 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2020 Red Hat, Inc. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -77,6 +79,3 @@ latex_documents = [ u'%s Documentation' % project, u'OpenStack Foundation', 'manual'), ] - -# Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/oslo_service/tests/test_service.py b/oslo_service/tests/test_service.py index 4aeff45..58be122 100644 --- a/oslo_service/tests/test_service.py +++ b/oslo_service/tests/test_service.py @@ -164,8 +164,8 @@ class ServiceLauncherTest(ServiceTestBase): # Skip ps header f.readline() - processes = [tuple(int(p) for p in l.strip().split()[:2]) - for l in f] + processes = [tuple(int(p) for p in line.strip().split()[:2]) + for line in f] return [p for p, pp in processes if pp == self.pid] def test_killed_worker_recover(self): diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 1b29268..dd1993f 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2020 Red Hat, Inc. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/test-requirements.txt b/test-requirements.txt index 10805d3..b1a1b57 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -14,3 +14,5 @@ coverage!=4.4,>=4.0 # Apache-2.0 # Bandit security code scanner bandit>=1.6.0,<1.7.0 # Apache-2.0 + +pre-commit>=2.6.0 # MIT diff --git a/tox.ini b/tox.ini index e029fb6..f20db81 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ commands = [testenv:pep8] commands = - flake8 + pre-commit run -a bandit -r oslo_service -n5 -x tests doc8 --ignore-path "doc/source/history.rst" doc/source -- GitLab From b40ddc2841c35a79a59b8cd2d7da681f7686be9e Mon Sep 17 00:00:00 2001 From: OpenStack Release Bot Date: Fri, 11 Sep 2020 21:01:10 +0000 Subject: [PATCH 2/8] Update master for stable/victoria Add file to the reno documentation build to show release notes for stable/victoria. Use pbr instruction to increment the minor version number automatically so that master versions are higher than the versions on stable/victoria. Change-Id: I6c0a29cb530fa81ccd665120553b1552e4f2351b Sem-Ver: feature --- releasenotes/source/index.rst | 1 + releasenotes/source/victoria.rst | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 releasenotes/source/victoria.rst diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst index 88413b6..05123c9 100644 --- a/releasenotes/source/index.rst +++ b/releasenotes/source/index.rst @@ -6,6 +6,7 @@ :maxdepth: 1 unreleased + victoria ussuri train stein diff --git a/releasenotes/source/victoria.rst b/releasenotes/source/victoria.rst new file mode 100644 index 0000000..4efc7b6 --- /dev/null +++ b/releasenotes/source/victoria.rst @@ -0,0 +1,6 @@ +============================= +Victoria Series Release Notes +============================= + +.. release-notes:: + :branch: stable/victoria -- GitLab From 55b744b54223f2188b33fc77bc6092d1d2b32a18 Mon Sep 17 00:00:00 2001 From: OpenStack Release Bot Date: Fri, 11 Sep 2020 21:01:12 +0000 Subject: [PATCH 3/8] Add Python3 wallaby unit tests This is an automatically generated patch to ensure unit testing is in place for all the of the tested runtimes for wallaby. See also the PTI in governance [1]. [1]: https://governance.openstack.org/tc/reference/project-testing-interface.html Change-Id: I29085c5287166077da67f1356abc6fc4b643d4d3 --- .zuul.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zuul.yaml b/.zuul.yaml index 2c16442..1155b74 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,7 +3,7 @@ - check-requirements - lib-forward-testing-python3 - openstack-lower-constraints-jobs - - openstack-python3-victoria-jobs + - openstack-python3-wallaby-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 -- GitLab From c449037ead2c8c283b9f4c291b746fd1fc0f084e Mon Sep 17 00:00:00 2001 From: likui Date: Sun, 1 Nov 2020 16:21:36 +0800 Subject: [PATCH 4/8] Use TOX_CONSTRAINTS_FILE UPPER_CONSTRAINTS_FILE is old name and deprecated -https://zuul-ci.org/docs/zuul-jobs/python-roles.html#rolevar-tox.tox_constraints_file This allows to use lower-constraints file as more readable way instead of UPPER_CONSTRAINTS_FILE=. [1] https://review.opendev.org/#/c/722814/ Change-Id: I2dcd646a65812b8951881376086533197e97f0f8 --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index f20db81..b255ae5 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ setenv = BRANCH_NAME=master CLIENT_NAME=oslo.service deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/doc/requirements.txt -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt @@ -54,7 +54,7 @@ commands = oslo_debug_helper -t oslo_service/tests {posargs} [testenv:bandit] deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt commands = bandit -r oslo_service -n5 -x tests {posargs} -- GitLab From 8b8e0717bfb1ef7194e1efeb4338d7c8e3c24874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Wed, 4 Nov 2020 10:04:59 +0100 Subject: [PATCH 5/8] Use py3 as the default runtime for tox Moving on py3 as the default runtime for tox to avoid to update this at each new cycle. Wallaby support officially the following runtimes [1]: - Python 3.6 - Python 3.8 During Victoria Python 3.7 was used as the default runtime [2] however this version isn't longer officially supported. [1] https://governance.openstack.org/tc/reference/runtimes/wallaby.html#python-runtimes-for-wallaby [2] https://governance.openstack.org/tc/reference/runtimes/victoria.html#python-runtimes-for-victoria Change-Id: If79bec3c1ae3df62d2af057e748d6110952f9dcc --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f20db81..f98f804 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.2.0 -envlist = py38,pep8,bandit +envlist = py3,pep8,bandit ignore_basepython_conflict = true [testenv] -- GitLab From b2cdfef4533163aba2a1bc96e96cc277bf230ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Wed, 4 Nov 2020 10:51:11 +0100 Subject: [PATCH 6/8] Use TOX_CONSTRAINTS_FILE UPPER_CONSTRAINTS_FILE is old name and deprecated This allows to use upper-constraints file as more readable way instead of UPPER_CONSTRAINTS_FILE=. [1] https://review.opendev.org/#/c/722814/ [2] https://zuul-ci.org/docs/zuul-jobs/python-roles.html#rolevar-tox.tox_constraints_file Change-Id: I5c0161f3c0f75f516678b7e30b9231ce80deb3ee --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index f20db81..b255ae5 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ setenv = BRANCH_NAME=master CLIENT_NAME=oslo.service deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/doc/requirements.txt -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt @@ -54,7 +54,7 @@ commands = oslo_debug_helper -t oslo_service/tests {posargs} [testenv:bandit] deps = - -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt commands = bandit -r oslo_service -n5 -x tests {posargs} -- GitLab From 383701e2317e96d81f05a9749e4c106929bb8a34 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 30 Nov 2020 08:33:00 -0500 Subject: [PATCH 7/8] Drop custom implementation of EVENTLET_HUB Eventlet uses monotonic clocks by default since 0.21, hence no need to patch that anymore. Closes-Bug: #1906262 Co-Authored-By: Dimitri John Ledkov Co-Authored-By: Michael Hudson-Doyle Change-Id: I72106068d99cc174412aa3026082ec63f1d895fe --- oslo_service/__init__.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/oslo_service/__init__.py b/oslo_service/__init__.py index 0c3807e..e69de29 100644 --- a/oslo_service/__init__.py +++ b/oslo_service/__init__.py @@ -1,33 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os - -import eventlet.patcher - - -time = eventlet.patcher.original('time') - - -def service_hub(): - # NOTE(dims): Add a custom impl for EVENTLET_HUB, so we can - # override the clock used in the eventlet hubs. The default - # uses time.time() and we need to use a monotonic timer - # to ensure that things like loopingcall work properly. - hub = eventlet.hubs.get_default_hub().Hub() - hub.clock = time.monotonic - # get_default_hub() will return a hub that is supported on this platform - hub.is_available = lambda: True - return hub - - -os.environ['EVENTLET_HUB'] = 'oslo_service:service_hub' -- GitLab From a88653d07787d1ea29ce7bd05bf73db42db48c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Fri, 18 Dec 2020 15:12:43 +0100 Subject: [PATCH 8/8] Dropping lower constraints testing We facing errors related to the new pip resolver, this topic was discussed on the ML and QA team proposed to to test lower-constraints [1]. I propose to drop this test because the complexity and recurring pain needed to maintain that now exceeds the benefits provided by this mechanismes. [1] http://lists.openstack.org/pipermail/openstack-discuss/2020-December/019390.html Change-Id: Ia531606ec2526ce1c6169296a8f254342870416d --- .zuul.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.zuul.yaml b/.zuul.yaml index 1155b74..8425030 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -2,7 +2,6 @@ templates: - check-requirements - lib-forward-testing-python3 - - openstack-lower-constraints-jobs - openstack-python3-wallaby-jobs - periodic-stable-jobs - publish-openstack-docs-pti -- GitLab