Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 3, 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
25 changes: 14 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/.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
/phpbench.json 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
/phpbench.json 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/[email protected]"
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: 88
Expand All @@ -34,7 +32,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -87,7 +94,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -100,9 +107,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"

Expand All @@ -124,7 +140,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -137,12 +153,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 @@ -166,7 +200,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -218,7 +252,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -231,9 +265,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 @@ -263,7 +306,7 @@ jobs:
uses: "actions/[email protected]"

- 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 @@ -276,8 +319,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/[email protected]"
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/[email protected]"
- name: "Close stale issues and pull requests"
uses: "actions/[email protected]"
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"
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,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
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"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",
"ergebnis/test-util": "~0.7.0",
"infection/infection": "~0.13.6",
Expand All @@ -26,9 +26,14 @@
"phpstan/phpstan-deprecation-rules": "~0.12.0",
"phpstan/phpstan-strict-rules": "~0.12.0",
"phpunit/phpunit": "^7.5.18",
"psalm/plugin-phpunit": "~0.8.0",
"vimeo/psalm": "^3.8.1",
"zendframework/zend-file": "^2.8.3"
},
"config": {
"platform": {
"php": "7.1.33"
},
"preferred-install": "dist",
"sort-packages": true
},
Expand Down
Loading