-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Coding Standard. * Add PHPCS cache directory. * Coding Standards: Apply PHPCBF to codebase. * Coding Standards: Add GitHub workflow. --------- Signed-off-by: Alex Sirota <[email protected]> Co-authored-by: Alex Sirota <[email protected]>
- Loading branch information
Showing
14 changed files
with
648 additions
and
99 deletions.
There are no files selected for viewing
Empty file.
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,85 @@ | ||
name: PHP coding standards | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
# Runs the PHP coding standards checks. | ||
# | ||
# Violations are reported inline with annotations. | ||
# | ||
# Performs the following steps: | ||
# - Checks out the repository. | ||
# - Sets up PHP. | ||
# - Configures caching for PHPCS scans. | ||
# - Installs Composer dependencies. | ||
# - Make Composer packages available globally. | ||
# - Runs PHPCS on the full codebase (warnings excluded). | ||
# - Generate a report for displaying issues as pull request annotations. | ||
# - Runs PHPCS on the `tests` directory without (warnings included). | ||
# - Generate a report for displaying `test` directory issues as pull request annotations. | ||
# - Ensures version-controlled files are not modified or deleted. | ||
phpcs: | ||
name: Run coding standards checks | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 | ||
with: | ||
coverage: none | ||
tools: cs2pr | ||
|
||
# This date is used to ensure that the PHPCS cache is cleared at least once every week. | ||
# http://man7.org/linux/man-pages/man1/date.1.html | ||
- name: "Get last Monday's date" | ||
id: get-date | ||
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache PHPCS scan cache | ||
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1 | ||
with: | ||
path: | | ||
.cache/phpcs-src.json | ||
.cache/phpcs-tests.json | ||
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-php-${{ inputs.php-version }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }} | ||
|
||
- name: Install Composer dependencies | ||
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 | ||
|
||
- name: Make Composer packages available globally | ||
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH | ||
|
||
- name: Run PHPCS on all files | ||
id: phpcs-files | ||
if: ${{ ! inputs.old-branch }} | ||
run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml | ||
|
||
- name: Show PHPCS results in PR | ||
if: ${{ always() && steps.phpcs-files.outcome == 'failure' }} | ||
run: cs2pr ./.cache/phpcs-report.xml | ||
|
||
- name: Check test suite files for warnings | ||
id: phpcs-tests | ||
run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml | ||
|
||
- name: Show test suite scan results in PR | ||
if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }} | ||
run: cs2pr ./.cache/phpcs-tests-report.xml | ||
|
||
- name: Ensure version-controlled files are not modified during the tests | ||
run: git diff --exit-code |
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 |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
/tests/cache | ||
/tests/coverage | ||
.DS_Store | ||
|
||
# Track placeholders so that empty directories stay in the repo. | ||
!.gitkeep |
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,20 +1,31 @@ | ||
{ | ||
"name": "aspirepress/aspire-update", | ||
"description": "Update plugins and themes for WordPress.", | ||
"type": "wordpress-plugin", | ||
"license": "GPL-3.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "AspirePress" | ||
|
||
"name": "aspirepress/aspire-update", | ||
"description": "Update plugins and themes for WordPress.", | ||
"type": "wordpress-plugin", | ||
"license": "GPL-3.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "AspirePress" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.4.0" | ||
}, | ||
"require-dev": { | ||
"squizlabs/php_codesniffer": "3.10.3", | ||
"wp-coding-standards/wpcs": "~3.1.0", | ||
"yoast/phpunit-polyfills": "^1.1.0" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.4.0" | ||
}, | ||
"require-dev": { | ||
"yoast/phpunit-polyfills": "^1.1.0" | ||
}, | ||
"scripts": { | ||
"test": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit" ] | ||
} | ||
"scripts": { | ||
"format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source", | ||
"lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary, source", | ||
"test": [ "Composer\\Config::disableProcessTimeout", "@php ./vendor/phpunit/phpunit/phpunit" ] | ||
} | ||
|
||
} |
Oops, something went wrong.