Skip to content

Commit

Permalink
Allow molecule to list scenarios present under molecule directory wit…
Browse files Browse the repository at this point in the history
…hin a collection (#3989)

Related: #3987
  • Loading branch information
audgirka committed Aug 8, 2023
1 parent 00461c6 commit 6daea25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .config/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ packaging
pluggy >= 0.7.1, < 2.0
PyYAML >= 5.1
rich >= 9.5.1
wcmatch>=8.1.2 # MIT
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ repos:
- types-filelock
- types-jsonschema
- types-setuptools
- wcmatch
- repo: https://github.com/pycqa/pylint
rev: v3.0.0a6
hooks:
Expand All @@ -88,3 +89,4 @@ repos:
- pexpect
- pytest-mock
- pytest-testinfra
- wcmatch
11 changes: 9 additions & 2 deletions src/molecule/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@

import abc
import collections
import glob
import logging
import os
import shutil
from typing import Any, Callable

import click
import wcmatch.pathlib
import wcmatch.wcmatch
from click_help_colors import HelpColorsCommand, HelpColorsGroup
from wcmatch import glob

import molecule.scenarios
from molecule import config, logger, text, util
Expand Down Expand Up @@ -189,7 +191,12 @@ def get_configs(args, command_args, ansible_args=(), glob_str=MOLECULE_GLOB):
command_args=command_args,
ansible_args=ansible_args,
)
for c in glob.glob(glob_str)
for c in glob.glob(
glob_str,
flags=wcmatch.pathlib.GLOBSTAR
| wcmatch.pathlib.BRACE
| wcmatch.pathlib.DOTGLOB,
)
]
_verify_configs(configs, glob_str)

Expand Down
5 changes: 4 additions & 1 deletion src/molecule/command/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def list(ctx, scenario_name, format): # pragma: no cover
command_args = {"subcommand": subcommand, "format": format}

statuses = []
s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name)
s = scenarios.Scenarios(
base.get_configs(args, command_args, glob_str="**/molecule/*/molecule.yml"),
scenario_name,
)
for scenario in s:
statuses.extend(base.execute_subcommand(scenario.config, subcommand))

Expand Down

0 comments on commit 6daea25

Please sign in to comment.