Find a way to bypass phpcbf exit code

This commit is contained in:
alistair3149 2019-12-30 18:45:08 -05:00
parent 7627ab74f1
commit 27aba531c6
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C
2 changed files with 21 additions and 11 deletions

View file

@ -22,20 +22,15 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
# Bypass the phpcbf non-standard exit code
- name: Run composer fix
run: |
./bin/phpcbf.sh
composer fix
- name: Run Composer test
run: composer test
- name: Attempt to auto fix the issues
if: failure()
run: composer fix
# Use failure() because phpcbf always return a failure
- name: Re-run the auto fix and verify if the issues are resolved
if: failure()
run: |
composer fix
composer test
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

15
bin/phpcbf.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# Wrap phpcbf to turn 1 success exit code into 0 code.
# See https://github.com/squizlabs/PHP_CodeSniffer/issues/1818#issuecomment-354420927
root=$( dirname $0 )/..
$root/vendor/bin/phpcbf $@
exit=$?
# Exit code 1 is used to indicate that all fixable errors were fixed correctly.
if [[ $exit == 1 ]]; then
exit=0
fi
exit $exit