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 #169

Merged
merged 1 commit into from
Apr 11, 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
5 changes: 1 addition & 4 deletions .dependabot/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
version: 1

update_configs:
- automerged_updates:
- match:
dependency_type: "development"
commit_message:
- commit_message:
include_scope: true
prefix: "Build"
default_labels:
Expand Down
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/.dependabot/ export-ignore
/.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
/phpbench.json export-ignore
/phive.xml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/psalm-baseline.xml export-ignore
Expand Down
26 changes: 12 additions & 14 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ For details, take a look at the following workflow configuration files:

## Coding Standards

We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards.
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

```
$ brew install yamllint
```

to install `yamllint`.

We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards in PHP files.

Run

Expand Down Expand Up @@ -81,18 +91,6 @@ $ make mutation-tests

to run mutation tests.

## Benchmarks

We are using [`phpbench/phpbench`](http://github.com/phpbench/phpbench) to benchmark performance and memory consumption.

Run

```
$ make bench
```

to run all the benchmarks.

## Extra lazy?

Run
Expand All @@ -101,7 +99,7 @@ Run
$ make
```

to enforce coding standards, run a dependency analysis, run a static code analysis, run tests, and run benchmarks!
to enforce coding standards, run a static code analysis, and run tests!

## Help

Expand Down
9 changes: 5 additions & 4 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ branches:
- "Tests (7.4, highest)"
- "Code Coverage (7.4, locked)"
- "Mutation Tests (7.4, locked)"
- "codecov/patch"
- "codecov/project"
strict: false
restrictions:

Expand All @@ -41,8 +39,7 @@ branches:
# 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"
apps: []
teams: []
users:
- "ergebnis-bot"
Expand All @@ -63,6 +60,10 @@ labels:
color: "0e8a16"
description: ""

- name: "merge"
color: "6f42c1"
description: ""

- name: "question"
color: "cc317c"
description: ""
Expand Down
125 changes: 105 additions & 20 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
uses: "actions/cache@v1"
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"
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand All @@ -141,7 +141,7 @@ jobs:
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Run maglnet/composer-require-checker"
uses: "docker://webfactory/composer-require-checker:2.1.0"
run: "tools/composer-require-checker check"

static-code-analysis:
name: "Static Code Analysis"
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('**/composer.lock') }}"
key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "${{ matrix.php-version }}-composer-locked-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand All @@ -200,7 +200,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: ".build/phpstan"
key: "php-${{ matrix.php-version }}-phpstan-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-phpstan-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-phpstan-"

- name: "Run phpstan/phpstan"
Expand All @@ -209,8 +209,15 @@ jobs:
- name: "Create cache directory for vimeo/psalm"
run: "mkdir -p .build/psalm"

- name: "Cache cache directory for vimeo/psalm"
uses: "actions/cache@v1"
with:
path: ".build/psalm"
key: "php-${{ matrix.php-version }}-psalm-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-psalm-"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --shepherd --show-info=false --stats"
run: "vendor/bin/psalm --config=psalm.xml --diff --diff-methods --shepherd --show-info=false --stats --threads=4"

tests:
name: "Tests"
Expand Down Expand Up @@ -249,7 +256,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand Down Expand Up @@ -308,7 +315,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand Down Expand Up @@ -369,7 +376,7 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Set COMPOSER_ROOT_VERSION environment variable"
Expand All @@ -387,11 +394,11 @@ jobs:
if: "matrix.dependencies == 'highest'"
run: "composer update --no-interaction --no-progress --no-suggest"

- 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 }}"

review:
name: "Review"
merge:
name: "Merge"

runs-on: "ubuntu-latest"

Expand All @@ -403,15 +410,93 @@ jobs:
- "static-code-analysis"
- "tests"

if: >
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false && (
github.event.action == 'opened' ||
github.event.action == 'reopened' ||
github.event.action == 'synchronize'
) && (
(github.actor == 'dependabot-preview[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: "Approve pull requests created by dependabot that update development dependencies"
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)')"
- name: "Request review from @ergebnis-bot"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"

- name: "Approve pull requests created by @ergebnis-bot that update the license year"
uses: "hmarr/[email protected]"
if: "github.actor == 'ergebnis-bot' && github.event_name == 'pull_request' && github.event.pull_request.title == 'Enhancement: Update license year'"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo

const reviewers = [
"ergebnis-bot",
]

await github.pulls.createReviewRequest({
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
reviewers: reviewers,
})

- name: "Wait"
run: "sleep 3"

- name: "Assign @ergebnis-bot"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo

const reviewers = [
"ergebnis-bot",
]

await github.issues.addAssignees({
assignees: reviewers,
issue_number: pullRequest.number,
owner: repository.owner,
repo: repository.repo,
})

- name: "Wait"
run: "sleep 3"

- name: "Approve pull request"
uses: "actions/[email protected]"
if: "github.actor != 'ergebnis-bot'"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo

await github.pulls.createReview({
event: "APPROVE",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})

- name: "Wait"
run: "sleep 3"

- name: "Merge pull request"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const pullRequest = context.payload.pull_request
const repository = context.repo

await github.pulls.merge({
merge_method: "merge",
owner: repository.owner,
pull_number: pullRequest.number,
repo: repository.repo,
})
2 changes: 1 addition & 1 deletion .github/workflows/renew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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/[email protected].9"
uses: "gr2m/[email protected].10"
with:
author: "ergebnis-bot <[email protected]>"
branch: "feature/license-year"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.build/
/.notes/
/vendor/
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $config->getFinder()
'.build/',
'.dependabot/',
'.github/',
'.notes/',
'test/Fixture/',
])
->name('.php_cs');
Expand Down
3 changes: 2 additions & 1 deletion .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends: "default"

ignore: |
.build/
.notes/
vendor/

rules:
Expand Down Expand Up @@ -32,7 +33,7 @@ rules:
document-start:
present: false
indentation:
check-multi-line-strings: true
check-multi-line-strings: false
indent-sequences: true
spaces: 2
empty-lines:
Expand Down
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ MIN_COVERED_MSI:=88
MIN_MSI:=88

.PHONY: it
it: coding-standards dependency-analysis static-code-analysis tests bench ## Runs the coding-standards, dependency-analysis, static-code-analysis, tests, and bench targets

.PHONY: bench
bench: vendor ## Runs benchmarks with phpbench/phpbench
vendor/bin/phpbench run --report=aggregate
it: coding-standards static-code-analysis tests ## Runs the coding-standards, static-code-analysis, and tests targets

.PHONY: code-coverage
code-coverage: vendor ## Collects coverage from running unit tests with phpunit/phpunit
Expand All @@ -22,7 +18,7 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix

.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.1.0
tools/composer-require-checker check

.PHONY: help
help: ## Displays this list of targets with descriptions
Expand All @@ -38,7 +34,7 @@ static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
mkdir -p .build/phpstan
vendor/bin/phpstan analyse --configuration=phpstan.neon
mkdir -p .build/psalm
vendor/bin/psalm --config=psalm.xml --show-info=false --stats
vendor/bin/psalm --config=psalm.xml --diff --diff-methods --show-info=false --stats --threads=4

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with phpstan/phpstan and vimeo/psalm
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"ergebnis/phpstan-rules": "~0.14.4",
"ergebnis/test-util": "~1.0.0",
"infection/infection": "~0.13.6",
"phpbench/phpbench": "~0.16.10",
"phpstan/extension-installer": "^1.0.4",
"phpstan/phpstan": "~0.12.18",
"phpstan/phpstan-deprecation-rules": "~0.12.2",
Expand Down
Loading