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

Merged
merged 1 commit into from
May 10, 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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +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
/phive.xml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/psalm-baseline.xml export-ignore
Expand Down
3 changes: 3 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ For details, take a look at the following workflow configuration files:
- [`workflows/prune.yaml`](workflows/prune.yaml)
- [`workflows/release.yaml`](workflows/release.yaml)
- [`workflows/renew.yaml`](workflows/renew.yaml)
- [`workflows/triage.yaml`](workflows/triage.yaml)

## Coding Standards

We are using [`ergebnis/composer-normalize`](https://github.com/ergebnis/composer-normalize) to normalize `composer.json`.

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
Expand Down
20 changes: 10 additions & 10 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ branches:
required_approving_review_count: 1
required_status_checks:
contexts:
- "Code Coverage (7.4, locked)"
- "Coding Standards (7.1, locked)"
- "Dependency Analysis (7.4, locked)"
- "Mutation Tests (7.4, locked)"
- "Static Code Analysis (7.4, locked)"
- "Tests (7.1, lowest)"
- "Tests (7.1, locked)"
- "Tests (7.1, highest)"
- "Tests (7.2, lowest)"
- "Tests (7.2, locked)"
- "Tests (7.1, locked)"
- "Tests (7.1, lowest)"
- "Tests (7.2, highest)"
- "Tests (7.3, lowest)"
- "Tests (7.3, locked)"
- "Tests (7.2, locked)"
- "Tests (7.2, lowest)"
- "Tests (7.3, highest)"
- "Tests (7.4, lowest)"
- "Tests (7.4, locked)"
- "Tests (7.3, locked)"
- "Tests (7.3, lowest)"
- "Tests (7.4, highest)"
- "Code Coverage (7.4, locked)"
- "Mutation Tests (7.4, locked)"
- "Tests (7.4, locked)"
- "Tests (7.4, lowest)"
strict: false
restrictions:

Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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 @@ -169,8 +169,8 @@ jobs:
uses: "actions/cache@v1"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "${{ matrix.php-version }}-composer-locked-"
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'"
Expand Down Expand Up @@ -424,9 +424,6 @@ jobs:
reviewers: reviewers,
})

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

- name: "Assign @ergebnis-bot"
uses: "actions/[email protected]"
with:
Expand All @@ -446,9 +443,6 @@ jobs:
repo: repository.repo,
})

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

- name: "Approve pull request"
uses: "actions/[email protected]"
if: "github.actor != 'ergebnis-bot'"
Expand All @@ -465,9 +459,6 @@ jobs:
repo: repository.repo,
})

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

- name: "Merge pull request"
uses: "actions/[email protected]"
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: "Prune issues and pull requests"
uses: "actions/stale@v1"
uses: "actions/stale@v2"
with:
days-before-close: 5
days-before-stale: 60
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/triage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Triage"

on: # yamllint disable-line rule:truthy
pull_request: null

jobs:
label:
name: "Label"

runs-on: "ubuntu-latest"

steps:
- name: "Add labels based on branch name"
if: "github.event.action == 'opened'"
uses: "actions/[email protected]"
with:
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
script: |
const branchPrefixLabels = {
feature: "enhancement",
fix: "bug",
}

const pullRequest = context.payload.pull_request
const repository = context.repo

const branchName = pullRequest.head.ref

const matches = branchName.match(new RegExp('^([^/]+)\/'));

if (matches instanceof Array && branchPrefixLabels.hasOwnProperty(matches[1])) {
const label = branchPrefixLabels[matches[1]]

github.issues.addLabels({
issue_number: pullRequest.number,
labels: [
label
],
owner: repository.owner,
repo: repository.repo,
});
}
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ code-coverage: vendor ## Collects coverage from running unit tests with phpunit/
vendor/bin/phpunit --configuration=test/Integration/phpunit.xml --coverage-text --prepend=.build/phpunit/xdebug-filter.php

.PHONY: coding-standards
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
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
composer normalize
yamllint -c .yamllint.yaml --strict .
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
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 Down Expand Up @@ -54,4 +56,3 @@ tests: vendor ## Runs auto-review, unit, and integration tests with phpunit/phpu
vendor: composer.json composer.lock
composer validate --strict
composer install --no-interaction --no-progress --no-suggest
composer normalize
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,7 @@ Please have a look at [`LICENSE.md`](LICENSE.md).
## Credits

The method [`FinalRule::isWhitelistedClass()`](src/Classes/FinalRule.php) is inspired by the work on [`FinalClassFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.15/src/Fixer/ClassNotation/FinalClassFixer.php) and [`FinalInternalClassFixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/2.15/src/Fixer/ClassNotation/FinalInternalClassFixer.php), contributed by [Dariusz Rumiński](https://github.com/keradus), [Filippo Tessarotto](https://github.com/Slamdunk), and [Spacepossum](https://github.com/SpacePossum) for [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (originally licensed under MIT).

## Curious what I am building?

:mailbox_with_mail: [Subscribe to my list](https://localheinz.com/projects/), and I will occasionally send you an email to let you know what I am working on.
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>
Binary file added tools/composer-require-checker
Binary file not shown.