Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from BrianHenryIE/phpcs
Add Php CodeSniffer and PHPStan Fix #84
- Loading branch information
Showing
8 changed files
with
1,379 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,51 @@ | ||
name: Run PHP CodeSniffer | ||
|
||
# Run PHPCBF to fix changes then annotate PHPCS | ||
# NB: Pull requests from forks do not have access to repository secrets so cannot commit changes. | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
php-codesniffer: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# Give the default GITHUB_TOKEN write permission to commit and push the | ||
# added or changed files to the repository. | ||
contents: write | ||
|
||
strategy: | ||
matrix: | ||
php: [ '8.0' ] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
tools: composer, cs2pr | ||
extensions: zip | ||
|
||
- name: Run composer install | ||
continue-on-error: true | ||
run: composer install | ||
|
||
- name: Run PHPCBF to fix what it can | ||
continue-on-error: true | ||
run: vendor/bin/phpcbf | ||
|
||
- name: Run PHPCS to add annotations to the code | ||
continue-on-error: true | ||
run: vendor/bin/phpcs -q -n --report=checkstyle | cs2pr | ||
|
||
- name: Commit PHPCBF changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "🤖 PHPCBF" | ||
|
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,62 @@ | ||
name: Run PHPStan | ||
|
||
# Run PHPStan to annotate the code | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
phpstan: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php: [ '8.0' ] | ||
|
||
permissions: | ||
# Give the default GITHUB_TOKEN write permission to commit and push the | ||
# added or changed files to the repository. | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
tools: composer, cs2pr | ||
extensions: zip | ||
|
||
- name: Run composer install | ||
continue-on-error: true | ||
run: composer install | ||
|
||
- name: Run PHPStan to add annotations to the code | ||
id: run-phpstan | ||
continue-on-error: true | ||
run: | | ||
vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G --no-progress --error-format=checkstyle | cs2pr | ||
- name: Get PhpStan level | ||
id: phpstan-level | ||
run: | | ||
LEVEL=$(cat phpstan.neon | grep level | sed "s/[^0-9]*//") | ||
echo "level=$LEVEL" >> "$GITHUB_OUTPUT" | ||
- name: Check success | ||
if: steps.run-phpstan.outcome == 'success' | ||
run: curl -o .github/phpstan.svg https://img.shields.io/badge/PHPStan-Level%20${{ steps.phpstan-level.outputs.level}}-2a5ea7.svg | ||
|
||
- name: Check failures | ||
if: steps.run-phpstan.outcome != 'success' | ||
run: curl -o .github/phpstan.svg https://img.shields.io/badge/PHPStan-Level%20${{ steps.phpstan-level.outputs.level}}❌-lightgrey.svg | ||
|
||
- name: Commit README badge changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
file_pattern: ".github/phpstan.svg" | ||
commit_message: "🤖 PhpStan" |
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
Oops, something went wrong.