From 01d8be4447d2f7ed0a193337dbc71ab32c917004 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 30 Jun 2023 09:39:08 +0200 Subject: [PATCH] Try to replace stickler with github actions --- .github/workflows/phpcbf.yml | 19 +++++++++++++++++++ dev/setup/git/hooks/pre-commit | 9 +++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/phpcbf.yml diff --git a/.github/workflows/phpcbf.yml b/.github/workflows/phpcbf.yml new file mode 100644 index 00000000000..5d0e262febd --- /dev/null +++ b/.github/workflows/phpcbf.yml @@ -0,0 +1,19 @@ +name: GitHub CI PHPCS and PHPCBF + +on: push + +jobs: + linter_name: + name: Run & fix PHP Code Sniffer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shalior/wordpress-phpcs-action@master + with: + github_token: ${{ secrets.github_token }} + use_default_configuration_file: false + phpcs_standard: 'dev/setup/codesniffer/ruleset.xml' + phpcs_args: '-n' # ignore warnings + #- uses: stefanzweifel/git-auto-commit-action@v4 # auto commit the fixes action for GitHub + # with: + # commit_message: Fix PHPCS errors diff --git a/dev/setup/git/hooks/pre-commit b/dev/setup/git/hooks/pre-commit index 55295b4d656..56a4d4876a6 100644 --- a/dev/setup/git/hooks/pre-commit +++ b/dev/setup/git/hooks/pre-commit @@ -45,12 +45,11 @@ if [ "$FILES" != "" ] then echo "Running PHPCS Code Sniffer..." - #~/vendor/bin/phpcs --version - #phpcs --standard=PSR2 --encoding=utf-8 -n -p $FILES # Check Dolibarr standard ${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES - # Check your own standard - #${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES + + # Check a common standard + #${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=PSR2 --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES result2=$? @@ -60,7 +59,9 @@ then if [ "x$AUTOFIX" != "x0" ] then ${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES + #${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES + echo "Found some errors in syntax rules. An automatic fix has been applied. Check it before commit." 1>&2; exit 1 else