Skip to content

Commit

Permalink
add attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
KB-perByte committed Nov 6, 2023
1 parent 665f9d8 commit 77528c3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 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
# import q
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,13 +109,18 @@ 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",
default=False,
# choices=["all", "sanity", "integration", "unit"],
help="Emit a github matrix",
# type=str,
)

parser.add_argument(
Expand Down Expand Up @@ -157,11 +161,11 @@ def tox_add_core_config(
global TOX_WORK_DIR # pylint: disable=global-statement # noqa: PLW0603
TOX_WORK_DIR = state.conf.work_dir
env_list = add_ansible_matrix(state)
# q(state.conf.options.gh_matrix)

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 @@ -258,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

0 comments on commit 77528c3

Please sign in to comment.