-
Notifications
You must be signed in to change notification settings - Fork 670
Add collection-aware scenario discovery and creation #4499
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
038fbec
to
e208207
Compare
2bffc52
to
ad39906
Compare
ad39906
to
bd636c7
Compare
- Provide both message and code arguments as required by constructor - Add proper exception chaining with 'from exc' - Document raised exception in docstring Fixes linting errors: B904, DOC501, DOC503, E1120, call-arg, arg-type
Tests cover all major functionality: - VCS root search (highest priority) - Collection extensions directory search - Home directory search (lowest priority) - Search priority ordering - File not found scenarios - Path filename extraction - Collection without extensions directory fallback Provides 100% coverage for the lookup_config_file function
Replace unused 'default=None' lambda arguments with '_' to satisfy ARG005 rule. No functional changes, only style fixes.
The find_vcs_root function expects a 'default' keyword argument, but test mocks were using lambda _ which doesn't accept it. Updated all mocks to use lambda default=None to match actual signature.
The default parameter is required for function signature compatibility but not used in test mocks, so suppress the unused argument warnings.
Qalthos
approved these changes
Aug 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enable Native Collection Support Through Auto-Detection
This PR enables Molecule to operate natively from Ansible collection roots by automatically detecting collections and encouraging proper scenario placement.
How It Works
When executed from a collection root (directory containing
galaxy.yml
with requiredname
andnamespace
fields), Molecule now:extensions/molecule/*/molecule.yml
molecule/
exists in the collection rootMOLECULE_GLOB
environment variableBehavior Details
Environment Override: If
MOLECULE_GLOB
is set, that pattern is used (highest priority)No Collection: If no valid
galaxy.yml
is found, use standardmolecule/*/molecule.yml
patternLegacy Collection: If collection detected AND
molecule/
directory exists in root:"Molecule scenarios should migrate to 'extensions/molecule'"
molecule/*/molecule.yml
pattern for backward compatibilityModern Collection: If collection detected but no
molecule/
in root:"Collection 'namespace.name' detected"
"Scenarios will be used from 'extensions/molecule'"
extensions/molecule/*/molecule.yml
Benefits
galaxy.yml
is presentmolecule/
in root continue workingextensions/molecule/
structureExample Usage
Files Changed
src/molecule/util.py
- Implements the auto-detection algorithmextensions/molecule/
layoutThis change makes Molecule collection-aware by default while maintaining full backward compatibility and providing clear guidance for modernization.