Skip to content

Commit

Permalink
Match actual version instead of regex in build CI job (#3396)
Browse files Browse the repository at this point in the history
  • Loading branch information
lioman authored Sep 20, 2024
1 parent 2f9d382 commit 84db21c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pelican/tests/build_test/test_build_files.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import importlib.metadata
import tarfile
from pathlib import Path
from re import match
from zipfile import ZipFile

import pytest

version = importlib.metadata.version("pelican")


@pytest.mark.skipif(
"not config.getoption('--check-build')",
Expand All @@ -16,7 +19,7 @@ def test_wheel_contents(pytestconfig):
that everything that is needed is included in the final build
"""
dist_folder = pytestconfig.getoption("--check-build")
wheels = Path(dist_folder).rglob("*.whl")
wheels = Path(dist_folder).rglob(f"pelican-{version}-py3-none-any.whl")
for wheel_file in wheels:
files_list = ZipFile(wheel_file).namelist()
# Check if theme files are copied to wheel
Expand Down Expand Up @@ -52,7 +55,7 @@ def test_sdist_contents(pytestconfig, expected_file):
that everything that is needed is included in the final build.
"""
dist_folder = pytestconfig.getoption("--check-build")
sdist_files = Path(dist_folder).rglob("*.tar.gz")
sdist_files = Path(dist_folder).rglob(f"pelican-{version}.tar.gz")
for dist in sdist_files:
files_list = tarfile.open(dist, "r:gz").getnames()
dir_matcher = ""
Expand All @@ -61,6 +64,6 @@ def test_sdist_contents(pytestconfig, expected_file):
filtered_values = [
path
for path in files_list
if match(rf"^pelican-\d+\.\d+\.\d+/{expected_file}{dir_matcher}$", path)
if match(rf"^pelican-{version}/{expected_file}{dir_matcher}$", path)
]
assert len(filtered_values) > 0

0 comments on commit 84db21c

Please sign in to comment.