diff --git a/.dependabot/config.yml b/.dependabot/config.yaml similarity index 100% rename from .dependabot/config.yml rename to .dependabot/config.yaml diff --git a/.editorconfig b/.editorconfig index 329611ca..3aaad722 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,7 +13,7 @@ indent_size = 2 [*.neon] indent_style = tab -[*.yml] +[*.{yaml,yml}] indent_size = 2 [Makefile] diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 118930c8..729263ef 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,7 +2,12 @@ We are using [GitHub Actions](https://github.com/features/actions) as a continuous integration system. -For details, see [`workflows/continuous-integration.yml`](workflows/continuous-integration.yml). +For details, take a look at the following workflow configuration files: + +- [`workflows/integrate.yaml`](workflows/integrate.yaml) +- [`workflows/prune.yaml`](workflows/prune.yaml) +- [`workflows/release.yaml`](workflows/release.yaml) +- [`workflows/renew.yaml`](workflows/renew.yaml) ## Coding Standards @@ -40,7 +45,7 @@ $ make static-code-analysis to run a static code analysis. -We are also using the baseline features of [`phpstan/phpstan`(https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff) and [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file). +We are also using the baseline features of [`phpstan/phpstan`](https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff) and [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file). Run diff --git a/.github/settings.yml b/.github/settings.yml index 51549117..aa3c6671 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -28,6 +28,12 @@ branches: - "Tests (7.4, highest)" strict: false restrictions: + + # https://developer.github.com/v3/repos/branches/#parameters-1 + + # Note: User, app, and team restrictions are only available for organization-owned repositories. + # Set to null to disable when using this configuration for a repository on a personal account. + apps: - "dependabot-preview" teams: [] @@ -39,35 +45,35 @@ branches: labels: - name: "bug" - color: "#ee0701" + color: "ee0701" description: "" - name: "dependency" - color: "#0366d6" + color: "0366d6" description: "" - name: "enhancement" - color: "#0e8a16" + color: "0e8a16" description: "" - name: "rfc" - color: "#f4db3a" + color: "f4db3a" description: "" - name: "question" - color: "#cc317c" + color: "cc317c" description: "" - name: "security" - color: "#ee0701" + color: "ee0701" description: "" - name: "stale" - color: "#eeeeee" + color: "eeeeee" description: "" - name: "vendor" - color: "#f4db3a" + color: "f4db3a" description: "" # https://developer.github.com/v3/repos/#edit diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/integrate.yaml similarity index 71% rename from .github/workflows/continuous-integration.yml rename to .github/workflows/integrate.yaml index db985f43..f8105970 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/integrate.yaml @@ -1,9 +1,9 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: "Continuous Integration" +name: "Integrate" -on: - pull_request: +on: # yamllint disable-line rule:truthy + pull_request: null push: branches: - "master" @@ -27,10 +27,17 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2.0.0" + uses: "actions/checkout@v2" + + - name: "Lint YAML files" + uses: "ibiqlik/action-yamllint@v1" + with: + config_file: ".yamllint.yaml" + file_or_dir: "." + strict: true - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.3" + uses: "shivammathur/setup-php@v2" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -39,22 +46,26 @@ jobs: - name: "Validate composer.json and composer.lock" run: "composer validate --strict" + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: - path: "~/.composer/cache" + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" 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" + - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - name: "Install locked dependencies with composer" + - name: "Install locked dependencies from composer.lock" if: "matrix.dependencies == 'locked'" run: "composer install --no-interaction --no-progress --no-suggest" - - name: "Install highest dependencies with composer" + - name: "Install highest dependencies from composer.json" if: "matrix.dependencies == 'highest'" run: "composer update --no-interaction --no-progress --no-suggest" @@ -65,7 +76,7 @@ jobs: run: "mkdir -p .build/php-cs-fixer" - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: path: ".build/php-cs-fixer" key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}" @@ -89,36 +100,40 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2.0.0" + uses: "actions/checkout@v2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.3" + uses: "shivammathur/setup-php@v2" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: - path: "~/.composer/cache" + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" 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" + - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - name: "Install locked dependencies with composer" + - name: "Install locked dependencies from composer.lock" if: "matrix.dependencies == 'locked'" run: "composer install --no-interaction --no-progress --no-suggest" - - name: "Install highest dependencies with composer" + - name: "Install highest dependencies from composer.json" if: "matrix.dependencies == 'highest'" run: "composer update --no-interaction --no-progress --no-suggest" - name: "Run maglnet/composer-require-checker" - uses: "docker://webfactory/composer-require-checker:2.0.0" + uses: "docker://webfactory/composer-require-checker:2.1.0" static-code-analysis: name: "Static Code Analysis" @@ -135,37 +150,48 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2.0.0" + uses: "actions/checkout@v2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.3" + uses: "shivammathur/setup-php@v2" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: - path: "~/.composer/cache" + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}" restore-keys: "${{ matrix.php-version }}-composer-locked-" - - name: "Install lowest dependencies with composer" + - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - name: "Install locked dependencies with composer" + - name: "Install locked dependencies from composer.lock" if: "matrix.dependencies == 'locked'" run: "composer install --no-interaction --no-progress --no-suggest" - - name: "Install highest dependencies with composer" + - name: "Install highest dependencies from composer.json" if: "matrix.dependencies == 'highest'" run: "composer update --no-interaction --no-progress --no-suggest" - name: "Create cache directory for phpstan/phpstan" run: "mkdir -p .build/phpstan" + - name: "Cache cache directory for phpstan/phpstan" + uses: "actions/cache@v1" + with: + path: ".build/phpstan" + key: "php-${{ matrix.php-version }}-phpstan-${{ hashFiles('**/composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-phpstan-" + - name: "Run phpstan/phpstan" run: "vendor/bin/phpstan analyse --configuration=phpstan.neon" @@ -194,31 +220,35 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2.0.0" + uses: "actions/checkout@v2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.3" + uses: "shivammathur/setup-php@v2" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: - path: "~/.composer/cache" + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" 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" + - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - name: "Install locked dependencies with composer" + - name: "Install locked dependencies from composer.lock" if: "matrix.dependencies == 'locked'" run: "composer install --no-interaction --no-progress --no-suggest" - - name: "Install highest dependencies with composer" + - name: "Install highest dependencies from composer.json" if: "matrix.dependencies == 'highest'" run: "composer update --no-interaction --no-progress --no-suggest" diff --git a/.github/workflows/prune.yaml b/.github/workflows/prune.yaml new file mode 100644 index 00000000..449e4652 --- /dev/null +++ b/.github/workflows/prune.yaml @@ -0,0 +1,31 @@ +# https://github.com/actions/stale + +name: "Prune" + +on: # yamllint disable-line rule:truthy + schedule: + - cron: "0 12 * * *" + +jobs: + prune: + name: "Issues" + + runs-on: "ubuntu-latest" + + steps: + - name: "Prune issues and pull requests" + uses: "actions/stale@v1" + with: + days-before-close: 5 + days-before-stale: 60 + repo-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + stale-issue-label: "stale" + stale-issue-message: | + Since this issue has not had any activity within the last sixty days, I have marked it as stale. + + I will close it if no further activity occurs within the next five days. + stale-pr-label: "stale" + stale-pr-message: | + Since this pull request has not had any activity within the last sixty days, I have marked it as stale. + + I will close it if no further activity occurs within the next five days. diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/release.yaml similarity index 86% rename from .github/workflows/continuous-deployment.yml rename to .github/workflows/release.yaml index c8b2a2e9..5cd6d94b 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/release.yaml @@ -1,8 +1,8 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: "Continuous Deployment" +name: "Release" -on: +on: # yamllint disable-line rule:truthy push: tags: - "**" @@ -19,7 +19,7 @@ jobs: run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\"" - name: "Create release" - uses: "actions/create-release@v1.0.0" + uses: "actions/create-release@v1" env: GITHUB_TOKEN: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" with: diff --git a/.github/workflows/license.yml b/.github/workflows/renew.yaml similarity index 76% rename from .github/workflows/license.yml rename to .github/workflows/renew.yaml index 5786ef26..c6923adf 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/renew.yaml @@ -1,8 +1,8 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: "License" +name: "Renew" -on: +on: # yamllint disable-line rule:truthy schedule: - cron: "1 0 1 1 *" @@ -18,17 +18,17 @@ jobs: strategy: matrix: php-version: - - "7.1" + - "7.2" dependencies: - "locked" steps: - name: "Checkout" - uses: "actions/checkout@v2.0.0" + uses: "actions/checkout@v2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@1.7.3" + uses: "shivammathur/setup-php@v2" with: coverage: "none" extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" @@ -37,22 +37,26 @@ jobs: - name: "Validate composer.json and composer.lock" run: "composer validate --strict" + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + - name: "Cache dependencies installed with composer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: - path: "~/.composer/cache" + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" 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" + - name: "Install lowest dependencies from composer.json" if: "matrix.dependencies == 'lowest'" run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - name: "Install locked dependencies with composer" + - name: "Install locked dependencies from composer.lock" if: "matrix.dependencies == 'locked'" run: "composer install --no-interaction --no-progress --no-suggest" - - name: "Install highest dependencies with composer" + - name: "Install highest dependencies from composer.json" if: "matrix.dependencies == 'highest'" run: "composer update --no-interaction --no-progress --no-suggest" @@ -60,7 +64,7 @@ jobs: run: "mkdir -p .build/php-cs-fixer" - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: "actions/cache@v1.0.3" + uses: "actions/cache@v1" with: path: ".build/php-cs-fixer" key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}" @@ -70,7 +74,7 @@ jobs: 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" + uses: "gr2m/create-or-update-pull-request-action@v1.2.10" with: author: "ergebnis-bot " branch: "feature/license-year" diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 0d6f48ef..00000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,29 +0,0 @@ -# https://github.com/actions/stale - -name: "Stale" - -on: - schedule: - - cron: "0 12 * * *" - -jobs: - stale: - runs-on: "ubuntu-latest" - - steps: - - name: "Close stale issues and pull requests" - uses: "actions/stale@v1.1.0" - with: - days-before-close: 5 - days-before-stale: 60 - repo-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" - stale-issue-label: 'stale' - stale-issue-message: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. - stale-pr-label: "stale" - stale-pr-message: > - This PR has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. diff --git a/.php_cs b/.php_cs index 0241e668..7846af94 100644 --- a/.php_cs +++ b/.php_cs @@ -32,9 +32,9 @@ $config->getFinder() ->ignoreDotFiles(false) ->in(__DIR__) ->exclude([ - '.build', - '.dependabot', - '.github', + '.build/', + '.dependabot/', + '.github/', ]) ->name('.php_cs'); diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 00000000..17b1b556 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,65 @@ +extends: "default" + +ignore: | + .build/ + vendor/ + +rules: + braces: + max-spaces-inside-empty: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: 0 + min-spaces-inside: 1 + brackets: + max-spaces-inside-empty: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 0 + min-spaces-inside: 0 + colons: + max-spaces-after: 1 + max-spaces-before: 0 + commas: + max-spaces-after: 1 + max-spaces-before: 0 + min-spaces-after: 1 + comments: + ignore-shebangs: true + min-spaces-from-content: 1 + require-starting-space: true + comments-indentation: "enable" + document-end: + present: false + document-start: + present: false + indentation: + check-multi-line-strings: true + indent-sequences: true + spaces: 2 + empty-lines: + max-end: 0 + max-start: 0 + max: 1 + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + hyphens: + max-spaces-after: 2 + key-duplicates: "enable" + key-ordering: "disable" + line-length: "disable" + new-line-at-end-of-file: "enable" + new-lines: + type: "unix" + octal-values: + forbid-implicit-octal: true + quoted-strings: + quote-type: "double" + trailing-spaces: "enable" + truthy: + allowed-values: + - "false" + - "true" + +yaml-files: + - '*.yaml' + - '*.yml' diff --git a/Makefile b/Makefile index 3228a3c8..1cb60ad8 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,13 @@ it: coding-standards dependency-analysis static-code-analysis tests ## Runs the .PHONY: coding-standards coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer + 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 .PHONY: dependency-analysis dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker - docker run --interactive --rm --tty --volume ${PWD}:/app webfactory/composer-require-checker:2.0.0 + docker run --interactive --rm --tty --volume ${PWD}:/app webfactory/composer-require-checker:2.1.0 .PHONY: help help: ## Displays this list of targets with descriptions diff --git a/README.md b/README.md index 675797e0..db183548 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # http-method -[![Continuous Deployment](https://github.com/ergebnis/http-method/workflows/Continuous%20Deployment/badge.svg)](https://github.com/ergebnis/http-method/actions) -[![Continuous Integration](https://github.com/ergebnis/http-method/workflows/Continuous%20Integration/badge.svg)](https://github.com/ergebnis/http-method/actions) +[![Integrate](https://github.com/ergebnis/http-method/workflows/Integrate/badge.svg?branch=master)](https://github.com/ergebnis/http-method/actions) +[![Prune](https://github.com/ergebnis/http-method/workflows/Prune/badge.svg?branch=master)](https://github.com/ergebnis/http-method/actions) +[![Release](https://github.com/ergebnis/http-method/workflows/Release/badge.svg?branch=master)](https://github.com/ergebnis/http-method/actions) +[![Renew](https://github.com/ergebnis/http-method/workflows/Renew/badge.svg?branch=master)](https://github.com/ergebnis/http-method/actions) [![Type Coverage](https://shepherd.dev/github/ergebnis/http-method/coverage.svg)](https://shepherd.dev/github/ergebnis/http-method) @@ -150,4 +152,6 @@ Please have a look at [`CODE_OF_CONDUCT.md`](https://github.com/ergebnis/.github ## License -This package is licensed using the [MIT License](LICENSE.md). +This package is licensed using the MIT License. + +Please have a look at [`LICENSE.md`](LICENSE.md). diff --git a/phpstan.neon b/phpstan.neon index d52be24d..c1075f0a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,6 +6,6 @@ parameters: inferPrivatePropertyTypeFromConstructor: true level: max paths: - - src - - test - tmpDir: %currentWorkingDirectory%/.build/phpstan + - src/ + - test/ + tmpDir: %currentWorkingDirectory%/.build/phpstan/ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9ba07fe4..4380f5a9 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + assertSame @@ -77,4 +77,14 @@ assertSame + + + array + + + + + array + + diff --git a/psalm.xml b/psalm.xml index 87dbffbd..d645df4b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,7 +3,9 @@ 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/psalm" errorBaseline="psalm-baseline.xml" + errorLevel="1" resolveFromConfigFile="true" > @@ -15,10 +17,10 @@ - - + + - + diff --git a/test/Unit/phpunit.xml b/test/Unit/phpunit.xml index 07b9c636..5d606146 100644 --- a/test/Unit/phpunit.xml +++ b/test/Unit/phpunit.xml @@ -29,7 +29,7 @@ - ../../src + ../../src/