From 826889ed9a87740787e4af413e44285237e395bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 20 Jan 2020 09:37:20 +0100 Subject: [PATCH] Enhancement: Synchronize with ergebnis/php-library-template --- .dependabot/config.yml | 6 -- .github/settings.yml | 2 + .github/workflows/continuous-integration.yml | 22 +++-- .github/workflows/license.yml | 85 +++++++++++++++++++ .php_cs | 24 +++--- .php_cs.fixture | 4 +- LICENSE => LICENSE.md | 8 +- README.md | 11 ++- composer.json | 1 + composer.lock | 60 ++++++++++++- src/Exception/InvalidExcludeClassName.php | 4 +- src/Exception/NonExistentDirectory.php | 4 +- src/Exception/NonExistentExcludeClass.php | 4 +- src/Helper.php | 4 +- test/AutoReview/SrcCodeTest.php | 4 +- test/AutoReview/TestCodeTest.php | 4 +- .../Exception/InvalidExcludeClassNameTest.php | 4 +- .../Exception/NonExistentDirectoryTest.php | 4 +- .../Exception/NonExistentExcludeClassTest.php | 4 +- test/Unit/HelperTest.php | 4 +- 20 files changed, 206 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/license.yml rename LICENSE => LICENSE.md (77%) diff --git a/.dependabot/config.yml b/.dependabot/config.yml index 5f718083..0ee7e919 100644 --- a/.dependabot/config.yml +++ b/.dependabot/config.yml @@ -9,14 +9,8 @@ update_configs: commit_message: include_scope: true prefix: "Build" - default_assignees: - - "ergebnis-bot" - - "localheinz" default_labels: - "dependency" - default_reviewers: - - "ergebnis-bot" - - "localheinz" directory: "/" package_manager: "php:composer" update_schedule: "live" diff --git a/.github/settings.yml b/.github/settings.yml index 5362fca3..9bd17422 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -75,7 +75,9 @@ repository: allow_merge_commit: true allow_rebase_merge: false allow_squash_merge: false + archived: false default_branch: "master" + delete_branch_on_merge: true description: ":eyeglasses: Provides utilities for tests." has_downloads: true has_issues: true diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 639fbae0..77cb461a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -32,7 +32,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -97,7 +97,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -145,7 +145,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -205,7 +205,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -257,7 +257,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "xdebug" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -311,7 +311,7 @@ jobs: uses: "actions/checkout@v2.0.0" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.0" + uses: "shivammathur/setup-php@1.7.3" with: coverage: "xdebug" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -339,8 +339,8 @@ jobs: - name: "Run mutation tests with Xdebug and infection/infection" run: "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${{ env.MIN_COVERED_MSI }} --min-msi=${{ env.MIN_MSI }}" - approve: - name: "Approve" + review: + name: "Review" runs-on: "ubuntu-latest" @@ -358,3 +358,9 @@ jobs: if: "(github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') && github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'Build(deps-dev)')" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + + - name: "Approve pull requests created by @ergebnis-bot that update the license year" + uses: "hmarr/auto-approve-action@v2.0.0" + if: "github.actor == 'ergebnis-bot' && github.event_name == 'pull_request' && github.event.pull_request.title == 'Enhancement: Update license year'" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml new file mode 100644 index 00000000..5786ef26 --- /dev/null +++ b/.github/workflows/license.yml @@ -0,0 +1,85 @@ +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions + +name: "License" + +on: + schedule: + - cron: "1 0 1 1 *" + +env: + REQUIRED_PHP_EXTENSIONS: "mbstring" + +jobs: + license: + name: "License" + + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.1" + + dependencies: + - "locked" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2.0.0" + + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@1.7.3" + with: + coverage: "none" + extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" + php-version: "${{ matrix.php-version }}" + + - name: "Validate composer.json and composer.lock" + run: "composer validate --strict" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1.0.3" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" + + - name: "Install lowest dependencies with composer" + if: "matrix.dependencies == 'lowest'" + run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" + + - name: "Install locked dependencies with composer" + if: "matrix.dependencies == 'locked'" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Install highest dependencies with composer" + if: "matrix.dependencies == 'highest'" + run: "composer update --no-interaction --no-progress --no-suggest" + + - name: "Create cache directory for friendsofphp/php-cs-fixer" + run: "mkdir -p .build/php-cs-fixer" + + - name: "Cache cache directory for friendsofphp/php-cs-fixer" + uses: "actions/cache@v1.0.3" + with: + path: ".build/php-cs-fixer" + key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-" + + - name: "Run friendsofphp/php-cs-fixer" + run: "vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --verbose" + + - name: "Open pull request updating license year" + uses: "gr2m/create-or-update-pull-request-action@v1.2.9" + with: + author: "ergebnis-bot " + branch: "feature/license-year" + body: | + This PR + + * [x] updates the license year + commit-message: "Enhancement: Update license year" + path: "." + title: "Enhancement: Update license year" + env: + GITHUB_TOKEN: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" diff --git a/.php_cs b/.php_cs index f4d79893..d13cab9a 100644 --- a/.php_cs +++ b/.php_cs @@ -3,26 +3,30 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ +use Ergebnis\License; use Ergebnis\PhpCsFixer\Config; -$header = <<<'EOF' -Copyright (c) 2017 Andreas Möller +$license = License\Type\MIT::markdown( + __DIR__ . '/LICENSE.md', + License\Range::since( + License\Year::fromString('2017'), + new \DateTimeZone('UTC') + ), + License\Holder::fromString('Andreas Möller'), + License\Url::fromString('https://github.com/ergebnis/test-util') +); -For the full copyright and license information, please view -the LICENSE file that was distributed with this source code. +$license->save(); -@see https://github.com/ergebnis/test-util -EOF; - -$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header)); +$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($license->header())); $config->getFinder() ->ignoreDotFiles(false) diff --git a/.php_cs.fixture b/.php_cs.fixture index f64fa459..bb701d35 100644 --- a/.php_cs.fixture +++ b/.php_cs.fixture @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/LICENSE b/LICENSE.md similarity index 77% rename from LICENSE rename to LICENSE.md index cb45728f..84f08bf1 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,16 +1,16 @@ -The MIT License (MIT) +# The MIT License (MIT) -Copyright (c) 2017 Andreas Möller +Copyright (c) 2017-2020 Andreas Möller 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 +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 +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 24aa745d..0852be8d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,10 @@ [![Continuous Deployment](https://github.com/ergebnis/test-util/workflows/Continuous%20Deployment/badge.svg)](https://github.com/ergebnis/test-util/actions) [![Continuous Integration](https://github.com/ergebnis/test-util/workflows/Continuous%20Integration/badge.svg)](https://github.com/ergebnis/test-util/actions) + [![Code Coverage](https://codecov.io/gh/ergebnis/test-util/branch/master/graph/badge.svg)](https://codecov.io/gh/ergebnis/test-util) [![Type Coverage](https://shepherd.dev/github/ergebnis/test-util/coverage.svg)](https://shepherd.dev/github/ergebnis/test-util) + [![Latest Stable Version](https://poser.pugx.org/ergebnis/test-util/v/stable)](https://packagist.org/packages/ergebnis/test-util) [![Total Downloads](https://poser.pugx.org/ergebnis/test-util/downloads)](https://packagist.org/packages/ergebnis/test-util) @@ -73,8 +75,7 @@ For reference, see [`fzaninotto/faker`](https://github.com/fzaninotto/Faker). ### Additional Assertions -In addition to the assertions made available by extending from `PHPUnit\Framework\TestCase`, -the `Helper` trait provides the following assertions: +In addition to the assertions made available by extending from `PHPUnit\Framework\TestCase`, the `Helper` trait provides the following assertions: * `assertClassesAreAbstractOrFinal(string $directory, array $excludeClassNames = [])` * `assertClassesHaveTests(string $directory, string $namespace, string $testNamespace, array $excludeClassyNames = [])` @@ -106,10 +107,8 @@ Please have a look at [`CODE_OF_CONDUCT.md`](https://github.com/ergebnis/.github ## License -This package is licensed using the MIT License. +This package is licensed using the [MIT License](LICENSE.md). ## Credits -The [`SrcCodeTest`](test/AutoReview/SrcCodeTest.php) in this and other -projects I maintain or contribute to is inspired by [`ProjectCodeTest`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.0.0/tests/ProjectCodeTest.php) -in [`friends-of-php/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer), and was initially created by [Dariusz Rumiński](https://github.com/keradus). +The [`SrcCodeTest`](test/AutoReview/SrcCodeTest.php) in this and other projects I maintain or contribute to is inspired by [`ProjectCodeTest`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.0.0/tests/ProjectCodeTest.php) in [`friends-of-php/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer), and was initially created by [Dariusz Rumiński](https://github.com/keradus). diff --git a/composer.json b/composer.json index 99fff5c9..20d16dd1 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.2.2", + "ergebnis/license": "~0.1.0", "ergebnis/php-cs-fixer-config": "^2.0.0", "ergebnis/phpstan-rules": "~0.14.2", "infection/infection": "~0.13.6", diff --git a/composer.lock b/composer.lock index c67d8d11..5acfb4d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9672a1924a5a66f8c338b4344a5e7195", + "content-hash": "dea1998bdf698568a41d74e108af22d2", "packages": [ { "name": "ergebnis/classy", @@ -773,6 +773,64 @@ ], "time": "2019-12-19T14:42:54+00:00" }, + { + "name": "ergebnis/license", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/license.git", + "reference": "ca94bcaabcbd56e663899fc4510e9cfdd8c6329c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/license/zipball/ca94bcaabcbd56e663899fc4510e9cfdd8c6329c", + "reference": "ca94bcaabcbd56e663899fc4510e9cfdd8c6329c", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.1" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.2.2", + "ergebnis/php-cs-fixer-config": "~1.1.3", + "ergebnis/phpstan-rules": "~0.14.2", + "ergebnis/test-util": "~0.9.1", + "infection/infection": "~0.13.6", + "jangregor/phpstan-prophecy": "~0.6.0", + "phpstan/extension-installer": "^1.0.3", + "phpstan/phpstan": "~0.12.5", + "phpstan/phpstan-deprecation-rules": "~0.12.2", + "phpstan/phpstan-phpunit": "~0.12.6", + "phpstan/phpstan-strict-rules": "~0.12.1", + "phpunit/phpunit": "^7.5.20", + "psalm/plugin-phpunit": "~0.8.1", + "symfony/filesystem": "^4.4.0", + "vimeo/psalm": "^3.8.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Ergebnis\\License\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "description": "Provides an abstraction for a license.", + "homepage": "https://github.com/ergebnis/license", + "keywords": [ + "license" + ], + "time": "2020-01-19T13:40:34+00:00" + }, { "name": "ergebnis/php-cs-fixer-config", "version": "2.0.0", diff --git a/src/Exception/InvalidExcludeClassName.php b/src/Exception/InvalidExcludeClassName.php index e31ad700..34d21542 100644 --- a/src/Exception/InvalidExcludeClassName.php +++ b/src/Exception/InvalidExcludeClassName.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/src/Exception/NonExistentDirectory.php b/src/Exception/NonExistentDirectory.php index 5257786f..ae35cd86 100644 --- a/src/Exception/NonExistentDirectory.php +++ b/src/Exception/NonExistentDirectory.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/src/Exception/NonExistentExcludeClass.php b/src/Exception/NonExistentExcludeClass.php index 093af450..4452c0b7 100644 --- a/src/Exception/NonExistentExcludeClass.php +++ b/src/Exception/NonExistentExcludeClass.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/src/Helper.php b/src/Helper.php index a2dd7304..0559cc8b 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/AutoReview/SrcCodeTest.php b/test/AutoReview/SrcCodeTest.php index dd1a09d8..eed2521a 100644 --- a/test/AutoReview/SrcCodeTest.php +++ b/test/AutoReview/SrcCodeTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/AutoReview/TestCodeTest.php b/test/AutoReview/TestCodeTest.php index d8062ee5..9f1cffdb 100644 --- a/test/AutoReview/TestCodeTest.php +++ b/test/AutoReview/TestCodeTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/Unit/Exception/InvalidExcludeClassNameTest.php b/test/Unit/Exception/InvalidExcludeClassNameTest.php index ec60d2d4..2b1f53e7 100644 --- a/test/Unit/Exception/InvalidExcludeClassNameTest.php +++ b/test/Unit/Exception/InvalidExcludeClassNameTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/Unit/Exception/NonExistentDirectoryTest.php b/test/Unit/Exception/NonExistentDirectoryTest.php index 49826f71..51842caa 100644 --- a/test/Unit/Exception/NonExistentDirectoryTest.php +++ b/test/Unit/Exception/NonExistentDirectoryTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/Unit/Exception/NonExistentExcludeClassTest.php b/test/Unit/Exception/NonExistentExcludeClassTest.php index e46c2cfd..d3f6158e 100644 --- a/test/Unit/Exception/NonExistentExcludeClassTest.php +++ b/test/Unit/Exception/NonExistentExcludeClassTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */ diff --git a/test/Unit/HelperTest.php b/test/Unit/HelperTest.php index 10a185ee..37ea7dee 100644 --- a/test/Unit/HelperTest.php +++ b/test/Unit/HelperTest.php @@ -3,10 +3,10 @@ declare(strict_types=1); /** - * Copyright (c) 2017 Andreas Möller + * Copyright (c) 2017-2020 Andreas Möller * * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. + * the LICENSE.md file that was distributed with this source code. * * @see https://github.com/ergebnis/test-util */