From 012e5e527cb8ec45ed9df029d4ebcc8a4dd65fd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Jun 2023 03:18:15 +0200 Subject: [PATCH] Add PHPCS check --- .github/workflows/php-cs.yml | 96 ++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/php-cs.yml diff --git a/.github/workflows/php-cs.yml b/.github/workflows/php-cs.yml new file mode 100644 index 00000000000..6cfb2d6cee6 --- /dev/null +++ b/.github/workflows/php-cs.yml @@ -0,0 +1,96 @@ +name: GitHub CI Coding Style + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password + ports: + - 32574:3306 + + steps: + # git clone dolibarr into GITHUB_WORKSPACE = /home/runner/work/dolibarr/dolibarr + - uses: actions/checkout@v3 + + - name: Version PHP + run: | + php -i | head - + + - name: Set vendor-dir + run: composer -n config -g vendor-dir htdocs/includes + + #- name: Install packages for PHP 7.1 + # run: | + # composer -n require phpunit/phpunit ^7.5 \ + # php-parallel-lint/php-parallel-lint ^1 \ + # php-parallel-lint/php-console-highlighter ^0 \ + # php-parallel-lint/php-var-dump-check ~0.4 \ + # squizlabs/php_codesniffer ^3 + + - name: Install packages for PHP 8.1 + run: | + composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ + php-parallel-lint/php-parallel-lint ^1.2 \ + php-parallel-lint/php-console-highlighter ^0 \ + php-parallel-lint/php-var-dump-check ~0.4 \ + squizlabs/php_codesniffer ^3 + + - name: Adding path of binaries tools installed by composer to the PATH + run: | + export PATH="$GITHUB_WORKSPACE/htdocs/includes/bin:$PATH" + echo $PATH + ls $GITHUB_WORKSPACE/htdocs/includes/bin + + - name: Version information + run: | + composer -V + # Check Parallel-lint version + echo "Parallel-lint version" + htdocs/includes/bin/parallel-lint -V + # Check PHP CodeSniffer version + echo "PHPCS version" + htdocs/includes/bin/phpcs --version | head - + htdocs/includes/bin/phpcs -i | head - + # Check PHP Vardump check version + echo "PHP Vardump check version" + htdocs/includes/bin/var-dump-check --version + # Check PHPUnit version + echo "PHPUnit version" + htdocs/includes/bin/phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check Database + echo "Database version" + mysql --version | head - + psql --version + + - name: lint + run: | + htdocs/includes/bin/parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ + --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ + --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --exclude htdocs/includes/webklex --blame . + + - name: phpcs + run: | + htdocs/includes/bin/phpcs -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 .; + + - name: var-dump-check + run: | + htdocs/includes/bin/var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php . +