Skip to content

Commit

Permalink
Enhancement: Synchronize project tooling configuration with localhein…
Browse files Browse the repository at this point in the history
…z/php-library-template
  • Loading branch information
localheinz committed Nov 15, 2019
1 parent 14ee994 commit bcc41af
Show file tree
Hide file tree
Showing 16 changed files with 1,464 additions and 313 deletions.
8 changes: 8 additions & 0 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
version: 1

update_configs:
- default_assignees:
- "localheinz"
default_reviewers:
- "localheinz"
directory: "/"
package_manager: "github_actions"
update_schedule: "daily"

- default_assignees:
- "localheinz"
default_reviewers:
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ trim_trailing_whitespace = true
[*.json]
indent_size = 2

[*.neon]
indent_style = tab

[*.yml]
indent_size = 2

Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/infection.json export-ignore
/Makefile export-ignore
/phpbench.json export-ignore
/phpstan.neon export-ignore
16 changes: 15 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ $ make cs

to automatically fix coding standard violations.

## Static Code Analysis

We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) to statically analyze the code.

Run

```
$ make stan
```

to run a static code analysis.

## Tests

We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development.
Expand Down Expand Up @@ -48,7 +60,9 @@ Run
$ make
```

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

## Help

:bulb: Run

Expand Down
29 changes: 15 additions & 14 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ branches:
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"
- "Coding Standards"
- "Static Code Analysis"
- "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

Expand Down
97 changes: 84 additions & 13 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
- pull_request
- push
pull_request:
push:
branches:
- master
tags:
- "**"

name: "Continuous Integration"

Expand All @@ -14,16 +18,58 @@ jobs:

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

- name: "Disable Xdebug"
run: php7.1 --ini | grep xdebug | sed 's/,$//' | xargs sudo rm

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

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1.0.0
with:
path: ~/.composer/cache
key: php7.1-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php7.1-composer-locked-
- name: "Install locked dependencies with composer"
run: php7.1 $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Run localheinz/composer-normalize"
uses: docker://localheinz/composer-normalize-action:0.5.2
with:
args: --dry-run

- 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
run: php7.1 vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --using-cache=no --verbose

static-code-analysis:
name: "Static Code Analysis"

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v1.1.0

- name: "Disable Xdebug"
run: php7.3 --ini | grep xdebug | sed 's/,$//' | xargs sudo rm

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1.0.0
with:
path: ~/.composer/cache
key: php7.3-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php7.3-composer-locked-
- name: "Install locked dependencies with composer"
run: php7.3 $(which composer) install --no-interaction --no-progress --no-suggest

- name: "Run phpstan/phpstan"
run: php7.3 vendor/bin/phpstan analyse --configuration=phpstan.neon

tests:
name: "Tests"
Expand All @@ -33,7 +79,6 @@ jobs:
strategy:
matrix:
php-binary:
- php7.1
- php7.2
- php7.3

Expand All @@ -44,7 +89,18 @@ jobs:

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

- name: "Disable Xdebug"
run: ${{ matrix.php-binary }} --ini | grep xdebug | sed 's/,$//' | xargs sudo rm

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1.0.0
with:
path: ~/.composer/cache
key: ${{ matrix.php-binary }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ matrix.php-binary }}-composer-${{ matrix.dependencies }}-
- name: "Install lowest dependencies with composer"
if: matrix.dependencies == 'lowest'
Expand All @@ -71,7 +127,15 @@ jobs:

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

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1.0.0
with:
path: ~/.composer/cache
key: php7.3-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php7.3-composer-locked-
- name: "Install locked dependencies with composer"
run: php7.3 $(which composer) install --no-interaction --no-progress --no-suggest
Expand All @@ -82,11 +146,10 @@ jobs:
- 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 }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash)

mutation-tests:
name: "Mutation Tests"
Expand All @@ -95,10 +158,18 @@ jobs:

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

- name: "Cache dependencies installed with composer"
uses: actions/cache@v1.0.0
with:
path: ~/.composer/cache
key: php7.3-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: |
php7.3-composer-locked-
- 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
run: php7.3 vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=92 --min-msi=92
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

For a full diff see [`2.0.1...master`](https://github.com/localheinz/json-printer/compare/2.0.1...master).
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: bench coverage cs help infection it test
.PHONY: bench coverage cs help infection it stan test

it: cs test bench ## Runs the cs, test, and bench targets
it: cs stan test ## Runs the cs, stan, and test targets

bench: vendor
bench: vendor ## Runs benchmarks with phpbench
vendor/bin/phpbench run --report=aggregate

coverage: vendor ## Collects coverage from running unit tests with phpunit
Expand All @@ -19,9 +19,13 @@ help: ## Displays this list of targets with descriptions

infection: vendor ## Runs mutation tests with infection
mkdir -p .build/infection
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=80 --min-msi=80
vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=92 --min-msi=92

test: vendor ## Runs auto-review and unit tests with phpunit
stan: vendor ## Runs a static analysis with phpstan
mkdir -p .build/phpstan
vendor/bin/phpstan analyse --configuration=phpstan.neon

test: vendor ## Runs auto-review, unit, and integration tests with phpunit
mkdir -p .build/phpunit
vendor/bin/phpunit --configuration=test/AutoReview/phpunit.xml
vendor/bin/phpunit --configuration=test/Unit/phpunit.xml
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# json-printer

[![Continuous Integration Status](https://github.com/localheinz/json-printer/workflows/Continuous%20Integration/badge.svg)](https://github.com/localheinz/json-printer/actions)
[![Continuous Integration](https://github.com/localheinz/json-printer/workflows/Continuous%20Integration/badge.svg)](https://github.com/localheinz/json-printer/actions)
[![codecov](https://codecov.io/gh/localheinz/json-printer/branch/master/graph/badge.svg)](https://codecov.io/gh/localheinz/json-printer)
[![Latest Stable Version](https://poser.pugx.org/localheinz/json-printer/v/stable)](https://packagist.org/packages/localheinz/json-printer)
[![Total Downloads](https://poser.pugx.org/localheinz/json-printer/downloads)](https://packagist.org/packages/localheinz/json-printer)
Expand Down Expand Up @@ -69,6 +69,10 @@ which results in `$printed`:
:bulb: Note that this printer is only concerned with normalizing the
indentation, no escaping or un-escaping occurs.

## Changelog

Please have a look at [`CHANGELOG.md`](CHANGELOG.md).

## Contributing

Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md).
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
"php": "^7.1"
},
"require-dev": {
"infection/infection": "~0.8.1",
"localheinz/php-cs-fixer-config": "~1.23.0",
"infection/infection": "~0.13.6",
"localheinz/php-cs-fixer-config": "~1.24.0",
"localheinz/phpstan-rules": "~0.13.0",
"localheinz/test-util": "~0.7.0",
"phpbench/phpbench": "~0.14.0",
"phpunit/phpunit": "^7.5.16"
"phpbench/phpbench": "~0.16.10",
"phpstan/phpstan": "~0.11.19",
"phpstan/phpstan-deprecation-rules": "~0.11.2",
"phpstan/phpstan-strict-rules": "~0.11.1",
"phpunit/phpunit": "^7.5.17"
},
"config": {
"preferred-install": "dist",
Expand Down
Loading

0 comments on commit bcc41af

Please sign in to comment.