-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
183 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Code Standards | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
phpcs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Required for phpcs-changed to compare with base branch | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.1' | ||
tools: composer:v2 | ||
|
||
- name: Install Dependencies | ||
run: composer install | ||
|
||
- name: Run PHPCS on changed files | ||
env: | ||
BASE_REF: ${{ github.base_ref }} | ||
run: | | ||
CHANGED_FILES=$(git diff --name-only --no-renames --diff-filter=d "origin/$BASE_REF" '*.php' || true) | ||
if [[ -n "$CHANGED_FILES" ]]; then | ||
vendor/bin/phpcs-changed \ | ||
--git-base="origin/$BASE_REF" \ | ||
--phpcs-path=vendor/bin/phpcs \ | ||
--standard=.phpcs.xml.dist \ | ||
$CHANGED_FILES | ||
else | ||
echo "No PHP files changed" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
. .husky/pre-commit-phpcbf.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
# Disable exit on error since we handle exit codes manually | ||
set +e | ||
|
||
# Get list of staged PHP files | ||
STAGED_PHP_FILES=$(git diff --cached --name-only --no-renames --diff-filter=d '*.php' ) | ||
|
||
# Exit if no PHP files are staged | ||
if [ -z "$STAGED_PHP_FILES" ]; then | ||
exit 0 | ||
fi | ||
|
||
echo "Running PHPCBF on staged files..." | ||
|
||
# First try to fix what we can with PHPCBF | ||
echo "$STAGED_PHP_FILES" | xargs vendor/bin/phpcbf | ||
|
||
# Check the return code | ||
PHPCBF_STATUS=$? | ||
|
||
# If files were fixed, add them back to staging | ||
if [ $PHPCBF_STATUS -ne 3 ]; then | ||
echo "$STAGED_PHP_FILES" | xargs git add | ||
|
||
if [ $PHPCBF_STATUS -eq 1 ] || [ $PHPCBF_STATUS -eq 2 ]; then | ||
echo "" | ||
echo "Some errors were fixed by PHPCBF, but not all. Continuing with phpcs-changed for remaining errors on lines changed by this PR." | ||
fi | ||
fi | ||
|
||
# Now run phpcs-changed to check only modified lines | ||
echo "Checking modified lines with phpcs-changed..." | ||
|
||
vendor/bin/phpcs-changed\ | ||
--git-staged\ | ||
--phpcs-path=vendor/bin/phpcs\ | ||
--standard=.phpcs.xml.dist\ | ||
$STAGED_PHP_FILES | ||
|
||
PHPCS_STATUS=$? | ||
|
||
if [ $PHPCS_STATUS -ne 0 ]; then | ||
echo "⛔️ Found coding standards violations in changed lines. Please fix them before committing." | ||
exit 1 | ||
fi | ||
|
||
echo "✅ All coding standards checks passed!" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Reporting Security Issues | ||
|
||
The WordPress community take security bugs seriously. We appreciate your efforts to disclose your findings responsibly and will make every effort to acknowledge your contributions. | ||
|
||
To report a security issue, please visit the [WordPress HackerOne](https://hackerone.com/wordpress) program. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters