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

PHP CS Fixer #193

Merged
merged 6 commits into from
Jan 9, 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
55 changes: 55 additions & 0 deletions .github/workflows/php-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PHP coding standards

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

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Setup PHP8.1
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress

- name: Composer dump-autoload to load all files
run: composer dump-autoload

- name: Run codefixer
run: composer run-script php-cs-fixer

- name: Check if code are already generated
uses: tj-actions/verify-changed-files@v8.8
id: verify-changed-files
with:
files: |
src
tests

- name: Run step only when files change.
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
core.setFailed('Inconsistent coding standards. Please run `composer run-script php-cs-fixer` locally and commit style.')
10 changes: 10 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([__DIR__ . '/src', __DIR__ . '/tests']);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Retrieve, create and delete SongArrangement comments ([PR187](https://github.com/5pm-HDH/churchtools-api/pull/187))
- Get GroupTypes ([PR188](https://github.com/5pm-HDH/churchtools-api/pull/188))
- PHP coding standard ([PR193](https://github.com/5pm-HDH/churchtools-api/pull/193))

### Changed

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"require-dev": {
"phpunit/phpunit": "9.5.5",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"friendsofphp/php-cs-fixer": "^3.46"
},
"license": "MIT",
"authors": [
Expand All @@ -37,6 +38,7 @@
"test-coverage-w": "vendor\\bin\\phpunit.bat --coverage-html .phpunit.cache/coverage-report",
"phpstan": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G",
"phpstan-w": "vendor\\bin\\phpstan.bat analyse -c phpstan.neon --memory-limit 1G",
"php-cs-fixer": "vendor/bin/php-cs-fixer fix",
"docs-generator": "php docs/src/DocGenerator.php"
}
}
Loading
Loading