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
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
language: generic
sudo: required

services:
- docker

env:
- FEDORA=28
- FEDORA=29
- FEDORA=rawhide
- FEDORA=28 TOXENV=integration
- FEDORA=28 TOXENV=py3
- FEDORA=29 TOXENV=integration
- FEDORA=29 TOXENV=py3
- FEDORA=29 TOXENV=style
- FEDORA=rawhide TOXENV=integration
- FEDORA=rawhide TOXENV=py3

install:
- sed -i "s/fedora-28-x86_64/fedora-${FEDORA}-x86_64/" mock.cfg
Expand All @@ -16,4 +19,4 @@ install:
- docker build -t taskotron .

script:
- docker run --cap-add=SYS_ADMIN -v $(pwd):$(pwd) -w $(pwd) -i -t taskotron
- docker run --cap-add=SYS_ADMIN -v $(pwd):$(pwd) -w $(pwd) -i -e "TOXENV=$TOXENV" -t taskotron
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM fedora

RUN dnf -y install --setopt=install_weak_deps=false --setopt=tsflags=nodocs \
--setopt=deltarpm=false --allowerasing --best \
--setopt=deltarpm=false --allowerasing --best --disablerepo=\*modular \
mock tox python3-rpm python3-dnf && dnf clean all

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
Expand Down
19 changes: 12 additions & 7 deletions python_versions_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
logging.basicConfig()

import os
import pathlib
import sys

from libtaskotron import check
Expand All @@ -31,17 +32,22 @@
def run(koji_build, workdir='.', artifactsdir='artifacts',
testcase='dist.python-versions', arches=['x86_64', 'noarch', 'src']):
'''The main method to run from Taskotron'''
workdir = os.path.abspath(workdir)
results_path = os.path.join(artifactsdir, 'taskotron', 'results.yml')
artifact = os.path.join(artifactsdir, 'output.log')
artifactsdir = pathlib.Path(artifactsdir)
workdir = pathlib.Path(workdir).resolve()
resultsdir = artifactsdir / 'taskotron'
resultspath = resultsdir / 'results.yml'
artifact = artifactsdir / 'output.log'

artifactsdir.mkdir(parents=True, exist_ok=True)
resultsdir.mkdir(parents=True, exist_ok=True)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two mkdirs were needed.
cc @kparal and @frantisekz - previously it worked without this


# find files to run on
files = sorted(os.listdir(workdir))
logs = []
packages = []
srpm_packages = []
for file_ in files:
path = os.path.join(workdir, file_)
path = workdir / file_
if file_.endswith('.rpm'):
try:
package = Package(path)
Expand Down Expand Up @@ -97,7 +103,7 @@ def run(koji_build, workdir='.', artifactsdir='artifacts',
outcome=outcome,
keyvals={'arch': arches})
if outcome == 'FAILED':
overall_detail.artifact = artifact
overall_detail.artifact = str(artifact)
details.append(overall_detail)

summary = 'python-versions {} for {} ({}).'.format(
Expand All @@ -106,8 +112,7 @@ def run(koji_build, workdir='.', artifactsdir='artifacts',

# generate output reportable to ResultsDB
output = check.export_YAML(details)
with open(results_path, 'w') as results_file:
results_file.write(output)
resultspath.write_text(output)

return 0 if overall_detail.outcome in ['PASSED', 'INFO'] else 1

Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python3

import pathlib
from setuptools import setup, find_packages


description = """Taskotron checks regarding Python versions"""

with open('README.rst') as readme:
long_description = readme.read()
long_description = pathlib.Path('README.rst').read_text()

setup(
name='taskotron-python-versions',
Expand Down
2 changes: 2 additions & 0 deletions taskotron_python_versions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def packages_by_version(packages):
"""
pkg_by_version = collections.defaultdict(list)
for package in packages:
if package.py_versions is None: # SRPMS
continue
for version in package.py_versions:
pkg_by_version[version].append(package)
return pkg_by_version
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def task_executables(packages, koji_build, artifact):
outcome=outcome)

if message:
detail.artifact = artifact
write_to_artifact(artifact, MESSAGE.format(message), INFO_URL)
detail.artifact = str(artifact)

log.info('subcheck executables {} for {}'.format(
outcome, koji_build))
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/naming_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def task_naming_scheme(packages, koji_build, artifact):
outcome=outcome)

if incorrect_names:
detail.artifact = artifact
names = ', '.join(incorrect_names)
write_to_artifact(artifact, MESSAGE.format(names), INFO_URL)
detail.artifact = str(artifact)
problems = 'Problematic RPMs:\n' + names
else:
problems = 'No problems found.'
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/py3_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def task_py3_support(packages, koji_build, artifact):
outcome=outcome)

if message:
detail.artifact = artifact
write_to_artifact(artifact, MESSAGE.format(message), INFO_URL)
detail.artifact = str(artifact)

log.info('subcheck py3_support {} for {}'.format(
outcome, koji_build))
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/python_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def task_python_usage(packages, koji_build, artifact):
outcome=outcome)

if problem_rpms:
detail.artifact = artifact
write_to_artifact(
artifact, MESSAGE.format('\n * '.join(problem_rpms)),
INFO_URL)
detail.artifact = str(artifact)
problems = 'Problematic RPMs:\n' + ', '.join(problem_rpms)
else:
problems = 'No problems found.'
Expand Down
4 changes: 2 additions & 2 deletions taskotron_python_versions/python_usage_obsoleted.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def task_python_usage_obsoleted(logs, koji_build, artifact):

if file_contains(buildlog, WARNING):
log.debug('{} contains our warning'.format(buildlog))
_, _, arch = buildlog.rpartition('.')
arch = buildlog.suffix.lstrip('.')
problem_arches.add(arch)
outcome = 'FAILED'

Expand All @@ -51,9 +51,9 @@ def task_python_usage_obsoleted(logs, koji_build, artifact):
outcome=outcome)

if problem_arches:
detail.artifact = artifact
info = '{}: {}'.format(koji_build, ', '.join(sorted(problem_arches)))
write_to_artifact(artifact, MESSAGE.format(info), INFO_URL)
detail.artifact = str(artifact)
problems = 'Problematic architectures: ' + info
else:
problems = 'No problems found.'
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def task_requires_naming_scheme(packages, koji_build, artifact):
outcome=outcome)

if problem_rpms:
detail.artifact = artifact
write_to_artifact(artifact, MESSAGE.format(message_rpms), INFO_URL)
detail.artifact = str(artifact)
problems = 'Problematic RPMs:\n' + ', '.join(problem_rpms)
else:
problems = 'No problems found.'
Expand Down
2 changes: 1 addition & 1 deletion taskotron_python_versions/two_three.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def task_two_three(packages, koji_build, artifact):
outcome=outcome)

if bads:
detail.artifact = artifact
rpms = ''
for name, py_versions in bads.items():
rpms += ('{}\n'
Expand All @@ -154,6 +153,7 @@ def task_two_three(packages, koji_build, artifact):
py_versions[2],
py_versions[3]))
write_to_artifact(artifact, MESSAGE.format(rpms), INFO_URL)
detail.artifact = str(artifact)
names = ', '.join(str(k) for k in bads.keys())
problems = 'Problematic RPMs:\n' + names
else:
Expand Down
6 changes: 3 additions & 3 deletions taskotron_python_versions/unversioned_shebangs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_problematic_files(archive, query):
the shebang query is encoded as well. We only test for ASCII shebangs.
"""
problematic = set()
with libarchive.file_reader(archive) as a:
with libarchive.file_reader(str(archive)) as a:
for entry in a:
try:
first_line = next(entry.get_blocks(), '').splitlines()[0]
Expand Down Expand Up @@ -112,7 +112,7 @@ def check_logs(logs):
for buildlog in logs:
if file_contains(buildlog, WARNING):
log.debug('{} contains our warning'.format(buildlog))
_, _, arch = buildlog.rpartition('.')
arch = buildlog.suffix.lstrip('.')
problem_arches.add(arch)
return ', '.join(sorted(problem_arches))

Expand Down Expand Up @@ -148,8 +148,8 @@ def task_unversioned_shebangs(packages, logs, koji_build, artifact):
outcome=outcome)

if outcome == 'FAILED':
detail.artifact = artifact
write_to_artifact(artifact, message, INFO_URL)
detail.artifact = str(artifact)
else:
problems = 'No problems found.'

Expand Down
20 changes: 16 additions & 4 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import pytest
from xdist.scheduler import LoadScopeScheduling


def parse_fixture_name(nodeid):
if '[' in nodeid:
parameters = nodeid.rsplit('[')[-1].replace(']', '')
return parameters.split('-')[0]
return None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the last return is redundunt.



def pytest_addoption(parser):
parser.addoption('--fake', action='store_true', default=False,
help='don\'t run the code, reuse the result from '
Expand All @@ -12,11 +20,15 @@ class FixtureScheduling(LoadScopeScheduling):
See https://github.com/pytest-dev/pytest-xdist/issues/18
"""
def _split_scope(self, nodeid):
if '[' in nodeid:
parameters = nodeid.rsplit('[')[-1].replace(']', '')
return parameters.split('-')[0]
return None
return parse_fixture_name(nodeid)


def pytest_xdist_make_scheduler(log, config):
return FixtureScheduling(config, log)


def pytest_collection_modifyitems(items):
for item in items:
fixture = parse_fixture_name(item.nodeid)
if fixture:
item.add_marker(getattr(pytest.mark, fixture))
Loading