Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Enhancement: Synchronize with ergebnis/php-library-template #161

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ update_configs:
- automerged_updates:
- match:
dependency_type: "development"
commit_message:
include_scope: true
prefix: "Build"
default_assignees:
- "localheinz"
default_labels:
Expand Down
23 changes: 13 additions & 10 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/.dependabot/ export-ignore
/.github/ export-ignore
/test/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/infection.json export-ignore
/Makefile export-ignore
/phpstan.neon export-ignore
/.dependabot/ export-ignore
/.github/ export-ignore
/test/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/infection.json export-ignore
/Makefile export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
10 changes: 5 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ to run a dependency analysis.

## Static Code Analysis

We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) to statically analyze the code.
We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.

Run

Expand All @@ -40,17 +40,17 @@ $ make static-code-analysis

to run a static code analysis.

We are also using the [baseline feature](https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff) of [`phpstan/phpstan`](https://github.com/phpstan/phpstan).
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

```
$ make static-code-analysis-baseline
```

to regenerate the baseline in [`../phpstan-baseline.neon`](../phpstan-baseline.neon).
to regenerate the baselines in [`../phpstan-baseline.neon`](../phpstan-baseline.neon) and [`../psalm-baseline.xml`](../psalm-baseline.xml).

:exclamation: Ideally, the baseline should shrink over time.
:exclamation: Ideally, the baselines should shrink over time.

## Tests

Expand All @@ -68,7 +68,7 @@ to run all the tests.

We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `Xdebug` and run
Enable `pcov` or `Xdebug` and run

```
$ make mutation-tests
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Continuous Deployment"

on:
push:
tags:
- "**"

jobs:
release:
name: "Release"

runs-on: "ubuntu-latest"

steps:
- name: "Determine tag"
id: "determine-tag"
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""

- name: "Create release"
uses: "actions/create-release@v1.0.0"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
draft: false
prerelease: false
release_name: "${{ steps.determine-tag.outputs.tag }}"
tag_name: "${{ steps.determine-tag.outputs.tag }}"
92 changes: 82 additions & 10 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Continuous Integration"

on:
pull_request:
push:
branches:
- "master"
tags:
- "**"

name: "Continuous Integration"

env:
MIN_COVERED_MSI: 95
Expand All @@ -34,7 +32,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand All @@ -50,9 +48,18 @@ jobs:
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: "Run ergebnis/composer-normalize"
run: "composer normalize --dry-run"

Expand Down Expand Up @@ -90,7 +97,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand All @@ -103,9 +110,18 @@ jobs:
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: "Run maglnet/composer-require-checker"
uses: "docker://webfactory/composer-require-checker:2.0.0"
with:
Expand All @@ -129,7 +145,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand All @@ -142,12 +158,30 @@ jobs:
key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}"
restore-keys: "${{ matrix.php-version }}-composer-locked-"

- 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 phpstan/phpstan"
run: "mkdir -p .build/phpstan"

- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan analyse --configuration=phpstan.neon"

- name: "Create cache directory for vimeo/psalm"
run: "mkdir -p .build/psalm"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --show-info=false"

tests:
name: "Tests"

Expand All @@ -171,7 +205,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "none"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand Down Expand Up @@ -223,7 +257,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "xdebug"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand All @@ -236,9 +270,18 @@ jobs:
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: "Dump Xdebug filter with phpunit/phpunit"
run: "vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php"

Expand Down Expand Up @@ -268,7 +311,7 @@ jobs:
uses: "actions/checkout@v2.0.0"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@1.6.2"
uses: "shivammathur/setup-php@1.7.0"
with:
coverage: "xdebug"
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
Expand All @@ -281,8 +324,37 @@ jobs:
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: "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"

runs-on: "ubuntu-latest"

needs:
- "code-coverage"
- "coding-standards"
- "dependency-analysis"
- "mutation-tests"
- "static-code-analysis"
- "tests"

steps:
- name: "Approve"
uses: "hmarr/auto-approve-action@v2.0.0"
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.AUTO_APPROVE_TOKEN }}"
11 changes: 6 additions & 5 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/actions/stale

name: "Close stale issues and pull requests"
name: "Stale"

on:
schedule:
Expand All @@ -11,18 +11,19 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/stale@v1.1.0"
- name: "Close stale issues and pull requests"
uses: "actions/stale@v1.1.0"
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
days-before-stale: 60
days-before-close: 5
days-before-stale: 60
repo-token: "${{ secrets.GITHUB_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.
stale-pr-label: "stale"
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ code-coverage: vendor ## Collects coverage from running unit tests with phpunit/
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
mkdir -p .build/php-cs-fixer
vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --verbose
vendor/bin/php-cs-fixer fix --config=.php_cs.fixture --diff --diff-format=udiff --verbose

.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
Expand All @@ -30,15 +29,19 @@ mutation-tests: vendor ## Runs mutation tests with infection/infection
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${MIN_COVERED_MSI} --min-msi=${MIN_MSI}

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
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
mkdir -p .build/psalm
vendor/bin/psalm --config=psalm.xml --show-info=false

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with phpstan/phpstan
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with phpstan/phpstan and vimeo/psalm
mkdir -p .build/phpstan
echo '' > phpstan-baseline.neon
vendor/bin/phpstan analyze --configuration=phpstan.neon --error-format=baselineNeon > phpstan-baseline.neon || true
mkdir -p .build/psalm
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml

.PHONY: tests
tests: vendor ## Runs auto-review, unit, and integration tests with phpunit/phpunit
Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
},
"require-dev": {
"ergebnis/composer-normalize": "^2.0.2",
"ergebnis/php-cs-fixer-config": "^1.1.2",
"ergebnis/php-cs-fixer-config": "^1.1.3",
"ergebnis/phpstan-rules": "~0.14.2",
"infection/infection": "~0.13.6",
"phpstan/extension-installer": "^1.0.3",
"phpstan/phpstan": "~0.12.3",
"phpstan/phpstan-deprecation-rules": "~0.12.0",
"phpstan/phpstan-phpunit": "~0.12.3",
"phpstan/phpstan-strict-rules": "~0.12.0",
"phpunit/phpunit": "^7.5.18"
"phpunit/phpunit": "^7.5.18",
"psalm/plugin-phpunit": "~0.8.0",
"vimeo/psalm": "^3.8.1"
},
"config": {
"platform": {
"php": "7.1.33"
},
"preferred-install": "dist",
"sort-packages": true
},
Expand Down
Loading