Respect .moodle-plugin-ci.yml config from subdirectories (#379)#380
Respect .moodle-plugin-ci.yml config from subdirectories (#379)#380marinaglancy wants to merge 1 commit intomoodlehq:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #380 +/- ##
============================================
+ Coverage 88.21% 88.37% +0.15%
- Complexity 767 780 +13
============================================
Files 77 77
Lines 2334 2365 +31
============================================
+ Hits 2059 2090 +31
Misses 275 275 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR extends plugin file discovery so that .moodle-plugin-ci.yml files found in subdirectories (e.g., subplugins) can contribute additional filter rules, enabling subcomponents to control their own CI exclusions.
Changes:
- Added support for discovering
.moodle-plugin-ci.ymlfiles below the plugin root and merging theirnotPaths/notNamesinto the Finder ignores. - Prefixed subdirectory
notPathsentries so they match correctly when the Finder is rooted at the main plugin directory. - Added PHPUnit tests covering subdirectory
notPaths, context-specific filters, and multiple subdirectory configs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Bridge/MoodlePlugin.php |
Adds recursive discovery/merge of subdirectory config filters into getFiles() results. |
tests/Bridge/MoodlePluginTest.php |
Adds tests validating merged ignore behavior from subdirectory configs (including context-specific sections). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Bridge/MoodlePlugin.php
Outdated
| $relativeDir = rtrim(substr( | ||
| dirname($file->getRealPath()), | ||
| strlen($this->directory) + 1 | ||
| ), '/'); | ||
|
|
||
| // Prefix notPaths with the relative subdirectory path. | ||
| if (!empty($ignores['notPaths'])) { | ||
| foreach ($ignores['notPaths'] as $notPath) { | ||
| $merged['notPaths'][] = $relativeDir . '/' . $notPath; |
There was a problem hiding this comment.
$relativeDir is derived by subtracting string lengths from real paths (dirname($file->getRealPath()) vs $this->directory). If $this->directory is not normalized (e.g., contains ".." like in src/Command/PHPDocCommand.php) or has different separators, substr() can produce an incorrect offset (or false), leading to wrong prefixes or even a TypeError in rtrim(). Consider using Symfony Finder’s $file->getRelativePath() (or Path::makeRelative(realpath(...), realpath(...))) to compute the config directory relative to the plugin root in a path-safe way.
| $relativeDir = rtrim(substr( | |
| dirname($file->getRealPath()), | |
| strlen($this->directory) + 1 | |
| ), '/'); | |
| // Prefix notPaths with the relative subdirectory path. | |
| if (!empty($ignores['notPaths'])) { | |
| foreach ($ignores['notPaths'] as $notPath) { | |
| $merged['notPaths'][] = $relativeDir . '/' . $notPath; | |
| $relativeDir = rtrim($file->getRelativePath(), '/'); | |
| // Prefix notPaths with the relative subdirectory path. | |
| if (!empty($ignores['notPaths'])) { | |
| $prefix = $relativeDir === '' ? '/' : $relativeDir . '/'; | |
| foreach ($ignores['notPaths'] as $notPath) { | |
| $merged['notPaths'][] = $prefix . $notPath; |
There was a problem hiding this comment.
agree, corrected
When running checks on a plugin, discover .moodle-plugin-ci.yml files in subdirectories (e.g., subplugins) and merge their notPaths/notNames filters, so subplugins can manage their own CI exclusions independently.
21c5694 to
f27ef1f
Compare
When running checks on a plugin, discover .moodle-plugin-ci.yml files in subdirectories (e.g., subplugins) and merge their notPaths/notNames filters, so subplugins can manage their own CI exclusions independently.
Fixes #379