Silent drop of scenarios whose molecule.yml match a .gitignore rule
- Dominant language
- Python
- Stars
- 4.1k
- Forks
- 676
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 6
Description
### Prerequisites
- [x] This was not already reported in the past (duplicate check)
- [x] It does reproduce it with code from main branch (latest unreleased version)
- [x] I include a minimal example for reproducing the bug
- [x] The bug is not trivial, as for those a direct pull-request is preferred
- [x] Running `pip check` does not report any conflicts
- [x] I was able to reproduce the issue on a different machine
- [x] The issue is not specific to any driver other than 'default' one
### Environment
```
$ pip install --force-reinstall "git+https://github.com/ansible-community/molecule-plugins.git@main"
$ pip install --force-reinstall "molecule-plugins[podman] @ git+https://github.com/ansible-community/molecule-plugins.git@main"
$ molecule --version
molecule 26.8.0 using python 3.13
ansible:2.21.4
podman:26.7.16.dev4 from molecule_plugins requiring collections: containers.podman>=1.8.1
azure:26.7.16.dev4 from molecule_plugins
default:26.8.0 from molecule
openstack:26.7.16.dev4 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
ec2:26.7.16.dev4 from molecule_plugins
gce:26.7.16.dev4 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
containers:26.7.16.dev4 from molecule_plugins requiring collections: ansible.posix>=1.4.0 community.docker>=3.10.2 containers.podman>=1.8.1
docker:26.7.16.dev4 from molecule_plugins requiring collections: community.docker>=3.10.2 ansible.posix>=1.4.0
vagrant:26.7.16.dev4 from molecule_plugins
```
### What happened
Molecule test fails with `CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting` even when running from within a valid role directory, and even though the file exists and both std lib glob can correctly return it.
Root cause seems to be `get_configs -> filter_ignored_scenarios -> git check-ignore` : as a result drops any matched path that git reports as ignored, because the folder the role is in is indeed ignored, even if it is the scenario i am actually trying to locally test
The error is not helpful because "glob failed" does not actually lead the real cause, which is a git ignore match : by removing the ignore rule, it instantly works again
Suggestion: at a minimum, emit a distinct/clearer error message when scenarios are excluded specifically due to git check-ignore, not "nothing found", or let it run by not taking git ignore into account (i am new to molecule, i do not know if it is a good idea outside of my own use)
Thanks in advance
### Reproducing example
```yml
How to reproduce
- a role directory matching a git ignore pattern (vendored/Galaxy roles) containing a valid molecule/default/molecule.yml, with the role itself untracked by git = molecule test from inside that role directory fails.
- removing the ignore pattern, or force-adding the role path to git (not a solution for a galaxy role, just for testing) : works again
$ pwd
~/git/my_project/ansible/roles/my_role
$ cat ../../.gitignore
roles/
$ molecule test
CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting.
ERROR 'molecule/default/molecule.yml' glob failed. Exiting.
```
Contributor guide
Research direction
Reproduce the failure with an ignored role containing molecule/default/molecule.yml, then trace get_configs through filter_ignored_scenarios and git check-ignore. Verify why the valid scenario is dropped and make the resulting behavior or error distinguish git-ignore exclusion from a missing glob; confirm the ignored-role reproduction no longer reports only “glob failed.”
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100