Skip to content
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
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

on:
push:
branches: [main, "feat/*", "fix/*"]
pull_request:
branches: [main]

jobs:
tests:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, hash
coverage: xdebug
tools: composer:v2

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

- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Run test suite
run: vendor/bin/phpunit --testdox

static-analysis:
name: Static analysis (PHPStan)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: PHPStan
run: vendor/bin/phpstan analyse --no-progress

code-style:
name: Code style (PHP-CS-Fixer)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer:v2

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: PHP-CS-Fixer (dry-run)
run: vendor/bin/php-cs-fixer fix --dry-run --diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/.vscode/
/vendor/
/composer.lock
/build/
/.phpunit.cache/
/.php-cs-fixer.cache
35 changes: 35 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src', __DIR__ . '/tests'])
->name('*.php');

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@PHP80Migration' => true,
'declare_strict_types' => true,
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'function', 'const'],
],
'single_quote' => true,
'trailing_comma_in_multiline' => true,
'no_trailing_whitespace' => true,
'no_whitespace_in_blank_line' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'method_chaining_indentation' => true,
'native_function_invocation' => false,
'phpdoc_align' => ['align' => 'vertical'],
'phpdoc_separation' => true,
'phpdoc_trim' => true,
'no_superfluous_phpdoc_tags' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');
Loading
Loading