From 91af45019b8a45eca9b4aeb66a1de614859734b8 Mon Sep 17 00:00:00 2001 From: Saul Wold Date: Tue, 14 May 2019 13:31:12 -0700 Subject: [PATCH] Tox: add tox job and requirements to improve specfiles This is a tox job to scan the RPM specfiles and do some initial sanity checks and use the OpenDev Spec-Cleaner tool, this is not a 'linter' per-se, but will output a diff of recommended changes for the specfile. Initial disable cleaning our default CentOS specfiles since we know they need work, we can enable this later. This uses the speclint script in starlingx/integ a proposed by the Depends-On. The recommended guildline for openSUSE is located here: https://en.opensuse.org/openSUSE:Specfile_guidelines Fix up fm-rest-api opensuse specfile Depends-On: https://review.opendev.org/664995 Change-Id: I46da780a667569a9dccedd551d955c983e9601cd Signed-off-by: Saul Wold --- .zuul.yaml | 11 +++++++++++ bindep.txt | 2 ++ fm-rest-api/opensuse/fm-rest-api.spec | 6 +++--- test-requirements.txt | 1 + tox.ini | 22 +++++++++++++++++++++- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 bindep.txt diff --git a/.zuul.yaml b/.zuul.yaml index ae37045b..9dd45a71 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -11,6 +11,8 @@ - openstack-tox-linters - openstack-tox-pep8 - stx-fault-build + - flock-check-packaging: + voting: false gate: jobs: - build-openstack-api-ref @@ -56,3 +58,12 @@ fault: https://opendev.org/starlingx/fault integ: https://opendev.org/starlingx/integ update: https://opendev.org/starlingx/update + +- job: + name: flock-check-packaging + parent: tox + description: Sanity check RPM spec files + required-projects: + - name: starlingx/integ + vars: + tox_envlist: rpm-packaging-lint diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 00000000..2873110a --- /dev/null +++ b/bindep.txt @@ -0,0 +1,2 @@ +diffutils +rpm diff --git a/fm-rest-api/opensuse/fm-rest-api.spec b/fm-rest-api/opensuse/fm-rest-api.spec index c4a2120a..b0f92653 100644 --- a/fm-rest-api/opensuse/fm-rest-api.spec +++ b/fm-rest-api/opensuse/fm-rest-api.spec @@ -6,16 +6,16 @@ License: Apache-2.0 Group: Development/Tools/Other URL: https://opendev.org/starlingx/fault Source0: %{name}-%{version}.tar.xz -BuildRequires: python2-oslo.config +BuildRequires: insserv-compat BuildRequires: python-oslo.db -BuildRequires: python2-oslo.log BuildRequires: python-oslo.messaging BuildRequires: python-oslo.middleware BuildRequires: python-setuptools +BuildRequires: python2-oslo.config +BuildRequires: python2-oslo.log BuildRequires: python2-pip BuildRequires: systemd BuildRequires: systemd-rpm-macros -BuildRequires: insserv-compat Requires: python-eventlet Requires: python-paste Requires: python-webob diff --git a/test-requirements.txt b/test-requirements.txt index 71c1c3c4..a0833c46 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,4 @@ hacking!=0.13.0,<0.14,>=0.12.0 bashate >= 0.2 PyYAML >= 3.1.0 yamllint >= 0.5.2 +spec_cleaner>=1.0.9 diff --git a/tox.ini b/tox.ini index 369605a5..6803b471 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = linters,pep8 +envlist = linters,pep8,rpm-packaging-lint minversion = 2.3 skipsdist = True @@ -11,6 +11,26 @@ setenv = VIRTUAL_ENV={envdir} OS_TEST_TIMEOUT=60 deps = -r{toxinidir}/test-requirements.txt +[testenv:rpm-packaging-lint] +basepython = python3 +setenv = + VIRTUAL_ENV={envdir} + LC_ALL=en_US.utf-8 +install_command = pip install -U \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt} \ + {opts} {packages} +deps = -r{toxinidir}/test-requirements.txt +whitelist_externals = bash +commands = + bash -c 'if [ -d {toxinidir}/../integ ]; then integdir={toxinidir}/../integ; \ + else integdir={toxinidir}/../stx-integ; \ + fi; \ + find . \ + -not \( -type d -name .?\* -prune \) \ + -not \( -type d -name centos -prune \) \ + -type f -name \*.spec \ + -print0 | xargs -0 $integdir/tools/spec-tools/speclint.sh' + [testenv:linters] basepython = python3 whitelist_externals = bash