Skip to content

Comments

Respect .moodle-plugin-ci.yml config from subdirectories (#379)#380

Open
marinaglancy wants to merge 1 commit intomoodlehq:mainfrom
marinaglancy:notpaths_subplugins
Open

Respect .moodle-plugin-ci.yml config from subdirectories (#379)#380
marinaglancy wants to merge 1 commit intomoodlehq:mainfrom
marinaglancy:notpaths_subplugins

Conversation

@marinaglancy
Copy link
Contributor

@marinaglancy marinaglancy commented Feb 10, 2026

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

Copilot AI review requested due to automatic review settings February 10, 2026 12:03
@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.37%. Comparing base (198ee6c) to head (f27ef1f).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml files below the plugin root and merging their notPaths/notNames into the Finder ignores.
  • Prefixed subdirectory notPaths entries 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.

Comment on lines 300 to 308
$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;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$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.

Suggested change
$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;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.moodle-plugin-ci.yml from subplugins is not read when running checks on the parent plugin

1 participant