Pin publish test to 3.12 (#8951)

The bump to 3.13 broke the test
This commit is contained in:
konsti 2024-11-10 15:43:47 +01:00 committed by GitHub
parent 249089c96a
commit 874aa29b57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 11 deletions

View File

@ -1139,6 +1139,7 @@ jobs:
env: env:
# No dbus in GitHub Actions # No dbus in GitHub Actions
PYTHON_KEYRING_BACKEND: keyrings.alt.file.PlaintextKeyring PYTHON_KEYRING_BACKEND: keyrings.alt.file.PlaintextKeyring
PYTHON_VERSION: 3.12
permissions: permissions:
# For trusted publishing # For trusted publishing
id-token: write id-token: write
@ -1149,7 +1150,7 @@ jobs:
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.12" python-version: "${{ env.PYTHON_VERSION }}"
- name: "Download binary" - name: "Download binary"
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@ -1169,7 +1170,7 @@ jobs:
- name: "Publish test packages" - name: "Publish test packages"
# `-p 3.12` prefers the python we just installed over the one locked in `.python_version`. # `-p 3.12` prefers the python we just installed over the one locked in `.python_version`.
run: ./uv run -p 3.12 scripts/publish/test_publish.py --uv ./uv all run: ./uv run -p ${{ env.PYTHON_VERSION }} scripts/publish/test_publish.py --uv ./uv all
env: env:
RUST_LOG: uv=debug,uv_publish=trace RUST_LOG: uv=debug,uv_publish=trace
UV_TEST_PUBLISH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_TOKEN }} UV_TEST_PUBLISH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_TOKEN }}
@ -1177,6 +1178,7 @@ jobs:
UV_TEST_PUBLISH_GITLAB_PAT: ${{ secrets.UV_TEST_PUBLISH_GITLAB_PAT }} UV_TEST_PUBLISH_GITLAB_PAT: ${{ secrets.UV_TEST_PUBLISH_GITLAB_PAT }}
UV_TEST_PUBLISH_CODEBERG_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CODEBERG_TOKEN }} UV_TEST_PUBLISH_CODEBERG_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CODEBERG_TOKEN }}
UV_TEST_PUBLISH_CLOUDSMITH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CLOUDSMITH_TOKEN }} UV_TEST_PUBLISH_CLOUDSMITH_TOKEN: ${{ secrets.UV_TEST_PUBLISH_CLOUDSMITH_TOKEN }}
UV_TEST_PUBLISH_PYTHON_VERSION: ${{ env.PYTHON_VERSION }}
cache-test-ubuntu: cache-test-ubuntu:
timeout-minutes: 10 timeout-minutes: 10

View File

@ -69,6 +69,7 @@ from packaging.utils import (
from packaging.version import Version from packaging.version import Version
TEST_PYPI_PUBLISH_URL = "https://test.pypi.org/legacy/" TEST_PYPI_PUBLISH_URL = "https://test.pypi.org/legacy/"
PYTHON_VERSION = os.environ.get("UV_TEST_PUBLISH_PYTHON_VERSION", "3.12")
cwd = Path(__file__).parent cwd = Path(__file__).parent
@ -124,8 +125,8 @@ all_targets: dict[str, TargetConfiguration] = local_targets | {
} }
def get_new_version(project_name: str, client: httpx.Client) -> Version: def get_latest_version(project_name: str, client: httpx.Client) -> Version:
"""Return the next free patch version on all indexes of the package.""" """Return the latest version on all indexes of the package."""
# To keep the number of packages small we reuse them across targets, so we have to # To keep the number of packages small we reuse them across targets, so we have to
# pick a version that doesn't exist on any target yet # pick a version that doesn't exist on any target yet
versions = set() versions = set()
@ -151,10 +152,12 @@ def get_new_version(project_name: str, client: httpx.Client) -> Version:
time.sleep(1) time.sleep(1)
else: else:
raise RuntimeError(f"Failed to fetch {url}") from error raise RuntimeError(f"Failed to fetch {url}") from error
max_version = max(versions) return max(versions)
# Bump the path version to obtain an empty version
release = list(max_version.release) def get_new_version(latest_version: Version) -> Version:
"""Bump the path version to obtain an empty version."""
release = list(latest_version.release)
release[-1] += 1 release[-1] += 1
return Version(".".join(str(i) for i in release)) return Version(".".join(str(i) for i in release))
@ -193,7 +196,10 @@ def build_project_at_version(
if project_root.exists(): if project_root.exists():
rmtree(project_root) rmtree(project_root)
check_call([uv, "init", "--lib", "--name", project_name, dir_name], cwd=cwd) check_call(
[uv, "init", "-p", PYTHON_VERSION, "--lib", "--name", project_name, dir_name],
cwd=cwd,
)
pyproject_toml = project_root.joinpath("pyproject.toml") pyproject_toml = project_root.joinpath("pyproject.toml")
# Set to an unclaimed version # Set to an unclaimed version
@ -217,7 +223,12 @@ def build_project_at_version(
return project_root return project_root
def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path): def wait_for_index(
index_url: str,
project_name: str,
version: Version,
uv: Path,
):
"""Check that the index URL was updated, wait up to 100s if necessary. """Check that the index URL was updated, wait up to 100s if necessary.
Often enough the index takes a few seconds until the index is updated after an Often enough the index takes a few seconds until the index is updated after an
@ -231,6 +242,8 @@ def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path
uv, uv,
"pip", "pip",
"compile", "compile",
"-p",
PYTHON_VERSION,
"--index", "--index",
index_url, index_url,
"--quiet", "--quiet",
@ -241,7 +254,7 @@ def wait_for_index(index_url: str, project_name: str, version: Version, uv: Path
"-", "-",
], ],
text=True, text=True,
input=project_name, input=f"{project_name}",
) )
if f"{project_name}=={version}" in output and output.count("--hash") == 2: if f"{project_name}=={version}" in output and output.count("--hash") == 2:
break break
@ -265,7 +278,8 @@ def publish_project(target: str, uv: Path, client: httpx.Client):
print(f"\nPublish {project_name} for {target}") print(f"\nPublish {project_name} for {target}")
# The distributions are build to the dist directory of the project. # The distributions are build to the dist directory of the project.
version = get_new_version(project_name, client) previous_version = get_latest_version(project_name, client)
version = get_new_version(previous_version)
project_dir = build_project_at_version(project_name, version, uv) project_dir = build_project_at_version(project_name, version, uv)
# Upload configuration # Upload configuration