Skip to content

Commit

Permalink
Merge pull request #8 from jpopelka/1.6
Browse files Browse the repository at this point in the history
Pre-1.6 polishing
  • Loading branch information
jpopelka authored Sep 14, 2023
2 parents d56aa43 + 474ec24 commit 692b3eb
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 181 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:

jobs:
pages:
# To not run in forks
if: github.repository_owner == 'fedora-ci'
runs-on: ubuntu-latest
environment:
name: github-pages
Expand Down
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

repos:
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.289
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -27,11 +28,6 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: [--max-line-length=100]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ dependency graph.

## Requirements

- Python 3.8
- Python 3.9

## External Dependencies

In order to run the tool, the following pre-requisites need to be installed:

- [rpm](http://rpm.org)
- [librepo](https://github.com/rpm-software-management/librepo)
- [hawkey](https://github.com/rpm-software-management/hawkey)
- [libsolv](https://github.com/openSUSE/libsolv)

For development and tests:
Expand All @@ -24,9 +23,3 @@ For development and tests:
## Documentation

- https://fedora-ci.github.io/rpmdeplint

## Using

A user guide is provided by the man(1) page shipped with this tool:

man rpmdeplint
24 changes: 11 additions & 13 deletions acceptance_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


class NonSpewingWSGIRequestHandler(wsgiref.simple_server.WSGIRequestHandler):
def log_message(self, format, *args):
def log_message(self, _format, *args):
# The default implementation writes to stderr, which makes a mess in
# the test suite. Use stdlib logging instead so that it can be captured
# with everything else.
logger.info(format, *args)
logger.info(_format, *args)


class WSGIServer(Thread):
Expand Down Expand Up @@ -83,19 +83,19 @@ def __call__(self, environ, start_response):
return []


@pytest.fixture
def dir_server(request):
@pytest.fixture()
def dir_server():
"""
Defines a HTTP test server for listing directory contents.
Defines an HTTP test server for listing directory contents.
"""
server = DirServer()
server.start()
request.addfinalizer(server.stop)
return server
yield server
server.stop()


@pytest.fixture(autouse=True)
def rpmfluff_leak_finder(request):
def _rpmfluff_leak_finder():
"""
Adds a finalizer which will fail any test that has left behind
a test-rpmbuild-* directory. These are created by rpmfluff in order to
Expand All @@ -105,8 +105,6 @@ def rpmfluff_leak_finder(request):
re-use whatever is in the directory (even if it's wrong).
"""

def _finalize():
if any(entry.startswith("test-rpmbuild-") for entry in os.listdir(".")):
raise AssertionError("Test failed to clean up rpmfluff build directory")

request.addfinalizer(_finalize)
yield
if any(entry.startswith("test-rpmbuild-") for entry in os.listdir(".")):
raise AssertionError("Test failed to clean up rpmfluff build directory")
42 changes: 19 additions & 23 deletions acceptance_tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
import time
from pathlib import Path

from data_setup import run_rpmdeplint
from rpmfluff import SimpleRpmBuild, SourceFile
from rpmfluff.yumrepobuild import YumRepoBuild

from data_setup import run_rpmdeplint
from rpmdeplint.repodata import cache_entry_path


def expected_cache_path(repodir: str, suffix: str, old=False) -> Path:
def expected_cache_path(repodir: str, name: str, old=False) -> Path:
"""
For the test repo located in *repodir*, return the path within the
rpmdeplint cache where we expect the metadata file with given suffix
to appear after rpmdeplint has downloaded it.
"""
file = next(Path(repodir, "repodata").glob(f"*{suffix}"))
file = next(Path(repodir, "repodata").glob(f"*-{name}.*"))
checksum = file.name.split("-", 1)[0]
return cache_entry_path(checksum) / file.name if old else cache_entry_path(checksum)

Expand Down Expand Up @@ -66,7 +66,7 @@ def cleanUp():
request.addfinalizer(cleanUp)

exitcode, out, err = run_rpmdeplint(
["rpmdeplint", "check", "--repo=base,{}".format(dir_server.url)]
["rpmdeplint", "check", f"--repo=base,{dir_server.url}"]
+ [p.get_built_rpm("i386") for p in test_packages]
)
assert exitcode == 3
Expand Down Expand Up @@ -107,7 +107,7 @@ def cleanUp():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p_noarch.get_built_rpm("noarch"),
p_archful.get_built_rpm("i386"),
]
Expand Down Expand Up @@ -139,12 +139,12 @@ def cleanUp():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p1.get_built_rpm("i386"),
]
)

cache_path = expected_cache_path(baserepo.repoDir, "primary.xml.gz")
cache_path = expected_cache_path(baserepo.repoDir, "primary.xml")
assert cache_path.exists()
original_cache_mtime = cache_path.stat().st_mtime

Expand All @@ -157,7 +157,7 @@ def cleanUp():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p1.get_built_rpm("i386"),
]
)
Expand Down Expand Up @@ -191,16 +191,14 @@ def cleanup():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p1.get_built_rpm("i386"),
]
)
assert exitcode == 0

first_primary_cache_path = expected_cache_path(firstrepo.repoDir, "primary.xml.gz")
first_filelists_cache_path = expected_cache_path(
firstrepo.repoDir, "filelists.xml.gz"
)
first_primary_cache_path = expected_cache_path(firstrepo.repoDir, "primary.xml")
first_filelists_cache_path = expected_cache_path(firstrepo.repoDir, "filelists.xml")

assert first_primary_cache_path.exists()
assert first_filelists_cache_path.exists()
Expand All @@ -223,17 +221,15 @@ def cleanup2():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p2.get_built_rpm("i386"),
]
)
assert exitcode == 0

second_primary_cache_path = expected_cache_path(
secondrepo.repoDir, "primary.xml.gz"
)
second_primary_cache_path = expected_cache_path(secondrepo.repoDir, "primary.xml")
second_filelists_cache_path = expected_cache_path(
secondrepo.repoDir, "filelists.xml.gz"
secondrepo.repoDir, "filelists.xml"
)

# Ensure the cache only has files from the second one
Expand All @@ -255,8 +251,8 @@ def cleanUp():

request.addfinalizer(cleanUp)

old_cache_path = expected_cache_path(repo.repoDir, "primary.xml.gz", old=True)
new_cache_path = expected_cache_path(repo.repoDir, "primary.xml.gz")
old_cache_path = expected_cache_path(repo.repoDir, "primary.xml", old=True)
new_cache_path = expected_cache_path(repo.repoDir, "primary.xml")

# Simulate the old cache path left over from an older version of rpmdeplint
old_cache_path.parent.mkdir(parents=True)
Expand All @@ -266,7 +262,7 @@ def cleanUp():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p1.get_built_rpm("i386"),
]
)
Expand All @@ -276,7 +272,7 @@ def cleanUp():
assert new_cache_path.is_file()


def test_prints_error_on_repo_download_failure(request, dir_server):
def test_prints_error_on_repo_download_failure(request):
# Specifically we don't want an unhandled exception, because that triggers abrt.
test_tool_rpm = SimpleRpmBuild("test-tool", "10", "3.el6", ["x86_64"])
test_tool_rpm.make()
Expand Down Expand Up @@ -323,7 +319,7 @@ def cleanUp():
[
"rpmdeplint",
"check",
"--repo=base,{}".format(dir_server.url),
f"--repo=base,{dir_server.url}",
p1.get_built_rpm("x86_64"),
]
)
Expand Down
Loading

0 comments on commit 692b3eb

Please sign in to comment.