Skip to content

Commit 50f20fb

Browse files
committed
ci: skip PHPCS step when a PR changes no PHP files
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.
1 parent 644fe87 commit 50f20fb

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

.github/workflows/wpcs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
echo "files=$FILES" >> $GITHUB_OUTPUT
3838
3939
- name: Detect coding standard violations
40+
if: steps.changes.outputs.files != ''
4041
run: |
4142
phpcs -i
4243
vendor/bin/phpcs ${{ steps.changes.outputs.files }} -q --report=checkstyle | cs2pr --graceful-warnings

0 commit comments

Comments
 (0)