Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,31 @@ def _render_dependencies(integration: str, releases: list[Version]) -> list[str]
return rendered


def _render_latest_dependencies(
integration: str, latest_release: Version
) -> list[str]:
"""Render version-specific dependencies for the 'latest' alias.

Dependencies with "*" or "py3.*" constraints already match the latest
env via tox factor matching, so only version-specific constraints need
to be duplicated here.
"""
rendered = []

if TEST_SUITE_CONFIG[integration].get("deps") is None:
return rendered

for constraint, deps in TEST_SUITE_CONFIG[integration]["deps"].items():
if constraint == "*" or constraint.startswith("py3"):
continue
restriction = SpecifierSet(constraint, prereleases=True)
if latest_release in restriction:
for dep in deps:
rendered.append(f"{integration}-latest: {dep}")

return rendered


def write_tox_file(packages: dict) -> None:
template = ENV.get_template("tox.jinja")

Expand All @@ -735,15 +760,30 @@ def write_tox_file(packages: dict) -> None:
for group, integrations in packages.items():
context["groups"][group] = []
for integration in integrations:
# Find the highest stable (non-prerelease) release for the
# -latest alias. Prereleases are always appended last by
# pick_releases_to_test, so we walk backwards.
latest_stable = None
for rel in reversed(integration["releases"]):
if not rel.is_prerelease:
latest_stable = rel
break

context["groups"][group].append(
{
"name": integration["name"],
"package": integration["package"],
"extra": integration["extra"],
"releases": integration["releases"],
"latest_stable": latest_stable,
"dependencies": _render_dependencies(
integration["name"], integration["releases"]
),
"latest_dependencies": _render_latest_dependencies(
integration["name"], latest_stable
)
if latest_stable
else [],
}
)
context["testpaths"].append(
Expand Down
13 changes: 13 additions & 0 deletions scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ envlist =
{% for release in integration.releases %}
{{ release.rendered_python_versions }}-{{ integration.name }}-v{{ release }}
{% endfor %}
{% if integration.latest_stable %}
{{ integration.latest_stable.rendered_python_versions }}-{{ integration.name }}-latest
{% endif %}

{% endfor %}

Expand Down Expand Up @@ -143,9 +146,19 @@ deps =
{{ integration.name }}-v{{ release }}: {{ integration.package }}=={{ release }}
{% endif %}
{% endfor %}
{% if integration.latest_stable %}
{% if integration.extra %}
{{ integration.name }}-latest: {{ integration.package }}[{{ integration.extra }}]=={{ integration.latest_stable }}
{% else %}
{{ integration.name }}-latest: {{ integration.package }}=={{ integration.latest_stable }}
{% endif %}
{% endif %}
{% for dep in integration.dependencies %}
{{ dep }}
{% endfor %}
{% for dep in integration.latest_dependencies %}
{{ dep }}
{% endfor %}

{% endfor %}

Expand Down
7 changes: 6 additions & 1 deletion scripts/runtox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ fi

searchstring="$1"

ENV="$($TOXPATH -l | grep -- "$searchstring" | tr $'\n' ',')"
# Filter out -latest environments unless explicitly requested
if [[ "$searchstring" == *-latest* ]]; then
ENV="$($TOXPATH -l | grep -- "$searchstring" | tr $'\n' ',')"
else
ENV="$($TOXPATH -l | grep -- "$searchstring" | grep -v -- '-latest$' | tr $'\n' ',')"
fi

if [ -z "${ENV}" ]; then
echo "No targets found. Skipping."
Expand Down
5 changes: 5 additions & 0 deletions scripts/split_tox_gh_actions/split_tox_gh_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def parse_tox():
raw_python_versions = groups["py_versions"]
framework = groups["framework"]

# The -latest env is an alias for the highest version of the
# same framework, so merge it with the base framework.
if framework.endswith("-latest"):
framework = framework[: -len("-latest")]

# collect python versions to test the framework in
raw_python_versions = set(raw_python_versions.split(","))
py_versions[framework] |= raw_python_versions
Expand Down
Loading
Loading