Skip to content

Commit

Permalink
Merge pull request #5 from oleksandr-gribiennikov-paysera/EC-1064
Browse files Browse the repository at this point in the history
EC-1064
  • Loading branch information
oleksandr-gribiennikov-paysera authored Mar 11, 2024
2 parents 00f3c9b + c676574 commit e963e73
Show file tree
Hide file tree
Showing 30 changed files with 4,736 additions and 239 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check styling

on: [pull_request]

permissions:
contents: read

jobs:
style:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install PHP dependencies
run: composer update --no-cache --prefer-stable --no-interaction --no-progress

- name: Check styling
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection ./src ./tests
38 changes: 38 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PHPStan

on:
pull_request:
paths:
- '**.php'
- 'phpstan.neon.dist'

permissions:
contents: read

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install PHP dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: |
vendor/bin/phpstan --error-format=github analyse src/
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "PHPStan analysis failed with exit code $exit_code"
exit $exit_code
fi
36 changes: 36 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run tests

on: [pull_request]

permissions:
contents: read

jobs:
php-tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.3, 8.2, 8.1, 8.0, 7.4]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install PHP dependencies
run: composer update --${{ matrix.dependency-version }} --no-cache --no-interaction --no-progress

- name: Execute tests
run: composer run phpunit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
composer.lock
vendor/
coverage/
.phpunit.result.cache
.composer/
build/
.idea/
20 changes: 20 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

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

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@PHP82Migration' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => true,
])
->setFinder($finder)
;
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
"config": {
"preferred-install": "dist",
"prepend-autoloader": false,
"optimize-autoloader": true
"optimize-autoloader": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"scripts": {
"phpunit": "./vendor/phpunit/phpunit/phpunit tests"
},
"require-dev": {
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"friendsofphp/php-cs-fixer": "^3.38",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.3"
}
}
Loading

0 comments on commit e963e73

Please sign in to comment.