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

Allow molecule to list scenarios present under molecule directory within a collection #3989

Merged
merged 3 commits into from
Aug 8, 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
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