From 0d708b20467fb658123e1aaae9f4dffbaacd4b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sat, 29 Aug 2020 10:56:49 +0200 Subject: [PATCH] Enhancement: Synchronize with ergebnis/php-library-template --- .gitattributes | 29 +-- .../determine-cache-directory/action.yaml | 16 ++ .../composer/composer/install/action.yaml | 22 ++ .../actions/composer/composer/install/run.sh | 25 +++ .github/dependabot.yml | 2 +- .github/settings.yml | 14 +- .github/workflows/integrate.yaml | 196 +++++++----------- .github/workflows/prune.yaml | 20 +- .github/workflows/release.yaml | 2 +- .github/workflows/renew.yaml | 36 ++-- .github/workflows/triage.yaml | 4 +- Makefile | 7 +- composer-require-checker.json | 19 ++ psalm-baseline.xml | 8 +- psalm.xml | 2 + 15 files changed, 224 insertions(+), 178 deletions(-) create mode 100644 .github/actions/composer/composer/determine-cache-directory/action.yaml create mode 100644 .github/actions/composer/composer/install/action.yaml create mode 100755 .github/actions/composer/composer/install/run.sh create mode 100644 composer-require-checker.json diff --git a/.gitattributes b/.gitattributes index 99692297..79ecf3ae 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,14 +1,15 @@ -/.github/ export-ignore -/test/ export-ignore -/tools/ export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.php_cs export-ignore -/infection.json export-ignore -/Makefile export-ignore -/phive.xml export-ignore -/phpstan-baseline.neon export-ignore -/phpstan.neon export-ignore -/psalm-baseline.xml export-ignore -/psalm.xml export-ignore +/.github/ export-ignore +/test/ export-ignore +/tools/ export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php_cs export-ignore +/composer-require-checker.json export-ignore +/infection.json export-ignore +/Makefile export-ignore +/phive.xml export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon export-ignore +/psalm-baseline.xml export-ignore +/psalm.xml export-ignore diff --git a/.github/actions/composer/composer/determine-cache-directory/action.yaml b/.github/actions/composer/composer/determine-cache-directory/action.yaml new file mode 100644 index 00000000..a898fdaa --- /dev/null +++ b/.github/actions/composer/composer/determine-cache-directory/action.yaml @@ -0,0 +1,16 @@ +# https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions +# https://getcomposer.org/doc/03-cli.md#composer-cache-dir + +name: "Determine composer cache directory" + +description: "Determines the composer cache directory and exports it as COMPOSER_CACHE_DIR environment variable" + +runs: + using: "composite" + + steps: + - name: "Determine composer cache directory" + shell: "bash" + run: "echo \"::set-env name=COMPOSER_CACHE_DIR::$(composer config cache-dir)\"" diff --git a/.github/actions/composer/composer/install/action.yaml b/.github/actions/composer/composer/install/action.yaml new file mode 100644 index 00000000..bab262e5 --- /dev/null +++ b/.github/actions/composer/composer/install/action.yaml @@ -0,0 +1,22 @@ +# https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs +# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions + +name: "Install dependencies with composer" + +description: "Installs dependencies with composer" + +inputs: + dependencies: + description: "Which dependencies to install, one of \"lowest\", \"locked\", \"highest\"" + required: true + +runs: + using: "composite" + + steps: + - name: "Install ${{ inputs.dependencies }} dependencies with composer" + shell: "bash" + run: "${{ github.action_path }}/run.sh" + env: + COMPOSER_INSTALL_DEPENDENCIES: "${{ inputs.dependencies }}" diff --git a/.github/actions/composer/composer/install/run.sh b/.github/actions/composer/composer/install/run.sh new file mode 100755 index 00000000..dddf3039 --- /dev/null +++ b/.github/actions/composer/composer/install/run.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +dependencies="${COMPOSER_INSTALL_DEPENDENCIES}" + +if [[ ${dependencies} == "lowest" ]]; then + composer update --no-interaction --no-progress --no-suggest --prefer-lowest + + exit 0 +fi + +if [[ ${dependencies} == "locked" ]]; then + composer install --no-interaction --no-progress --no-suggest + + exit 0 +fi + +if [[ ${dependencies} == "highest" ]]; then + composer update --no-interaction --no-progress --no-suggest + + exit 0 +fi + +echo "::error::The value for the \"dependencies\" input needs to be one of \"lowest\", \"locked\"', \"highest\"' - got \"${dependencies}\" instead." + +exit 1 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e19966ae..1eedeb94 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,4 @@ -# https://help.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates +# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 diff --git a/.github/settings.yml b/.github/settings.yml index 3d234574..c4cec541 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -3,8 +3,8 @@ branches: - name: "main" - # https://developer.github.com/v3/repos/branches/#remove-branch-protection - # https://developer.github.com/v3/repos/branches/#update-branch-protection + # https://docs.github.com/en/rest/reference/repos#delete-branch-protection + # https://docs.github.com/en/rest/reference/repos#update-branch-protection protection: enforce_admins: false @@ -31,7 +31,7 @@ branches: strict: false restrictions: - # https://developer.github.com/v3/repos/branches/#parameters-1 + # https://docs.github.com/en/rest/reference/repos#list-branches--parameters # 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. @@ -41,8 +41,8 @@ branches: users: - "ergebnis-bot" -# https://developer.github.com/v3/issues/labels/#create-a-label -# https://developer.github.com/v3/issues/labels/#update-a-label +# https://docs.github.com/en/rest/reference/issues#create-a-label +# https://docs.github.com/en/rest/reference/issues#update-a-label labels: - name: "bug" @@ -73,7 +73,7 @@ labels: color: "eeeeee" description: "" -# https://developer.github.com/v3/repos/#edit +# https://docs.github.com/en/rest/reference/repos#update-a-repository repository: allow_merge_commit: true @@ -91,6 +91,6 @@ repository: name: "phpstan-rules" private: false - # https://developer.github.com/v3/repos/branches/#remove-branch-protection + # https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics topics: "phpstan, phpstan-rules, phpstan-extreme-rules" diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index fd08c9c0..f1bae03c 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -1,4 +1,4 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions +# https://docs.github.com/en/actions name: "Integrate" @@ -9,6 +9,7 @@ on: # yamllint disable-line rule:truthy - "main" env: + ERGEBNIS_BOT_NAME: "ergebnis-bot" MIN_COVERED_MSI: 92 MIN_MSI: 83 PHP_EXTENSIONS: "mbstring" @@ -32,14 +33,14 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Lint YAML files" - uses: "ibiqlik/action-yamllint@v1" + uses: "ibiqlik/action-yamllint@v1.0.0" with: config_file: ".yamllint.yaml" file_or_dir: "." strict: true - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: coverage: "none" extensions: "${{ env.PHP_EXTENSIONS }}" @@ -49,27 +50,19 @@ jobs: run: "composer validate --strict" - name: "Determine composer cache directory" - id: "determine-composer-cache-directory" - run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - name: "Run ergebnis/composer-normalize" run: "composer normalize --dry-run" @@ -78,7 +71,7 @@ jobs: run: "mkdir -p .build/php-cs-fixer" - name: "Cache cache directory for friendsofphp/php-cs-fixer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: path: ".build/php-cs-fixer" key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('composer.lock') }}" @@ -105,37 +98,29 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: coverage: "none" extensions: "${{ env.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)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - name: "Run maglnet/composer-require-checker" - run: "tools/composer-require-checker check" + run: "tools/composer-require-checker check --config-file=$(pwd)/composer-require-checker.json" static-code-analysis: name: "Static Code Analysis" @@ -155,53 +140,45 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: coverage: "none" extensions: "${{ env.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)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - name: "Create cache directory for phpstan/phpstan" run: "mkdir -p .build/phpstan" - name: "Cache cache directory for phpstan/phpstan" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: path: ".build/phpstan" key: "php-${{ matrix.php-version }}-phpstan-${{ github.sha }}" restore-keys: "php-${{ matrix.php-version }}-phpstan-" - name: "Run phpstan/phpstan" - run: "vendor/bin/phpstan analyse --configuration=phpstan.neon" + run: "vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=-1" - name: "Create cache directory for vimeo/psalm" run: "mkdir -p .build/psalm" - name: "Cache cache directory for vimeo/psalm" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: path: ".build/psalm" key: "php-${{ matrix.php-version }}-psalm-${{ github.sha }}" @@ -232,34 +209,29 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: coverage: "none" extensions: "${{ env.PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" + - name: "Set up problem matchers for phpunit/phpunit" + run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" + - name: "Determine composer cache directory" - id: "determine-composer-cache-directory" - run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - name: "Run auto-review tests with phpunit/phpunit" run: "vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml" @@ -288,40 +260,32 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: - coverage: "xdebug" - extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" + coverage: "pcov" + extensions: "${{ env.PHP_EXTENSIONS }}" php-version: "${{ matrix.php-version }}" + - name: "Set up problem matchers for phpunit/phpunit" + run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" + - name: "Determine composer cache directory" - id: "determine-composer-cache-directory" - run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" - - - name: "Dump Xdebug filter with phpunit/phpunit" - run: "vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - - name: "Collect code coverage with Xdebug and phpunit/phpunit" - run: "vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --coverage-clover=.build/logs/clover.xml --prepend=.build/phpunit/xdebug-filter.php" + - name: "Collect code coverage with pcov and phpunit/phpunit" + run: "vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --coverage-clover=.build/logs/clover.xml" - name: "Send code coverage report to Codecov.io" env: @@ -346,36 +310,28 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: - coverage: "xdebug" - extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}" + coverage: "pcov" + extensions: "${{ env.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)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - - name: "Run mutation tests with Xdebug and infection/infection" + - name: "Run mutation tests with pcov and infection/infection" run: "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${{ env.MIN_COVERED_MSI }} --min-msi=${{ env.MIN_MSI }}" merge: @@ -405,7 +361,7 @@ jobs: ) steps: - - name: "Request review from @ergebnis-bot" + - name: "Request review from @${{ env.ERGEBNIS_BOT_NAME }}" uses: "actions/github-script@v3.0.0" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" @@ -414,7 +370,7 @@ jobs: const repository = context.repo const reviewers = [ - "ergebnis-bot", + "${{ env.ERGEBNIS_BOT_NAME }}", ] await github.pulls.requestReviewers({ @@ -424,7 +380,7 @@ jobs: reviewers: reviewers, }) - - name: "Assign @ergebnis-bot" + - name: "Assign @${{ env.ERGEBNIS_BOT_NAME }}" uses: "actions/github-script@v3.0.0" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" @@ -432,12 +388,12 @@ jobs: const pullRequest = context.payload.pull_request const repository = context.repo - const reviewers = [ - "ergebnis-bot", + const assignees = [ + "${{ env.ERGEBNIS_BOT_NAME }}", ] await github.issues.addAssignees({ - assignees: reviewers, + assignees: assignees, issue_number: pullRequest.number, owner: repository.owner, repo: repository.repo, @@ -445,7 +401,7 @@ jobs: - name: "Approve pull request" uses: "actions/github-script@v3.0.0" - if: "github.actor != 'ergebnis-bot'" + if: "github.actor != '${{ env.ERGEBNIS_BOT_NAME }}'" with: github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" script: | diff --git a/.github/workflows/prune.yaml b/.github/workflows/prune.yaml index 99a34217..180b7229 100644 --- a/.github/workflows/prune.yaml +++ b/.github/workflows/prune.yaml @@ -1,4 +1,4 @@ -# https://github.com/actions/stale +# https://docs.github.com/en/actions name: "Prune" @@ -6,6 +6,10 @@ on: # yamllint disable-line rule:truthy schedule: - cron: "0 12 * * *" +env: + DAYS_BEFORE_CLOSE: 14 + DAYS_BEFORE_STALE: 180 + jobs: prune: name: "Issues" @@ -14,18 +18,18 @@ jobs: steps: - name: "Prune issues and pull requests" - uses: "actions/stale@v3" + uses: "actions/stale@v3.0.10" with: - days-before-close: 5 - days-before-stale: 60 + days-before-close: "${{ env.DAYS_BEFORE_CLOSE }}" + days-before-stale: "${{ env.DAYS_BEFORE_STALE }}" 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. + Since this issue has not had any activity within the last ${{ env.DAYS_BEFORE_STALE }} days, I have marked it as stale. - I will close it if no further activity occurs within the next five days. + I will close it if no further activity occurs within the next ${{ env.DAYS_BEFORE_CLOSE }} 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. + Since this pull request has not had any activity within the last ${{ env.DAYS_BEFORE_STALE }} days, I have marked it as stale. - I will close it if no further activity occurs within the next five days. + I will close it if no further activity occurs within the next ${{ env.DAYS_BEFORE_CLOSE }} days. diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3133c9c4..e5b72ee8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions +# https://docs.github.com/en/actions name: "Release" diff --git a/.github/workflows/renew.yaml b/.github/workflows/renew.yaml index 9db86c27..0fdb3842 100644 --- a/.github/workflows/renew.yaml +++ b/.github/workflows/renew.yaml @@ -1,4 +1,4 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions +# https://docs.github.com/en/actions name: "Renew" @@ -7,6 +7,8 @@ on: # yamllint disable-line rule:truthy - cron: "1 0 1 1 *" env: + ERGEBNIS_BOT_EMAIL: "bot@ergebn.is" + ERGEBNIS_BOT_NAME: "ergebnis-bot" PHP_EXTENSIONS: "mbstring" jobs: @@ -28,7 +30,7 @@ jobs: uses: "actions/checkout@v2.3.2" - name: "Install PHP with extensions" - uses: "shivammathur/setup-php@v2" + uses: "shivammathur/setup-php@2.4.3" with: coverage: "none" extensions: "${{ env.PHP_EXTENSIONS }}" @@ -38,36 +40,28 @@ jobs: run: "composer validate --strict" - name: "Determine composer cache directory" - id: "determine-composer-cache-directory" - run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + uses: "./.github/actions/composer/composer/determine-cache-directory" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v2.1.1" with: - path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" - key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}" + path: "${{ env.COMPOSER_CACHE_DIR }}" + 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'" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest" - - - name: "Install locked dependencies from composer.lock" - if: "matrix.dependencies == 'locked'" - run: "composer install --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies from composer.json" - if: "matrix.dependencies == 'highest'" - run: "composer update --no-interaction --no-progress --no-suggest" + - name: "Install ${{ matrix.dependencies }} dependencies with composer" + uses: "./.github/actions/composer/composer/install" + with: + dependencies: "${{ matrix.dependencies }}" - 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@v2" + uses: "actions/cache@v2.1.1" with: path: ".build/php-cs-fixer" - key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}" + 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" @@ -76,7 +70,7 @@ jobs: - name: "Open pull request updating license year" uses: "gr2m/create-or-update-pull-request-action@v1.2.10" with: - author: "ergebnis-bot " + author: "${{ env.ERGEBNIS_BOT_NAME }} <${{ env.ERGEBNIS_BOT_EMAIL }}>" branch: "feature/license-year" body: | This PR diff --git a/.github/workflows/triage.yaml b/.github/workflows/triage.yaml index 5091493b..f86c120a 100644 --- a/.github/workflows/triage.yaml +++ b/.github/workflows/triage.yaml @@ -1,7 +1,9 @@ +# https://docs.github.com/en/actions + name: "Triage" on: # yamllint disable-line rule:truthy - pull_request: + pull_request_target: types: - "opened" diff --git a/Makefile b/Makefile index 53931a72..e1f6b9e9 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,7 @@ 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/Integration/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php - vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --coverage-text --prepend=.build/phpunit/xdebug-filter.php + vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --coverage-text .PHONY: coding-standards 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 @@ -20,7 +19,7 @@ coding-standards: vendor ## Normalizes composer.json with ergebnis/composer-norm .PHONY: dependency-analysis dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker - tools/composer-require-checker check + tools/composer-require-checker check --config-file=$(shell pwd)/composer-require-checker.json .PHONY: help help: ## Displays this list of targets with descriptions @@ -34,7 +33,7 @@ mutation-tests: vendor ## Runs mutation tests with infection/infection .PHONY: static-code-analysis static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm mkdir -p .build/phpstan - vendor/bin/phpstan analyse --configuration=phpstan.neon + vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=-1 mkdir -p .build/psalm vendor/bin/psalm --config=psalm.xml --diff --diff-methods --show-info=false --stats --threads=4 diff --git a/composer-require-checker.json b/composer-require-checker.json new file mode 100644 index 00000000..67d0aa16 --- /dev/null +++ b/composer-require-checker.json @@ -0,0 +1,19 @@ +{ + "symbol-whitelist": [ + "array", + "bool", + "callable", + "false", + "float", + "int", + "iterable", + "null", + "object", + "parent", + "self", + "static", + "string", + "true", + "void" + ] +} diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d9704a49..41479c44 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $docComment->getReformattedText() @@ -9,6 +9,9 @@ $annotation + + true === $allowAbstractClasses + @@ -20,6 +23,9 @@ isset($node->namespacedName) + + string + diff --git a/psalm.xml b/psalm.xml index 33b5c2a6..a4c89a87 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,7 +6,9 @@ cacheDirectory=".build/psalm" errorBaseline="psalm-baseline.xml" errorLevel="1" + findUnusedVariablesAndParams="true" resolveFromConfigFile="true" + strictBinaryOperands="true" >