Minor: Add GitHub action for PHP-CS-Fixer

pull/4085/head
Angel Fernando Quiroz Campos 4 years ago
parent 36e5edae21
commit fae6006792
  1. 1
      .github/workflows/php.yml
  2. 51
      .github/workflows/php_cs.yml
  3. 7
      .php-cs-fixer.dist.php
  4. 3
      .php-cs-fixer.php
  5. 3
      .php_cs

@ -46,6 +46,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, gd, json, soap, zip, bcmath extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, gd, json, soap, zip, bcmath
ini-values: post_max_size=256M, max_execution_time=600, memory_limit=4096M ini-values: post_max_size=256M, max_execution_time=600, memory_limit=4096M
tools: composer:v2
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache-v1 id: composer-cache-v1

@ -0,0 +1,51 @@
name: PHP-CS-Fixer
on: [ push, pull_request ]
jobs:
composer_install:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-versions: ['7.1']
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, gd, json, soap, zip, bcmath
ini-values: post_max_size=256M, max_execution_time=600, memory_limit=4096M
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer downloads
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Run composer install
run: composer install --prefer-dist --no-progress
- name: Download PHP-CS-Fixer
run: |
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.19.3/php-cs-fixer.phar
- name: Run PHP-CS-Fixer
run: |
IFS='
'
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "HEAD~..HEAD")
if ! echo "${CHANGED_FILES}" | grep -qE "^(\\.php-cs-fixer(\\.dist)?\\.php|composer\\.lock)$"; then EXTRA_ARGS=$(printf -- '--path-mode=intersection\n--\n%s' "${CHANGED_FILES}"); else EXTRA_ARGS=''; fi
php ./php-cs-fixer.phar fix --config=.php-cs-fixer.php -v --dry-run --using-cache=no --diff ${EXTRA_ARGS}

@ -12,7 +12,7 @@ $rules = [
'header' => $header, 'header' => $header,
],*/ ],*/
'blank_line_after_opening_tag' => false, 'blank_line_after_opening_tag' => false,
'no_extra_consecutive_blank_lines' => true, 'no_extra_blank_lines' => true,
'multiline_comment_opening_closing' => true, 'multiline_comment_opening_closing' => true,
'yoda_style' => false, 'yoda_style' => false,
'phpdoc_to_comment' => false, 'phpdoc_to_comment' => false,
@ -38,6 +38,7 @@ $rules = [
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()
->exclude('app/') ->exclude('app/')
->exclude('node_modules/')
->exclude('assets') ->exclude('assets')
->exclude('bin') ->exclude('bin')
->exclude('documentation') ->exclude('documentation')
@ -89,8 +90,8 @@ $finder = PhpCsFixer\Finder::create()
->in(__DIR__) ->in(__DIR__)
; ;
return PhpCsFixer\Config::create() $config = new PhpCsFixer\Config();
->setRules( return $config->setRules(
$rules $rules
) )
->setFinder($finder); ->setFinder($finder);

@ -0,0 +1,3 @@
<?php
return require_once __DIR__.'/.php-cs-fixer.dist.php';

@ -1,3 +0,0 @@
<?php
return require_once __DIR__.'/.php_cs.dist';
Loading…
Cancel
Save