From 3d2070bd309b773c2925d277305a66065d12436c Mon Sep 17 00:00:00 2001 From: Aleksandr Denisyuk Date: Thu, 30 Mar 2023 22:28:40 +0300 Subject: [PATCH] Update development tools --- .editorconfig | 15 +++++ .gitattributes | 15 +++++ .github/workflows/ci.yml | 115 +++++++++++++++++++++++++++++++++++++++ .gitignore | 10 ++-- .php-cs-fixer.dist.php | 21 +++++++ LICENSE | 19 +++++++ README.md | 2 +- build/cache/.gitignore | 2 + build/logs/.gitignore | 2 + composer.json | 47 +++++++++++++--- phpunit.xml.dist | 19 ++++++- psalm-baseline.xml | 50 +++++++++++++++++ psalm.xml | 20 +++++++ 13 files changed, 319 insertions(+), 18 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 .php-cs-fixer.dist.php create mode 100644 LICENSE create mode 100644 build/cache/.gitignore create mode 100644 build/logs/.gitignore create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dd53e98 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..03576fe --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1f7388a --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index 58694f3..594155b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -.idea/ -vendor/ -composer.lock -phpunit.xml -.phpunit.result.cache +/.idea/ +/.php-cs-fixer.php +/composer.lock +/phpunit.xml +/vendor/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..54072da --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,21 @@ +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) +; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..880306b --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 3a524a3..db4f4ea 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/build/cache/.gitignore b/build/cache/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/build/logs/.gitignore b/build/logs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/composer.json b/composer.json index 003ddfc..5b5d8e5 100644 --- a/composer.json +++ b/composer.json @@ -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": [ { @@ -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" + ] } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9f4ab7e..f792463 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,21 @@ - - + + - + ./tests/ + + + ./src/ + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..ff66f82 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,50 @@ + + + + + $values + + + + + $nanoseconds / 2 + + + + + mixed + + + $attempt + + + + + $nanoseconds + $seconds + + + time_nanosleep + + + + + array + + + + + array + + + + + array + + + + + array + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..d194b73 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + +