fix(ci): graceful PHPCS skip when phpcs.xml not present
Add guard to phpcbf and phpcs strict steps: if neither phpcs.xml, phpcs.xml.dist, nor .phpcs.xml.dist exists in the repo root, both steps exit 0 with an info message. This prevents startup_failure on the self-test (peptide-e2e is a Node repo with no PHPCS config) and provides clean feedback for repos not yet configured for PHPCS. Real PHP repos all have a phpcs.xml (prautoblogger, theme, pr-core, etc.) so the guard is transparent for them. Agent-Session: claude/reusable-ci-20260616
This commit is contained in:
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@@ -175,6 +175,10 @@ jobs:
|
|||||||
# trigger a new CI run — GitHub prevents loops on bot commits.
|
# trigger a new CI run — GitHub prevents loops on bot commits.
|
||||||
if: ${{ github.event_name == 'pull_request' && inputs.phpcs_autofix }}
|
if: ${{ github.event_name == 'pull_request' && inputs.phpcs_autofix }}
|
||||||
run: |
|
run: |
|
||||||
|
if [ ! -f phpcs.xml ] && [ ! -f phpcs.xml.dist ] && [ ! -f .phpcs.xml.dist ]; then
|
||||||
|
echo "No phpcs.xml — phpcbf skipped."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
phpcbf --standard=phpcs.xml \
|
phpcbf --standard=phpcs.xml \
|
||||||
--extensions=php \
|
--extensions=php \
|
||||||
--ignore=vendor/*,tests/*,node_modules/* \
|
--ignore=vendor/*,tests/*,node_modules/* \
|
||||||
@@ -191,7 +195,13 @@ jobs:
|
|||||||
# Runs on all events (push AND pull_request). After phpcbf has committed
|
# Runs on all events (push AND pull_request). After phpcbf has committed
|
||||||
# any auto-fixable issues on PRs, only non-auto-fixable violations land
|
# any auto-fixable issues on PRs, only non-auto-fixable violations land
|
||||||
# here. On push events phpcbf is skipped but phpcs is still strict.
|
# here. On push events phpcbf is skipped but phpcs is still strict.
|
||||||
|
# Guard: skip gracefully if no phpcs.xml exists (repo not yet configured).
|
||||||
run: |
|
run: |
|
||||||
|
if [ ! -f phpcs.xml ] && [ ! -f phpcs.xml.dist ] && [ ! -f .phpcs.xml.dist ]; then
|
||||||
|
echo "No phpcs.xml / phpcs.xml.dist / .phpcs.xml.dist found — PHPCS skipped."
|
||||||
|
echo "Add a phpcs.xml to enable coding standards enforcement."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
phpcs --standard=phpcs.xml \
|
phpcs --standard=phpcs.xml \
|
||||||
--extensions=php \
|
--extensions=php \
|
||||||
--ignore=vendor/*,tests/*,node_modules/* \
|
--ignore=vendor/*,tests/*,node_modules/* \
|
||||||
|
|||||||
Reference in New Issue
Block a user