1
0
Fork 0
forked from github/pelican

Match actual version instead of regex in build CI job (#3396)

This commit is contained in:
Lioman 2024-09-20 14:46:29 +02:00 committed by GitHub
commit 84db21c724
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,4 @@
import importlib.metadata
import tarfile import tarfile
from pathlib import Path from pathlib import Path
from re import match from re import match
@ -5,6 +6,8 @@ from zipfile import ZipFile
import pytest import pytest
version = importlib.metadata.version("pelican")
@pytest.mark.skipif( @pytest.mark.skipif(
"not config.getoption('--check-build')", "not config.getoption('--check-build')",
@ -16,7 +19,7 @@ def test_wheel_contents(pytestconfig):
that everything that is needed is included in the final build that everything that is needed is included in the final build
""" """
dist_folder = pytestconfig.getoption("--check-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: for wheel_file in wheels:
files_list = ZipFile(wheel_file).namelist() files_list = ZipFile(wheel_file).namelist()
# Check if theme files are copied to wheel # Check if theme files are copied to wheel
@ -52,7 +55,7 @@ def test_sdist_contents(pytestconfig, expected_file):
that everything that is needed is included in the final build. that everything that is needed is included in the final build.
""" """
dist_folder = pytestconfig.getoption("--check-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: for dist in sdist_files:
files_list = tarfile.open(dist, "r:gz").getnames() files_list = tarfile.open(dist, "r:gz").getnames()
dir_matcher = "" dir_matcher = ""
@ -61,6 +64,6 @@ def test_sdist_contents(pytestconfig, expected_file):
filtered_values = [ filtered_values = [
path path
for path in files_list 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 assert len(filtered_values) > 0