ci: skip PHPCS step when a PR changes no PHP files#19
Conversation
The PHPCS inspection builds a list of changed `.php` files and passes them to `phpcs`. When a PR touches no PHP files (e.g. a readme-only change), that list is empty and `phpcs` runs with no file arguments, falling back to the `<file>.</file>` directive in `phpcs.xml` and scanning the entire repository -- failing on pre-existing violations unrelated to the PR. Guard the step with `if: steps.changes.outputs.files != ''` so it is skipped when there are no PHP files to inspect.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PHPCS workflow step now includes a conditional check to execute only when changed PHP files are detected, avoiding unnecessary tool invocation when the PR modifies only non-PHP assets or documentation. ChangesConditional PHPCS Execution
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The
Inspectionsworkflow fails on PRs that change no PHP files (e.g. PR #18, which only editsreadme.txt).The
Detect coding standard violationsstep builds a list of changed.phpfiles and passes it tophpcs:When the PR touches no PHP files,
steps.changes.outputs.filesis empty, sophpcsruns with no file arguments. It then falls back to the<file>.</file>directive inphpcs.xmland scans the entire repository, failing on pre-existing violations that have nothing to do with the PR.Fix
Guard the step with
if: steps.changes.outputs.files != ''so it is skipped when there are no PHP files to inspect.Impact
Unblocks #18.
Summary by CodeRabbit