diff --git a/README.md b/README.md index cbad4c5..240ba51 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,22 @@ The returned tox environment name from returned `passed_name` was replaced by - run: ${{ matrix.command }} ``` +## Returned values + +This action returns a list of actions to be executed, each of them containing +the following fields: + +- `name` of the job to run + +- `command`, and optional `command2`, `command3`, ... which are the commands + to be executed using `run: ` step. + +- `python_version` is a string compatible with the expected format used by + [actions/setup-python](https://github.com/actions/setup-python) github action, + like `3.12` or `3.11\n3.12` when multiple python versions are to be installed. + +- `os` the name of an github runner, should be passed to `runs_on: ` + ## Examples Simple workflow using coactions/dynamic-matrix diff --git a/entrypoint.py b/entrypoint.py index ddba213..70b0035 100755 --- a/entrypoint.py +++ b/entrypoint.py @@ -122,10 +122,12 @@ def sort_key(s: str) -> tuple[int, str]: commands = _.split(";") env_python = default_python # Check for using correct python version for other_names like py310-devel. - match = re.search(r"py(\d+)", name) - if match: - py_version = match.groups()[0] + pythons: list[str] = [] + for py_version in re.findall(r"py(\d+)", line): env_python = f"{py_version[0]}.{py_version[1:]}" + pythons.append(PYTHON_REDIRECTS.get(env_python, env_python)) + if not pythons: + pythons.append(default_python) for platform_name in platform_names_sorted: if platform_name in name: break @@ -135,7 +137,7 @@ def sort_key(s: str) -> tuple[int, str]: data = { "name": name, "command": commands[0], - "python_version": PYTHON_REDIRECTS.get(env_python, env_python), + "python_version": "\n".join(pythons), "os": PLATFORM_MAP[platform_name], } for index, command in enumerate(commands[1:]): diff --git a/tests/test_action.py b/tests/test_action.py index 84f042b..3ddb828 100644 --- a/tests/test_action.py +++ b/tests/test_action.py @@ -19,7 +19,7 @@ "INPUT_MACOS": "minmax", "INPUT_MAX_PYTHON": "3.8", "INPUT_MIN_PYTHON": "3.8", - "INPUT_OTHER_NAMES": "z\nall-linux-arm64:tox -e unit;tox -e integration", + "INPUT_OTHER_NAMES": "z\nall-linux-arm64:tox -e py38-unit;tox -e py310-integration", "INPUT_PLATFORMS": "linux-arm64:ubuntu-24.04-arm64-2core", "INPUT_SKIP_EXPLODE": "1", "INPUT_WINDOWS": "minmax", @@ -28,11 +28,11 @@ "matrix": { "include": [ { - "command": "tox -e unit", - "command2": "tox -e integration", + "command": "tox -e py38-unit", + "command2": "tox -e py310-integration", "name": "all-linux-arm64", "os": "ubuntu-24.04-arm64-2core", - "python_version": "3.8", + "python_version": "3.8\n3.10", }, { "command": "tox -e z", @@ -71,5 +71,5 @@ def test_action(passed_env: dict[str, str], expected: dict[str, str]) -> None: assert isinstance(data, dict), data assert len(data) == 1 assert "matrix" in data - assert data == expected + assert data == expected, result # TestCase().assertDictEqual(data, expected)