From 2a25db9ee6ed2de3ea64b074ccf937f62f4db7f6 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 2 Sep 2022 16:14:09 +1000 Subject: [PATCH] Start running dib-lint again A recent change that didn't fail with hard-tabs made me realise we're not running tox -e pep8 ... which means we're not running dib-lint which should find this (and other things). I couldn't pinpoint when this happened; maybe job config was never in this repo. Anyway, move the pylint and dib-lint/flake8 testing to the now standard "linters" and update the linting job to openstack-tox-linters. It looks like pylint is very lightly used (came in with I7e24d8348db3aef79e1395d12692199a1f80161a and we've never expanded any testing). Leave this alone for now, but probably it is not important any more. This revealed some issues; updated flake8 (Iaa19c36f8cab8482a01f764c588375db8e7d8be3) found some spacing issues with keywords and an update to elrepo to match our standard bash flags. Change-Id: I45bf108c467f7c8190ca252e6c48450c2622aaf8 --- .zuul.d/project.yaml | 4 ++-- diskimage_builder/block_device/tests/test_lvm.py | 2 +- diskimage_builder/element_dependencies.py | 2 +- diskimage_builder/elements/elrepo/pre-install.d/01-elrepo | 3 ++- tox.ini | 8 +++----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.zuul.d/project.yaml b/.zuul.d/project.yaml index 0798509a..274cca1d 100644 --- a/.zuul.d/project.yaml +++ b/.zuul.d/project.yaml @@ -9,7 +9,7 @@ - tripleo-buildimage-jobs-centos-8 check: jobs: - - openstack-tox-pylint + - openstack-tox-linters - tox-py36: nodeset: nodes: @@ -55,7 +55,7 @@ - dib-functests-arm64-rpm gate: jobs: - - openstack-tox-pylint + - openstack-tox-linters - tox-py36: nodeset: nodes: diff --git a/diskimage_builder/block_device/tests/test_lvm.py b/diskimage_builder/block_device/tests/test_lvm.py index 692f1a1e..db294283 100644 --- a/diskimage_builder/block_device/tests/test_lvm.py +++ b/diskimage_builder/block_device/tests/test_lvm.py @@ -60,7 +60,7 @@ class TestLVM(tc.TestGraphGeneration): LVMPlugin, bad_config, {}, {}) bad_config = copy.deepcopy(lvm_config) - del(bad_config['lvs'][0]['size']) + del bad_config['lvs'][0]['size'] self.assertRaisesRegex(BlockDeviceSetupException, "Missing 'size' or 'extents' in lvs config", LVMPlugin, bad_config, {}, {}) diff --git a/diskimage_builder/element_dependencies.py b/diskimage_builder/element_dependencies.py index a5e8b738..522d16fd 100644 --- a/diskimage_builder/element_dependencies.py +++ b/diskimage_builder/element_dependencies.py @@ -178,7 +178,7 @@ def _expand_element_dependencies(user_elements, all_elements): raise MissingOSException("Please include an operating system element") out = final_elements - provided - return([all_elements[element] for element in out]) + return [all_elements[element] for element in out] def _find_all_elements(paths=None): diff --git a/diskimage_builder/elements/elrepo/pre-install.d/01-elrepo b/diskimage_builder/elements/elrepo/pre-install.d/01-elrepo index 9a8eca74..5da0522b 100755 --- a/diskimage_builder/elements/elrepo/pre-install.d/01-elrepo +++ b/diskimage_builder/elements/elrepo/pre-install.d/01-elrepo @@ -4,7 +4,8 @@ if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then set -x fi -set -euo pipefail +set -eu +set -o pipefail case "$DISTRO_NAME" in centos* | rhel* | rocky*) diff --git a/tox.ini b/tox.ini index 1640248a..b3394a7c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,pylint,py3 +envlist = pep8,linters,py3 minversion = 3.18.0 skipsdist = True ignore_basepython_conflict = True @@ -18,14 +18,12 @@ passenv= deps = bindep commands = bindep test -[testenv:pep8] +[testenv:linters] commands = + pylint --rcfile pylint.cfg diskimage_builder flake8 {posargs} dib-lint -[testenv:pylint] -commands = pylint --rcfile pylint.cfg diskimage_builder - [testenv:venv] commands = {posargs}