Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add code-style workflow #152

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PHP-CS-Fixer

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

permissions:
contents: read

jobs:
code-style:

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

steps:
- uses: actions/checkout@v3

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

# install dependencies from composer.json
- name: Install test dependencies
env:
COMPOSER: composer.json
run: composer install --prefer-dist --no-progress

# run php-cs-fixer, fix code styles
- name: Run PHP CS Fixer
run: composer cs-fix

# commit and push fixed files
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ modules.xml
.DS_Store
vendor/composer/*
vendor/autoload.php
/composer.lock
/.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)
;
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
{
"require-dev": {
"redaxo/php-cs-fixer-config": "^2.0",
"friendsofphp/php-cs-fixer": "^3.14"
},
"require": {
"netcarver/textile": ">=3"
},
"replace": {
"psr/log": "*",
"psr/container": "*"
},
"scripts": {
"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"
}
}
}

Loading