-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add php codesniffer with wordpress standards (#39)
- Loading branch information
Showing
3,729 changed files
with
324,555 additions
and
70,120 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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,50 @@ | ||
name: PHP CodeSniffer | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**.php' | ||
push: | ||
paths: | ||
- '**.php' | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
phpcs: | ||
name: PHP CodeSniffer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
tools: composer:v2 | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Run PHP CodeSniffer | ||
run: vendor/bin/phpcs -p --standard=phpcs.xml --report=full --runtime-set ignore_warnings_on_exit 1 > phpcs-results.txt | ||
|
||
- name: Post PHPCS results as PR comment | ||
if: github.event_name == 'pull_request' | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const fs = require('fs'); | ||
const phpcsOutput = fs.readFileSync('phpcs-results.txt', 'utf8'); | ||
const summary = phpcsOutput.split('\n').slice(0, 10).join('\n'); // Get first 10 lines for summary | ||
const fullReport = '## PHP CodeSniffer Results\n\n<details><summary>Click to expand full report</summary>\n\n```\n' + phpcsOutput + '\n```\n</details>'; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '## PHP CodeSniffer Summary\n\n```\n' + summary + '\n```\n\n' + fullReport | ||
}); |
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
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
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
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 |
---|---|---|
@@ -1,10 +1,20 @@ | ||
{ | ||
"require": { | ||
"phpseclib/phpseclib": "~3.0", | ||
"woocommerce/woocommerce": "^5.9.1", | ||
"php": "~7.4" | ||
"phpseclib/phpseclib": "~3.0" | ||
|
||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5" | ||
"phpunit/phpunit": "^9.5", | ||
"squizlabs/php_codesniffer": "^3.6", | ||
"wp-coding-standards/wpcs": "^3.1", | ||
"woocommerce/woocommerce": "^5.9.1", | ||
"php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"composer/installers": true, | ||
"automattic/jetpack-autoloader": true, | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.