Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attribute --matrix-scope for tox-ansible #242

Merged
merged 6 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 12 additions & 3 deletions src/tox_ansible/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from typing import TYPE_CHECKING, List, TypeVar

import yaml

from tox.config.loader.memory import MemoryLoader
from tox.config.loader.section import Section
from tox.config.loader.str_convert import StrConvert
Expand Down Expand Up @@ -110,6 +109,13 @@ def tox_add_option(parser: ToxParser) -> None:

:param parser: The tox CLI parser.
"""
parser.add_argument(
"--matrix-scope",
default="all",
choices=["all", "sanity", "integration", "unit"],
help="Emit a github matrix specific to scope mentioned",
)

parser.add_argument(
"--gh-matrix",
action="store_true",
Expand Down Expand Up @@ -159,7 +165,7 @@ def tox_add_core_config(
if not state.conf.options.gh_matrix:
return

generate_gh_matrix(env_list=env_list)
generate_gh_matrix(env_list=env_list, section=state.conf.options.matrix_scope)
sys.exit(0)


Expand Down Expand Up @@ -256,14 +262,17 @@ def add_ansible_matrix(state: State) -> EnvList:
return env_list


def generate_gh_matrix(env_list: EnvList) -> None:
def generate_gh_matrix(env_list: EnvList, section: str) -> None:
"""Generate the github matrix.

:param env_list: The environment list.
:param section: The test section to be generated.
"""
results = []

for env_name in env_list.envs:
if section != "all" and not env_name.startswith(section):
continue
candidates = []
factors = env_name.split("-")
for factor in factors:
Expand Down
Empty file added tox-ansible.ini
Empty file.
Loading