Skip to content

Commit

Permalink
Enhancement: Synchronize with ergebnis/php-library-template
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Apr 11, 2020
1 parent 4f20857 commit fc02cc8
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 37 deletions.
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ indent_size = 2
[*.neon]
indent_style = tab

[*.yaml]
[*.{yaml,yml}]
indent_size = 2

[Makefile]
Expand Down
14 changes: 12 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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 @@ -78,7 +88,7 @@ Run
$ make
```

to enforce coding standards, run a dependency analysis, run a static code analysis, and run tests!
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)"
- "Compile Phar (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
126 changes: 109 additions & 17 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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: "Install lowest dependencies from composer.json"
Expand All @@ -82,7 +82,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 @@ -120,7 +120,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: "Install lowest dependencies from composer.json"
Expand Down Expand Up @@ -172,7 +172,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: "Install lowest dependencies from composer.json"
Expand All @@ -190,14 +190,28 @@ jobs:
- 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-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-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: "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 @@ -236,7 +250,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: "Install lowest dependencies from composer.json"
Expand Down Expand Up @@ -292,7 +306,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: "Install lowest dependencies from composer.json"
Expand Down Expand Up @@ -353,7 +367,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: "Install lowest dependencies from composer.json"
Expand Down Expand Up @@ -389,8 +403,8 @@ jobs:
- name: "Run composer-normalize.phar with argument and options"
run: "${{ env.COMPOSER_NORMALIZE_PHAR }} --dry-run composer.json"

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

runs-on: "ubuntu-latest"

Expand All @@ -402,15 +416,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 @@ -74,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/[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,4 +1,5 @@
/.build/
/.notes/
/phar/resource/
/phar/src/
/phar/vendor/
Expand Down
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/',
])
->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
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
COMPOSER_VERSION:=1.10.1

.PHONY: it
it: coding-standards dependency-analysis static-code-analysis tests ## Runs the coding-standards, dependency-analysis, static-code-analysis, and tests targets
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 integration tests with phpunit/phpunit
Expand Down Expand Up @@ -38,13 +38,12 @@ 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
mkdir -p .build/phpstan
echo '' > phpstan-baseline.neon
vendor/bin/phpstan analyze --configuration=phpstan.neon --error-format=baselineNeon > phpstan-baseline.neon || true
vendor/bin/phpstan analyze --configuration=phpstan.neon --generate-baseline=phpstan-baseline.neon
mkdir -p .build/psalm
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml

Expand Down
4 changes: 4 additions & 0 deletions phive.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-require-checker" version="^2.1.0" installed="2.1.0" location="./tools/composer-require-checker" copy="true"/>
</phive>
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ parameters:
paths:
- src/
- test/
tmpDir: %currentWorkingDirectory%/.build/phpstan/
tmpDir: .build/phpstan/
3 changes: 1 addition & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.9.5@0cfe565d0afbcd31eadcc281b9017b5692911661">
<files psalm-version="3.10.1@eeed5ecccc10131397f0eb7ee6da810c0be3a7fc">
<file src="src/Application.php">
<PropertyNotSetInConstructor occurrences="1">
<code>Application</code>
Expand Down Expand Up @@ -64,7 +64,6 @@
<code>\Generator&lt;array{0: CommandInvocation, 1: string}&gt;</code>
<code>\Generator&lt;array{0: CommandInvocation, 1: int, 2: string}&gt;</code>
</MixedInferredReturnType>
<NonStaticSelfCall occurrences="3"/>
</file>
<file src="test/Util/File.php">
<PropertyNotSetInConstructor occurrences="1">
Expand Down
Binary file added tools/composer-require-checker
Binary file not shown.

0 comments on commit fc02cc8

Please sign in to comment.