Skip to content

Commit dfa841f

Browse files
create string YAML block
add test use platforms debugging print output
1 parent 9025ab8 commit dfa841f

File tree

5 files changed

+272
-16
lines changed

5 files changed

+272
-16
lines changed

.github/workflows/test_tox.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ jobs:
7979
posargs: 'PyPy'
8080
pytest: false
8181

82+
test_supported_pythons:
83+
uses: ./.github/workflows/tox.yml
84+
with:
85+
envs: ''
86+
pytest: false
87+
8288
test_libraries:
8389
uses: ./.github/workflows/tox.yml
8490
with:

.github/workflows/tox.yml

Lines changed: 18 additions & 9 deletions
Large diffs are not rendered by default.

tools/supported_pythons.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# "packaging==25.0",
88
# ]
99
# ///
10-
import json
1110
import os
1211
import warnings
1312
from pathlib import Path
@@ -23,17 +22,28 @@
2322
@click.option("--source", default=None)
2423
@click.option("--flags", default=None)
2524
@click.option("--no-eoas", is_flag=True, default=False)
26-
def load_supported_python_toxenvs(
25+
@click.option("--platforms", default=None)
26+
def supported_python_envs_block(
2727
source: Path = None,
2828
flags: list[str] = None,
2929
no_eoas: bool = False,
30+
platforms: list[str] = None,
3031
):
3132
"""enumerate toxenvs Python from a package source"""
3233

34+
if platforms is None:
35+
platforms = ["linux"]
36+
elif isinstance(platforms, str):
37+
platforms = platforms.split(",")
38+
3339
toxenvs = supported_python_toxenvs(source, flags, no_eoas)
34-
print(json.dumps(toxenvs, indent=2))
40+
envs_block = "\\n".join(
41+
f"- {platform}: {toxenv}" for platform in platforms for toxenv in toxenvs
42+
)
43+
44+
print(envs_block)
3545
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
36-
f.write(f"envs={json.dumps(toxenvs)}\n")
46+
f.write(f"envs={envs_block}\n")
3747

3848

3949
def supported_python_toxenvs(
@@ -50,7 +60,9 @@ def supported_python_toxenvs(
5060
try:
5161
python_requirements = SpecifierSet(configuration["project"]["requires-python"])
5262

53-
supported_pythons = [python for python in current_pythons if python in python_requirements]
63+
supported_pythons = [
64+
python for python in current_pythons if python in python_requirements
65+
]
5466
except (KeyError, TypeError):
5567
warnings.warn(
5668
"could not find `requires-python` in metadata; falling back to current Python versions..."
@@ -77,4 +89,4 @@ def current_python_versions(no_eoas: bool = False) -> list[Version]:
7789

7890

7991
if __name__ == "__main__":
80-
load_supported_python_toxenvs()
92+
supported_python_envs_block()

tools/tox_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def load_tox_targets(envs, libraries, posargs, toxdeps, toxargs, pytest, pytest_
3737
cache_restore_keys, artifact_path, runs_on, default_python, timeout_minutes):
3838
"""Script to load tox targets for GitHub Actions workflow."""
3939
# Load envs config
40-
envs = yaml.load(envs, Loader=yaml.BaseLoader)
40+
envs = yaml.load(envs.replace("\\n", "\n"), Loader=yaml.BaseLoader)
4141
print(json.dumps(envs, indent=2))
4242

4343
# Load global libraries config

uv.lock

Lines changed: 229 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)