Skip to content

Commit

Permalink
Update development tools
Browse files Browse the repository at this point in the history
  • Loading branch information
denisyukphp committed Mar 30, 2023
1 parent 4610cbf commit 3d2070b
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 18 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* text=auto

/.editorconfig export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/README.md export-ignore
/build/ export-ignore
/composer.lock export-ignore
/docs/ export-ignore
/phpunit.xml.dist export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/tests/ export-ignore
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: 'CI'

on:
push:
paths-ignore:
- 'build/**'
- 'docs/**'
- '.editorconfig'
- '.gitattributes'
- 'LICENSE'
- 'README.md'
pull_request:
paths-ignore:
- 'build/**'
- 'docs/**'
- '.editorconfig'
- '.gitattributes'
- 'LICENSE'
- 'README.md'

jobs:
parallel-lint:
name: 'ParallelLint'
runs-on: 'ubuntu-latest'

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

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

- name: Run ParallelLint
run: composer parallel-lint -- --no-progress --ignore-fails

psalm:
name: 'Psalm'
runs-on: 'ubuntu-latest'

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

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

- name: Run Psalm
run: composer psalm -- --no-progress --no-cache --output-format=github

php-cs-fixer:
name: 'PHPCsFixer'
runs-on: 'ubuntu-latest'

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

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

- name: Run PHPCsFixer
run: composer php-cs-fixer:diff -- --no-interaction --using-cache=no

phpunit:
name: 'PHPUnit'
needs: ['parallel-lint', 'psalm', 'php-cs-fixer']
runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
operating-system:
- 'ubuntu-latest'
- 'windows-latest'
php-version:
- '8.1'
composer-dependency:
- 'lowest'
- 'highest'

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.composer-dependency }}

- name: Run PHPUnit
run: composer phpunit -- --no-interaction --do-not-cache-result
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea/
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
/.idea/
/.php-cs-fixer.php
/composer.lock
/phpunit.xml
/vendor/
21 changes: 21 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

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

return (new PhpCsFixer\Config())
->setUsingCache(true)
->setCacheFile(__DIR__.'/build/cache/php-cs-fixer.cache')
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
])
->setFinder($finder)
;
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2022 Orangesoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BackOff

[![Build Status](https://img.shields.io/github/workflow/status/Orangesoft-Development/backoff/build/main?style=plastic)](https://github.com/Orangesoft-Development/backoff/actions/workflows/continuous-integration.yml)
[![Build Status](https://img.shields.io/github/actions/workflow/status/denisyukphp/backoff/ci.yml?branch=main&style=plastic)](https://github.com/denisyukphp/backoff/actions/workflows/ci.yml)
[![Latest Stable Version](https://img.shields.io/packagist/v/orangesoft/backoff?style=plastic)](https://packagist.org/packages/orangesoft/backoff)
[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/orangesoft/backoff?style=plastic&color=8892BF)](https://packagist.org/packages/orangesoft/backoff)
[![Total Downloads](https://img.shields.io/packagist/dt/orangesoft/backoff?style=plastic)](https://packagist.org/packages/orangesoft/backoff)
Expand Down
2 changes: 2 additions & 0 deletions build/cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions build/logs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
47 changes: 38 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"name": "orangesoft/backoff",
"description": "Back-off algorithm implementation",
"keywords": ["backoff", "exponential", "linear", "constant", "decorrelation", "jitter", "sleeper", "retry"],
"keywords": [
"backoff",
"exponential",
"linear",
"constant",
"decorrelation",
"jitter",
"sleeper",
"retry"
],
"license": "MIT",
"authors": [
{
Expand All @@ -11,27 +20,47 @@
"role": "Developer"
}
],
"config": {
"sort-packages": true
},
"require": {
"php": "^8.1"
},
"require-dev": {
"phpunit/php-timer": "^5.0",
"phpunit/phpunit": "^9.5"
"friendsofphp/php-cs-fixer": "^3.10",
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpbench/phpbench": "^1.2",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.17.0",
"vimeo/psalm": "^4.26"
},
"autoload": {
"psr-4": {
"Orangesoft\\BackOff\\": "src/"
"Orangesoft\\BackOff\\": "./src/"
}
},
"autoload-dev": {
"psr-4": {
"Orangesoft\\BackOff\\Tests\\": "tests/"
"Orangesoft\\BackOff\\Tests\\": "./tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit --colors=always"
},
"config": {
"sort-packages": true
"phpunit": "./vendor/bin/phpunit --verbose --colors=always --no-coverage",
"phpunit-coverage": "./vendor/bin/phpunit --verbose --colors=always --coverage-text",
"phpunit-coverage-html": "./vendor/bin/phpunit --verbose --colors=always --coverage-html ./build/logs/phpunit-coverage/",
"parallel-lint": "./vendor/bin/parallel-lint --colors ./src/ ./tests/",
"php-cs-fixer:fix": "./vendor/bin/php-cs-fixer fix --verbose --ansi --show-progress=dots",
"php-cs-fixer:diff": "./vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --diff",
"psalm": "./vendor/bin/psalm --show-info=true",
"psalm:set-baseline": "@psalm --set-baseline=./psalm-baseline.xml",
"psalm:update-baseline": "@psalm --update-baseline",
"psalm:ignore-baseline": "@psalm --ignore-baseline",
"test": [
"@parallel-lint",
"@psalm",
"@php-cs-fixer:diff",
"@phpunit"
]
}
}
19 changes: 16 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="./vendor/autoload.php">
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
cacheResultFile="./build/cache/phpunit.cache"
>
<testsuites>
<testsuite name="back-off test suite">
<testsuite name="backoff">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<coverage
processUncoveredFiles="true"
cacheDirectory="./build/cache/phpunit-coverage/"
>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
</phpunit>
50 changes: 50 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="src/Generator/Generator.php">
<ArgumentTypeCoercion occurrences="1">
<code>$values</code>
</ArgumentTypeCoercion>
</file>
<file src="src/Jitter/EqualJitter.php">
<PossiblyInvalidArgument occurrences="1">
<code>$nanoseconds / 2</code>
</PossiblyInvalidArgument>
</file>
<file src="src/Retry/Retry.php">
<InvalidReturnType occurrences="1">
<code>mixed</code>
</InvalidReturnType>
<UnusedVariable occurrences="1">
<code>$attempt</code>
</UnusedVariable>
</file>
<file src="src/Sleeper/Sleeper.php">
<ArgumentTypeCoercion occurrences="2">
<code>$nanoseconds</code>
<code>$seconds</code>
</ArgumentTypeCoercion>
<UnusedFunctionCall occurrences="1">
<code>time_nanosleep</code>
</UnusedFunctionCall>
</file>
<file src="tests/Strategy/ConstantStrategyTest.php">
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
</file>
<file src="tests/Strategy/DecorrelatedStrategyTest.php">
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
</file>
<file src="tests/Strategy/ExponentialStrategyTest.php">
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
</file>
<file src="tests/Strategy/LinearStrategyTest.php">
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
</file>
</files>
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd"
cacheDirectory="./build/cache/psalm/"
errorBaseline="./psalm-baseline.xml"
>
<projectFiles>
<directory name="./src/"/>
<directory name="./tests/"/>
<ignoreFiles>
<directory name="./vendor/"/>
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>

0 comments on commit 3d2070b

Please sign in to comment.