Skip to content
This repository was archived by the owner on Apr 30, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python_versions_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(koji_build, workdir='.', artifactsdir='artifacts'):
except PackageException as err:
log.error('{}: {}'.format(file_, err))
else:
if file_.endswith('.src.rpm'):
if package.is_srpm:
srpm_packages.append(package)
else:
packages.append(package)
Expand All @@ -54,7 +54,7 @@ def run(koji_build, workdir='.', artifactsdir='artifacts'):
details.append(task_two_three(packages, koji_build, artifact))
details.append(task_naming_scheme(packages, koji_build, artifact))
details.append(task_requires_naming_scheme(
packages + srpm_packages, koji_build, artifact))
srpm_packages + packages, koji_build, artifact))

# finally, the main detail with overall results
outcome = 'PASSED'
Expand Down
4 changes: 4 additions & 0 deletions taskotron_python_versions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def __init__(self, path):
except rpm.error as err:
raise PackageException('{}: {}'.format(self.filename, err))

@property
def is_srpm(self):
return self.filename.endswith('.src.rpm')

@property
def name(self):
"""Package name as a string."""
Expand Down
22 changes: 12 additions & 10 deletions taskotron_python_versions/requires.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import collections

import dnf

from .common import log, write_to_artifact
Expand Down Expand Up @@ -120,31 +118,35 @@ def task_requires_naming_scheme(packages, koji_build, artifact):
repoquery = get_dnf_query(fedora_release)

outcome = 'PASSED'
misnamed_requires = collections.defaultdict(set)

problem_rpms = set()
message_rpms = ''

for package in packages:
log.debug('Checking requires of {}'.format(package.filename))

requires = check_requires_naming_scheme(package, repoquery)
if requires:
misnamed_requires[package.nvr].update(requires)
outcome = 'FAILED'
problem_rpms.add(package.nvr)

message_rpms = ''
for package_name, requires in misnamed_requires.items():
message_rpms += '{}\n * Requires: {}\n'.format(
package_name, ', '.join(sorted(requires)))
message = '\n{} {}Requires:\n * {}\n'.format(
package.nvr,
'Build' if package.is_srpm else '',
'\n * '.join(sorted(requires)))
if message not in message_rpms:
message_rpms += message

detail = check.CheckDetail(
checkname='python-versions.requires_naming_scheme',
item=koji_build,
report_type=check.ReportType.KOJI_BUILD,
outcome=outcome)

if misnamed_requires:
if problem_rpms:
detail.artifact = artifact
write_to_artifact(artifact, MESSAGE.format(message_rpms), INFO_URL)
problems = 'Problematic RPMs:\n' + ', '.join(misnamed_requires.keys())
problems = 'Problematic RPMs:\n' + ', '.join(problem_rpms)
else:
problems = 'No problems found.'

Expand Down
12 changes: 7 additions & 5 deletions test/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,16 @@ def test_artifact_contains_requires_naming_scheme_and_looks_as_expected(

print(artifact)

expected_requires = 'python-psutil (python2-psutil is available)'

assert dedent("""
These RPMs use `python-` prefix without Python version in *Requires:
{}
* Requires: {}

tracer-0.6.9-1.fc23 BuildRequires:
* python-psutil (python2-psutil is available)

tracer-0.6.9-1.fc23 Requires:
* python-psutil (python2-psutil is available)

This is strongly discouraged and should be avoided. Please check
the required packages, and use names with either `python2-` or
`python3-` prefix.
""").strip().format(result.item, expected_requires) in artifact.strip()
""").strip() in artifact.strip()