diff --git a/.gitattributes b/.gitattributes index 4d2bdd86..69452453 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -/.dependabot/ export-ignore /.github/ export-ignore /test/ export-ignore /tools/ export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 3197d614..4a07dd7e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,9 +8,12 @@ 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 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 6581af3c..492955b7 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -17,15 +17,15 @@ branches: - "Coding Standards (7.2, locked)" - "Dependency Analysis (7.4, locked)" - "Static Code Analysis (7.4, locked)" - - "Tests (7.2, lowest)" - - "Tests (7.2, locked)" - "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)" + - "Tests (7.4, locked)" + - "Tests (7.4, lowest)" strict: false restrictions: diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index c04787fe..3fcd512e 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -51,7 +51,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') }}" @@ -76,7 +76,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') }}" @@ -114,7 +114,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') }}" @@ -164,11 +164,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'" @@ -186,7 +186,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 }}" @@ -199,7 +199,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 }}" @@ -241,7 +241,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') }}" @@ -286,14 +286,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: | @@ -311,11 +311,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: | @@ -333,11 +330,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 }}" @@ -352,11 +346,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 c6923adf..a2c63901 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 1101c5fd..651ae409 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/', ]) diff --git a/Makefile b/Makefile index 8cfd96e7..700f7e9f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ it: coding-standards static-code-analysis tests ## Runs the coding-standards, static-code-analysis, and tests targets .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 @@ -40,4 +41,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 e4810959..a20e4df6 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ The interface [`Ergebnis\Http\Method\Vendor\VarnishCache`](/src/Method/Vendor/Va To use these constants, import the interfaces and refer to the constants instead of using magic strings: ```php + - + assertSame