Skip to content

Commit

Permalink
chore: use php cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
eaCe committed Feb 14, 2023
1 parent 06c2bed commit 0849b67
Show file tree
Hide file tree
Showing 10 changed files with 1,713 additions and 706 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/default.config.yml.github-action.diff

This file was deleted.

79 changes: 19 additions & 60 deletions .github/workflows/phpchecks.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,38 @@
name: PHP checks
name: PHP CS Fixer

on:
push:
branches: [ master ]
branches: [ master, main ]
pull_request:
branches: [ master ]
branches: [ master, main ]

permissions:
contents: read

jobs:
check:
code-style:

runs-on: ubuntu-latest
permissions:
contents: write # for Git to git apply

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: gd, intl, pdo_mysql
coverage: none # disable xdebug, pcov
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: gd, intl, pdo_mysql
coverage: none # disable xdebug, pcov

# credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/
- name: Download latest REDAXO release
run: |
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest)
REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
echo "Downloaded REDAXO $REDAXO_VERSION"
curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip
unzip -oq redaxo.zip -d redaxo_cms
rm redaxo.zip
# install dependencies from composer.json
- name: Install test dependencies
run: composer install --prefer-dist --no-progress

- name: Init database
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
git apply .github/workflows/default.config.yml.github-action.diff
- name: Run PHP CS Fixer
run: composer cs-dry

- name: Setup REDAXO
run: |
php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword [email protected] --ansi
# copy Addon files, ignore some directories...
# install phpmailer
# install the addon
# if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name
- name: Copy and install Addons
run: |
rsync -av --exclude='vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}'
redaxo_cms/redaxo/bin/console install:download 'yform' '4.0.2'
redaxo_cms/redaxo/bin/console package:install 'yform'
redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}'
- name: Install test dependencies
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
env:
COMPOSER: composer.json
run: composer install --prefer-dist --no-progress

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run lint
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
run: composer lint

- name: Run phpcs
working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
run: composer phpcs

# - name: Run phpunit
# working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}
# run: composer test
# - uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: Apply php-cs-fixer changes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
/vendor/
/.php-cs-fixer.cache
11 changes: 11 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;

return (new Redaxo\PhpCsFixerConfig\Config())
->setFinder($finder)
;
6 changes: 3 additions & 3 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use YFormExport\Export;

if (rex::isBackend() && rex_url::currentBackendPage() === 'index.php?page=yform/manager/data_edit') {
if (rex::isBackend() && 'index.php?page=yform/manager/data_edit' === rex_url::currentBackendPage()) {
/**
* register EP, attach export button
* register EP, attach export button.
*/
\rex_extension::register('YFORM_DATA_LIST_LINKS','YFormExport\ExtensionPoints::YFORM_DATA_LIST_LINKS');
\rex_extension::register('YFORM_DATA_LIST_LINKS', 'YFormExport\ExtensionPoints::YFORM_DATA_LIST_LINKS');

new Export();
}
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"license": "MIT",
"scripts": {
"lint": "phplint ./ --exclude=vendor --no-cache lib",
"phpcs": "phpcs --ignore=*/vendor/* --extensions=php --standard=phpcs.xml lib",
"phpcbf": "phpcbf --extensions=php --standard=phpcs.xml lib",
"cs-dry": "php-cs-fixer fix -v --ansi --dry-run --config=.php-cs-fixer.dist.php",
"cs-fix": "php-cs-fixer fix -v --ansi --config=.php-cs-fixer.dist.php",
"test": "phpunit --testdox"
},
"require-dev": {
"redaxo/php-cs-fixer-config": "^2.0",
"friendsofphp/php-cs-fixer": "^3.14",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
"overtrue/phplint": "^4.1"
"psr/log": "1.1.4",
"symfony/console": "5.4"
}
}
Loading

0 comments on commit 0849b67

Please sign in to comment.