From 2c7ddf85160bf693f0335dd9c1debcc66c5cf5e2 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Mon, 7 Aug 2023 18:49:21 +0530 Subject: [PATCH 1/3] Allow molecule to list scenarios present under molecule directory within a collection --- src/molecule/command/base.py | 11 +++++++++-- src/molecule/command/list.py | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/molecule/command/base.py b/src/molecule/command/base.py index 338e068f33..7393d08f22 100644 --- a/src/molecule/command/base.py +++ b/src/molecule/command/base.py @@ -21,11 +21,13 @@ import abc import collections -import glob import logging import os import shutil from typing import Any, Callable +import wcmatch.pathlib +import wcmatch.wcmatch +from wcmatch import glob import click from click_help_colors import HelpColorsCommand, HelpColorsGroup @@ -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) diff --git a/src/molecule/command/list.py b/src/molecule/command/list.py index 09f419d950..5456a0017b 100644 --- a/src/molecule/command/list.py +++ b/src/molecule/command/list.py @@ -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)) From 5171ee56c2eb20ae2e75f1cf32840f72a8e2f0d6 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Mon, 7 Aug 2023 18:54:56 +0530 Subject: [PATCH 2/3] Fix ci issues --- .pre-commit-config.yaml | 2 ++ src/molecule/command/base.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9469f6447e..6fcd3f2d3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,6 +72,7 @@ repos: - types-filelock - types-jsonschema - types-setuptools + - wcmatch - repo: https://github.com/pycqa/pylint rev: v3.0.0a6 hooks: @@ -88,3 +89,4 @@ repos: - pexpect - pytest-mock - pytest-testinfra + - wcmatch diff --git a/src/molecule/command/base.py b/src/molecule/command/base.py index 7393d08f22..5089096041 100644 --- a/src/molecule/command/base.py +++ b/src/molecule/command/base.py @@ -25,12 +25,12 @@ import os import shutil from typing import Any, Callable -import wcmatch.pathlib -import wcmatch.wcmatch -from wcmatch import glob 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 From 71943d4b871c14cd21e4c4397e5a8f0733a5145e Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Mon, 7 Aug 2023 19:54:31 +0530 Subject: [PATCH 3/3] Add wcmatch as dependency --- .config/requirements.in | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/requirements.in b/.config/requirements.in index bdcd7a7e6d..784de1e9ba 100644 --- a/.config/requirements.in +++ b/.config/requirements.in @@ -9,3 +9,4 @@ packaging pluggy >= 0.7.1, < 2.0 PyYAML >= 5.1 rich >= 9.5.1 +wcmatch>=8.1.2 # MIT