Skip to content

Commit

Permalink
Merge pull request #51 from localheinz/feature/synchronize
Browse files Browse the repository at this point in the history
Enhancement: Synchronize project tooling configuration with localheinz/php-library-template
  • Loading branch information
localheinz committed Oct 6, 2019
2 parents 4862b71 + ef5ccce commit 970e9af
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 206 deletions.
13 changes: 13 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://dependabot.com/docs/config-file/

version: 1

update_configs:
- default_assignees:
- "localheinz"
default_reviewers:
- "localheinz"
directory: "/"
package_manager: "php:composer"
update_schedule: "live"
version_requirement_updates: "increase_versions"
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ trim_trailing_whitespace = true
[*.json]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

Expand Down
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/.dependabot/ export-ignore
/.github/ export-ignore
/.travis/ export-ignore
/test/ export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.travis.yml export-ignore
/infection.json export-ignore
/Makefile export-ignore
/phpbench.json export-ignore
38 changes: 29 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# CONTRIBUTING

We're using [Travis CI](https://travis-ci.com) as a continuous integration system.
We are using [GitHub Actions](https://github.com/features/actions) as a continuous integration system.

For details, see [`.travis.yml`](../.travis.yml).
For details, see [`workflows/continuous-integration.yml`](workflows/continuous-integration.yml).

## Coding Standards

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

Run

```
$ make cs
```

to automatically fix coding standard violations.

## Tests

We're using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development.
We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development.

Run

Expand All @@ -16,17 +28,17 @@ $ make test

to run all the tests.

## Coding Standards
## Mutation Tests

We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards.
We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Run
Enable `Xdebug` and run

```
$ make cs
$ make infection
```

to automatically fix coding standard violations.
to run mutation tests.

## Extra lazy?

Expand All @@ -36,4 +48,12 @@ Run
$ make
```

to run both coding standards check and tests!
to enforce coding standards and run tests!

:bulb: Run

```
$ make help
```

to display a list of available targets with corresponding descriptions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
custom: https://www.buymeacoffee.com/localheinz
github: localheinz
patreon: localheinz
61 changes: 61 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# https://github.com/probot/settings

branches:
- name: master
protection:
enforce_admins: false
required_pull_request_reviews:
dismiss_stale_reviews: true
require_code_owner_reviews: true
required_approving_review_count: 1
required_status_checks:
contexts:
- "Coding Standards"
- "Tests (php7.1, lowest)"
- "Tests (php7.1, locked)"
- "Tests (php7.1, highest)"
- "Tests (php7.2, lowest)"
- "Tests (php7.2, locked)"
- "Tests (php7.2, highest)"
- "Tests (php7.3, lowest)"
- "Tests (php7.3, locked)"
- "Tests (php7.3, highest)"
- "Code Coverage"
- "Mutation Tests"
- "codecov/patch"
- "codecov/project"
strict: false
restrictions: null

labels:
- name: bug
color: ee0701

- name: dependencies
color: 0366d6

- name: enhancement
color: 0e8a16

- name: question
color: cc317c

- name: security
color: ee0701

- name: stale
color: eeeeee

repository:
allow_merge_commit: true
allow_rebase_merge: false
allow_squash_merge: false
default_branch: master
description: ":page_with_curl: Provides a JSON printer, allowing for flexible indentation."
has_downloads: true
has_issues: true
has_pages: false
has_projects: false
has_wiki: false
name: json-printer
private: false
104 changes: 104 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
- pull_request
- push

name: "Continuous Integration"

jobs:
coding-standards:
name: "Coding Standards"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@master

- name: "Validate composer.json and composer.lock"
run: php7.1 $(which composer) validate --strict

- name: "Install locked dependencies with composer"
run: php7.1 $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Run friendsofphp/php-cs-fixer"
run: php7.1 vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --using-cache=no --verbose

tests:
name: "Tests"

runs-on: ubuntu-latest

strategy:
matrix:
php-binary:
- php7.1
- php7.2
- php7.3

dependencies:
- lowest
- locked
- highest

steps:
- name: "Checkout"
uses: actions/checkout@master

- name: "Install lowest dependencies with composer"
if: matrix.dependencies == 'lowest'
run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest --prefer-lowest

- name: "Install locked dependencies with composer"
if: matrix.dependencies == 'locked'
run: ${{ matrix.php-binary }} $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Install highest dependencies with composer"
if: matrix.dependencies == 'highest'
run: ${{ matrix.php-binary }} $(which composer) update --no-interaction --no-progress --no-suggest

- name: "Run auto-review tests with phpunit/phpunit"
run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml

- name: "Run unit tests with phpunit/phpunit"
run: ${{ matrix.php-binary }} vendor/bin/phpunit --configuration=test/Unit/phpunit.xml

code-coverage:
name: "Code Coverage"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@master

- name: "Install locked dependencies with composer"
run: php7.3 $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Dump Xdebug filter with phpunit/phpunit"
run: php7.3 vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --dump-xdebug-filter=.build/phpunit/xdebug-filter.php

- name: "Collect code coverage with Xdebug and phpunit/phpunit"
run: php7.3 vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml --prepend=.build/phpunit/xdebug-filter.php

- name: "Download code coverage uploader for Codecov.io"
run: curl -s https://codecov.io/bash -o codecov

- name: "Send code coverage report to Codecov.io"
run: bash codecov -t ${{ secrets.CODECOV_TOKEN }}

mutation-tests:
name: "Mutation Tests"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@master

- name: "Install locked dependencies with composer"
run: php7.3 $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Run mutation tests with infection/infection"
run: php7.3 vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=80 --min-msi=80
27 changes: 27 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# https://github.com/actions/stale

name: "Close stale issues and pull requests"

on:
schedule:
- cron: "0 * * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 60
days-before-close: 5
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-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'
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/.build/
/vendor/
/.php_cs.cache
/infection-log.txt
29 changes: 23 additions & 6 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2018 Andreas M枚ller
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/localheinz/json-printer
*/

use Localheinz\PhpCsFixer\Config;

$header = <<<EOF
$header = <<<'EOF'
Copyright (c) 2018 Andreas M枚ller
For the full copyright and license information, please view
Expand All @@ -16,10 +27,16 @@ $config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header), [
'mb_str_functions' => false,
]);

$config->getFinder()->in(__DIR__);

$cacheDir = \getenv('TRAVIS') ? \getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');
$config->getFinder()
->ignoreDotFiles(false)
->in(__DIR__)
->exclude([
'.build',
'.dependabot',
'.github',
])
->name('.php_cs');

$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php_cs.cache');

return $config;
Loading

0 comments on commit 970e9af

Please sign in to comment.