Skip to content

Commit 21a09d5

Browse files
sentrivanaclaude
andcommitted
feat(tox): Add -latest alias for each integration test suite
For every auto-generated integration, add a tox environment that aliases the highest tested version. E.g. `tox -e py3.14-httpx-latest` is equivalent to `tox -e py3.14-httpx-v0.28.1`. This makes it easy to run the latest version's tests without having to look up the exact version string. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 35fe9e4 commit 21a09d5

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

scripts/populate_tox/populate_tox.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,31 @@ def _render_dependencies(integration: str, releases: list[Version]) -> list[str]
724724
return rendered
725725

726726

727+
def _render_latest_dependencies(
728+
integration: str, latest_release: Version
729+
) -> list[str]:
730+
"""Render version-specific dependencies for the 'latest' alias.
731+
732+
Dependencies with "*" or "py3.*" constraints already match the latest
733+
env via tox factor matching, so only version-specific constraints need
734+
to be duplicated here.
735+
"""
736+
rendered = []
737+
738+
if TEST_SUITE_CONFIG[integration].get("deps") is None:
739+
return rendered
740+
741+
for constraint, deps in TEST_SUITE_CONFIG[integration]["deps"].items():
742+
if constraint == "*" or constraint.startswith("py3"):
743+
continue
744+
restriction = SpecifierSet(constraint, prereleases=True)
745+
if latest_release in restriction:
746+
for dep in deps:
747+
rendered.append(f"{integration}-latest: {dep}")
748+
749+
return rendered
750+
751+
727752
def write_tox_file(packages: dict) -> None:
728753
template = ENV.get_template("tox.jinja")
729754

@@ -744,6 +769,9 @@ def write_tox_file(packages: dict) -> None:
744769
"dependencies": _render_dependencies(
745770
integration["name"], integration["releases"]
746771
),
772+
"latest_dependencies": _render_latest_dependencies(
773+
integration["name"], integration["releases"][-1]
774+
),
747775
}
748776
)
749777
context["testpaths"].append(

scripts/populate_tox/tox.jinja

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ envlist =
6161
{% for release in integration.releases %}
6262
{{ release.rendered_python_versions }}-{{ integration.name }}-v{{ release }}
6363
{% endfor %}
64+
{{ integration.releases[-1].rendered_python_versions }}-{{ integration.name }}-latest
6465

6566
{% endfor %}
6667

@@ -143,9 +144,17 @@ deps =
143144
{{ integration.name }}-v{{ release }}: {{ integration.package }}=={{ release }}
144145
{% endif %}
145146
{% endfor %}
147+
{% if integration.extra %}
148+
{{ integration.name }}-latest: {{ integration.package }}[{{ integration.extra }}]=={{ integration.releases[-1] }}
149+
{% else %}
150+
{{ integration.name }}-latest: {{ integration.package }}=={{ integration.releases[-1] }}
151+
{% endif %}
146152
{% for dep in integration.dependencies %}
147153
{{ dep }}
148154
{% endfor %}
155+
{% for dep in integration.latest_dependencies %}
156+
{{ dep }}
157+
{% endfor %}
149158
150159
{% endfor %}
151160

scripts/split_tox_gh_actions/split_tox_gh_actions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ def parse_tox():
240240
raw_python_versions = groups["py_versions"]
241241
framework = groups["framework"]
242242

243+
# The -latest env is an alias for the highest version of the
244+
# same framework, so merge it with the base framework.
245+
if framework.endswith("-latest"):
246+
framework = framework[: -len("-latest")]
247+
243248
# collect python versions to test the framework in
244249
raw_python_versions = set(raw_python_versions.split(","))
245250
py_versions[framework] |= raw_python_versions

0 commit comments

Comments
 (0)