diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 54332f175e..f978485a15 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -46,6 +46,7 @@ jobs: 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 + tools: composer:v2 - name: Get composer cache directory id: composer-cache-v1 diff --git a/.github/workflows/php_cs.yml b/.github/workflows/php_cs.yml new file mode 100644 index 0000000000..32762d36c4 --- /dev/null +++ b/.github/workflows/php_cs.yml @@ -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} diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 94% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index 4cbadb31f2..cb3cb76548 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -12,7 +12,7 @@ $rules = [ 'header' => $header, ],*/ 'blank_line_after_opening_tag' => false, - 'no_extra_consecutive_blank_lines' => true, + 'no_extra_blank_lines' => true, 'multiline_comment_opening_closing' => true, 'yoda_style' => false, 'phpdoc_to_comment' => false, @@ -38,6 +38,7 @@ $rules = [ $finder = PhpCsFixer\Finder::create() ->exclude('app/') + ->exclude('node_modules/') ->exclude('assets') ->exclude('bin') ->exclude('documentation') @@ -89,8 +90,8 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ; -return PhpCsFixer\Config::create() - ->setRules( +$config = new PhpCsFixer\Config(); +return $config->setRules( $rules ) ->setFinder($finder); \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000000..4404a4e35c --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,3 @@ +