From d80aa549f13e4cd931724a8196d6b1e8bf34b5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 15 Jun 2020 00:12:25 +0200 Subject: [PATCH] Enhancement: Synchronize with ergebnis/php-library-template --- .dependabot/config.yaml | 14 ----------- .gitattributes | 1 - .github/CONTRIBUTING.md | 21 +++++++++------- .github/dependabot.yml | 26 +++++++++++++++++++ .github/settings.yml | 20 +++++++-------- .github/workflows/integrate.yaml | 41 ++++++++++++------------------ .github/workflows/prune.yaml | 2 +- .github/workflows/renew.yaml | 4 +-- .github/workflows/triage.yaml | 43 ++++++++++++++++++++++++++++++++ .php_cs | 5 ++-- Makefile | 7 +++--- README.md | 6 ++++- infection.json | 14 +++++------ 13 files changed, 127 insertions(+), 77 deletions(-) delete mode 100644 .dependabot/config.yaml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/triage.yaml diff --git a/.dependabot/config.yaml b/.dependabot/config.yaml deleted file mode 100644 index 7a12de73..00000000 --- a/.dependabot/config.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# https://dependabot.com/docs/config-file/ - -version: 1 - -update_configs: - - commit_message: - include_scope: true - prefix: "Build" - default_labels: - - "dependency" - directory: "/" - package_manager: "php:composer" - update_schedule: "live" - version_requirement_updates: "increase_versions" diff --git a/.gitattributes b/.gitattributes index 36d16720..d9c29c46 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -/.dependabot/ export-ignore /.github/ export-ignore /test/ export-ignore /.editorconfig export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3197d614..d0d33d0b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,14 +8,17 @@ For details, take a look at the following workflow configuration files: - [`workflows/prune.yaml`](workflows/prune.yaml) - [`workflows/release.yaml`](workflows/release.yaml) - [`workflows/renew.yaml`](workflows/renew.yaml) +- [`workflows/triage.yaml`](workflows/triage.yaml) ## Coding Standards +We are using [`ergebnis/composer-normalize`](https://github.com/ergebnis/composer-normalize) to normalize `composer.json`. + We are using [`yamllint`](https://github.com/adrienverge/yamllint) to enforce coding standards in YAML files. If you do not have `yamllint` installed yet, run -``` +```sh $ brew install yamllint ``` @@ -25,7 +28,7 @@ We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-C Run -``` +```sh $ make coding-standards ``` @@ -37,7 +40,7 @@ We are using [`maglnet/composer-require-checker`](https://github.com/maglnet/Com Run -``` +```sh $ make dependency-analysis ``` @@ -49,7 +52,7 @@ We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo Run -``` +```sh $ make static-code-analysis ``` @@ -59,7 +62,7 @@ We are also using the baseline features of [`phpstan/phpstan`](https://medium.co Run -``` +```sh $ make static-code-analysis-baseline ``` @@ -73,7 +76,7 @@ We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) t Run -``` +```sh $ make tests ``` @@ -85,7 +88,7 @@ We are using [`infection/infection`](https://github.com/infection/infection) to Enable `pcov` or `Xdebug` and run -``` +```sh $ make mutation-tests ``` @@ -95,7 +98,7 @@ to run mutation tests. Run -``` +```sh $ make ``` @@ -105,7 +108,7 @@ to enforce coding standards, run a static code analysis, and run tests! :bulb: Run -``` +```sh $ make help ``` diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..455760a4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,26 @@ +# https://help.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#target-branch + +version: 2 + +updates: + - commit-message: + include: "scope" + prefix: "Build" + directory: "/" + labels: + - "dependency" + open-pull-requests-limit: 10 + package-ecosystem: "composer" + schedule: + interval: "daily" + + - commit-message: + include: "scope" + prefix: "Build" + directory: "/" + labels: + - "dependency" + open-pull-requests-limit: 10 + package-ecosystem: "github-actions" + schedule: + interval: "daily" diff --git a/.github/settings.yml b/.github/settings.yml index 914fda56..898f47df 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -14,23 +14,23 @@ branches: required_approving_review_count: 1 required_status_checks: contexts: + - "Code Coverage (7.4, locked)" - "Coding Standards (7.1, locked)" - "Dependency Analysis (7.4, locked)" + - "Mutation Tests (7.4, locked)" - "Static Code Analysis (7.4, locked)" - - "Tests (7.1, lowest)" - - "Tests (7.1, locked)" - "Tests (7.1, highest)" - - "Tests (7.2, lowest)" - - "Tests (7.2, locked)" + - "Tests (7.1, locked)" + - "Tests (7.1, lowest)" - "Tests (7.2, highest)" - - "Tests (7.3, lowest)" - - "Tests (7.3, locked)" + - "Tests (7.2, locked)" + - "Tests (7.2, lowest)" - "Tests (7.3, highest)" - - "Tests (7.4, lowest)" - - "Tests (7.4, locked)" + - "Tests (7.3, locked)" + - "Tests (7.3, lowest)" - "Tests (7.4, highest)" - - "Code Coverage (7.4, locked)" - - "Mutation Tests (7.4, locked)" + - "Tests (7.4, locked)" + - "Tests (7.4, lowest)" strict: false restrictions: diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 60045295..6c9e0bcd 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -53,7 +53,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" @@ -78,7 +78,7 @@ jobs: run: "mkdir -p .build/php-cs-fixer" - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: ".build/php-cs-fixer" key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('composer.lock') }}" @@ -119,7 +119,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" @@ -171,11 +171,11 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" - key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" - restore-keys: "${{ matrix.php-version }}-composer-locked-" + key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-" - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" @@ -193,7 +193,7 @@ jobs: run: "mkdir -p .build/phpstan" - name: "Cache cache directory for phpstan/phpstan" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: ".build/phpstan" key: "php-${{ matrix.php-version }}-phpstan-${{ github.sha }}" @@ -206,7 +206,7 @@ jobs: run: "mkdir -p .build/psalm" - name: "Cache cache directory for vimeo/psalm" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: ".build/psalm" key: "php-${{ matrix.php-version }}-psalm-${{ github.sha }}" @@ -249,7 +249,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" @@ -305,7 +305,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" @@ -363,7 +363,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}" @@ -404,14 +404,14 @@ jobs: github.event.action == 'reopened' || github.event.action == 'synchronize' ) && ( - (github.actor == 'dependabot-preview[bot]' && startsWith(github.event.pull_request.title, 'Build(deps-dev)')) || + (github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'Build(deps-dev)')) || (github.actor == 'ergebnis-bot' && github.event.pull_request.title == 'Enhancement: Update license year') || (github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge')) ) steps: - name: "Request review from @ergebnis-bot" - uses: "actions/github-script@0.8.0" + uses: "actions/github-script@v2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" script: | @@ -429,11 +429,8 @@ jobs: reviewers: reviewers, }) - - name: "Wait" - run: "sleep 3" - - name: "Assign @ergebnis-bot" - uses: "actions/github-script@0.8.0" + uses: "actions/github-script@v2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" script: | @@ -451,11 +448,8 @@ jobs: repo: repository.repo, }) - - name: "Wait" - run: "sleep 3" - - name: "Approve pull request" - uses: "actions/github-script@0.8.0" + uses: "actions/github-script@v2" if: "github.actor != 'ergebnis-bot'" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" @@ -470,11 +464,8 @@ jobs: repo: repository.repo, }) - - name: "Wait" - run: "sleep 3" - - name: "Merge pull request" - uses: "actions/github-script@0.8.0" + uses: "actions/github-script@v2" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" script: | diff --git a/.github/workflows/prune.yaml b/.github/workflows/prune.yaml index 449e4652..99a34217 100644 --- a/.github/workflows/prune.yaml +++ b/.github/workflows/prune.yaml @@ -14,7 +14,7 @@ jobs: steps: - name: "Prune issues and pull requests" - uses: "actions/stale@v1" + uses: "actions/stale@v3" with: days-before-close: 5 days-before-stale: 60 diff --git a/.github/workflows/renew.yaml b/.github/workflows/renew.yaml index f82995d6..e2da07be 100644 --- a/.github/workflows/renew.yaml +++ b/.github/workflows/renew.yaml @@ -42,7 +42,7 @@ jobs: run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}" @@ -64,7 +64,7 @@ jobs: run: "mkdir -p .build/php-cs-fixer" - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: "actions/cache@v1" + uses: "actions/cache@v2" with: path: ".build/php-cs-fixer" key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}" diff --git a/.github/workflows/triage.yaml b/.github/workflows/triage.yaml new file mode 100644 index 00000000..10688d0a --- /dev/null +++ b/.github/workflows/triage.yaml @@ -0,0 +1,43 @@ +name: "Triage" + +on: # yamllint disable-line rule:truthy + pull_request: + types: + - "opened" + +jobs: + label: + name: "Label" + + runs-on: "ubuntu-latest" + + steps: + - name: "Add labels based on branch name" + uses: "actions/github-script@v2" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const branchPrefixLabels = { + feature: "enhancement", + fix: "bug", + } + + const pullRequest = context.payload.pull_request + const repository = context.repo + + const branchName = pullRequest.head.ref + + const matches = branchName.match(new RegExp('^([^/]+)\/')); + + if (matches instanceof Array && branchPrefixLabels.hasOwnProperty(matches[1])) { + const label = branchPrefixLabels[matches[1]] + + github.issues.addLabels({ + issue_number: pullRequest.number, + labels: [ + label + ], + owner: repository.owner, + repo: repository.repo, + }); + } diff --git a/.php_cs b/.php_cs index 82407edc..6040c79b 100644 --- a/.php_cs +++ b/.php_cs @@ -12,7 +12,7 @@ declare(strict_types=1); */ use Ergebnis\License; -use Ergebnis\PhpCsFixer\Config; +use Ergebnis\PhpCsFixer; $license = License\Type\MIT::markdown( __DIR__ . '/LICENSE.md', @@ -26,14 +26,13 @@ $license = License\Type\MIT::markdown( $license->save(); -$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($license->header())); +$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php71($license->header())); $config->getFinder() ->ignoreDotFiles(false) ->in(__DIR__) ->exclude([ '.build/', - '.dependabot/', '.github/', '.notes/', 'test/Fixture/', diff --git a/Makefile b/Makefile index 4ea60bc4..4aef695d 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,11 @@ it: coding-standards static-code-analysis tests ## Runs the coding-standards, st .PHONY: code-coverage code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit mkdir -p .build/phpunit - vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php - vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text --prepend=.build/phpunit/xdebug-filter.php + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text .PHONY: coding-standards -coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer +coding-standards: vendor ## Normalizes composer.json with ergebnis/composer-normalize, lints YAML files with yamllint and fixes code style issues with friendsofphp/php-cs-fixer + composer normalize yamllint -c .yamllint.yaml --strict . mkdir -p .build/php-cs-fixer vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --verbose @@ -53,4 +53,3 @@ tests: vendor ## Runs auto-review, unit, and integration tests with phpunit/phpu vendor: composer.json composer.lock composer validate --strict composer install --no-interaction --no-progress --no-suggest - composer normalize diff --git a/README.md b/README.md index 9acd27d3..24db2662 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Provides utilities for tests. Run -``` +```sh $ composer require --dev ergebnis/test-util ``` @@ -116,3 +116,7 @@ Please have a look at [`LICENSE.md`](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). + +## Curious what I am building? + +:mailbox_with_mail: [Subscribe to my list](https://localheinz.com/projects/), and I will occasionally send you an email to let you know what I am working on. diff --git a/infection.json b/infection.json index c7774fc5..09dc2fcd 100644 --- a/infection.json +++ b/infection.json @@ -1,14 +1,14 @@ { - "timeout": 10, + "logs": { + "text": ".build/infection/infection-log.txt" + }, + "phpUnit": { + "configDir": "test\/Unit" + }, "source": { "directories": [ "src" ] }, - "phpUnit": { - "configDir": "test\/Unit" - }, - "logs": { - "text": ".build/infection/infection-log.txt" - } + "timeout": 10 }