Skip to content

Commit 602c646

Browse files
create string YAML block
add test use platforms debugging print output use arguments `fill`, `fill_platforms`, `fill_factors`
1 parent 9025ab8 commit 602c646

File tree

5 files changed

+296
-21
lines changed

5 files changed

+296
-21
lines changed

.github/workflows/test_tox.yml

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

82+
test_supported_pythons:
83+
uses: ./.github/workflows/tox.yml
84+
with:
85+
envs: |
86+
- linux: py3
87+
fill: true
88+
fill_platforms: linux
89+
fill_factors: xdist
90+
pytest: false
91+
8292
test_libraries:
8393
uses: ./.github/workflows/tox.yml
8494
with:

.github/workflows/tox.yml

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

tools/supported_pythons.py

Lines changed: 26 additions & 11 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
@@ -21,26 +20,40 @@
2120

2221
@click.command()
2322
@click.option("--source", default=None)
24-
@click.option("--flags", default=None)
23+
@click.option("--factors", 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,
28-
flags: list[str] = None,
28+
factors: list[str] = None,
2929
no_eoas: bool = False,
30+
platforms: list[str] = None,
3031
):
3132
"""enumerate toxenvs Python from a package source"""
3233

33-
toxenvs = supported_python_toxenvs(source, flags, no_eoas)
34-
print(json.dumps(toxenvs, indent=2))
34+
if platforms is None:
35+
platforms = ["linux"]
36+
elif isinstance(platforms, str):
37+
platforms = platforms.split(",")
38+
39+
toxenvs = supported_python_toxenvs(source, factors, no_eoas)
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(
4050
source: Path = None,
41-
flags: list[str] = None,
51+
factors: list[str] = None,
4252
no_eoas: bool = False,
4353
) -> list[str]:
54+
if isinstance(factors, str):
55+
factors = factors.split(",")
56+
4457
current_pythons = current_python_versions(no_eoas=no_eoas)
4558

4659
if source is None or source == "":
@@ -50,15 +63,17 @@ def supported_python_toxenvs(
5063
try:
5164
python_requirements = SpecifierSet(configuration["project"]["requires-python"])
5265

53-
supported_pythons = [python for python in current_pythons if python in python_requirements]
66+
supported_pythons = [
67+
python for python in current_pythons if python in python_requirements
68+
]
5469
except (KeyError, TypeError):
5570
warnings.warn(
5671
"could not find `requires-python` in metadata; falling back to current Python versions..."
5772
)
5873
supported_pythons = current_pythons
5974

6075
return [
61-
f"py{str(python).replace('.', '')}{'-' + '-'.join(flags) if flags is not None and len(flags) > 0 else ''}"
76+
f"py{str(python).replace('.', '')}{'-' + '-'.join(factors) if factors is not None and len(factors) > 0 else ''}"
6277
for python in supported_pythons
6378
]
6479

@@ -77,4 +92,4 @@ def current_python_versions(no_eoas: bool = False) -> list[Version]:
7792

7893

7994
if __name__ == "__main__":
80-
load_supported_python_toxenvs()
95+
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)