Skip to content

Commit

Permalink
Ignore scenarios in virtual envrionments
Browse files Browse the repository at this point in the history
  • Loading branch information
audgirka committed Aug 10, 2023
1 parent aae8d28 commit 7a37dd5
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/molecule/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

import abc
import collections
import contextlib
import logging
import os
import shutil
import subprocess
from typing import Any, Callable

import click
Expand Down Expand Up @@ -184,19 +186,39 @@ def get_configs(args, command_args, ansible_args=(), glob_str=MOLECULE_GLOB):
`ansible-playbook` command.
:return: list
"""
scenario_paths = glob.glob(
glob_str,
flags=wcmatch.pathlib.GLOBSTAR
| wcmatch.pathlib.BRACE
| wcmatch.pathlib.DOTGLOB,
)
command = ["git", "check-ignore", *scenario_paths]

with contextlib.suppress(subprocess.CalledProcessError, FileNotFoundError):
proc = subprocess.run(
args=command,
capture_output=True,
check=True,
text=True,
shell=False,
)

try:
ignored = proc.stdout.splitlines()
paths = [
candidate for candidate in scenario_paths if str(candidate) not in ignored
]
except NameError:
paths = scenario_paths

configs = [
config.Config(
molecule_file=util.abs_path(c),
args=args,
command_args=command_args,
ansible_args=ansible_args,
)
for c in glob.glob(
glob_str,
flags=wcmatch.pathlib.GLOBSTAR
| wcmatch.pathlib.BRACE
| wcmatch.pathlib.DOTGLOB,
)
for c in paths
]
_verify_configs(configs, glob_str)

Expand Down

0 comments on commit 7a37dd5

Please sign in to comment.