Skip to content

Commit

Permalink
Merge pull request #52 from koriym/update-package
Browse files Browse the repository at this point in the history
Update package and CI files
  • Loading branch information
koriym authored Oct 15, 2020
2 parents 158e0a9 + 50f4d04 commit 7b58ccc
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 238 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/vendor/
/build/
/.idea/

/composer.lock
/phpunit.xml
/.phpunit.result.cache
/.php_cs.cache
185 changes: 0 additions & 185 deletions .php_cs.dist

This file was deleted.

2 changes: 0 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
filter:
paths: ["src/*"]
tools:
external_code_coverage: true
php_code_coverage: true
php_sim: true
php_pdepend: true
php_analyzer: true
Expand Down
57 changes: 53 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,68 @@
language: php

os: linux

dist: bionic

php:
- 7.2
- 7.3
- 7.4

cache:
directories:
- vendor
- ./vendor
- $HOME/.composer/cache

before_install:
- phpenv config-rm xdebug.ini || true
- composer self-update

install:
- composer install

before_script:

script:
- ./vendor/bin/phpunit --coverage-clover=coverage.clover
- ./vendor/bin/phpunit;

jobs:
fast_finish: true
allow_failures:
- php: nightly
include:
- stage: Test
name: Lowest dependencies
php: 7.4
install: composer update --prefer-dist --prefer-lowest

- stage: Test
name: Nightly
php: nightly
install: composer update --ignore-platform-reqs

- stage: Code Quality
name: Code coverage
php: 7.4
before_script:
- pecl install pcov
script:
- ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml --coverage-text
after_success:
- bash <(curl -s https://codecov.io/bash) -cF php

- stage: Code Quality
name: Static analysis
php: 7.4
install: composer global require --dev phpstan/phpstan ^0.12 vimeo/psalm ^3.11 phpmetrics/phpmetrics ^2.6 maglnet/composer-require-checker ^2.0
script:
- ~/.composer/vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction
- ~/.composer/vendor/bin/psalm --show-info=false --shepherd
- ~/.composer/vendor/bin/psalm -c psalm.compiler.xml --show-info=true
- ~/.composer/vendor/bin/phpmetrics --exclude=Exception src
- ~/.composer/vendor/bin/composer-require-checker check ./composer.json

- stage: Code Quality
name: Coding standards
php: 7.4
install: composer global require --dev doctrine/coding-standard ^8.1
script:
- ~/.composer/vendor/bin/phpcs --standard=./phpcs.xml src tests
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ This repository contains a single-line command that will automatically setup for

It will automatically install the following dependencies:

* PHPUnit: run your unit tests.
* PHP_CodeSniffer: validate your code against code convention.
* PHP CS Fixer: automatically fix your code to match the code convention.
* PHPMD: analyze your code to detect sub-optimal or overly complex code.
* PHPStan: analyze your code without running it to find bugs even before you write tests for the code.
* Psalm: another static analysis tool from Vimeo.
* [PHPUnit](https://phpunit.readthedocs.io/ja/latest/): provides testing framework.
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/wiki): detects violations of a defined set of coding standards.
* [PHPMD](https://phpmd.org): analyze your code to detect sub-optimal or overly complex code.
* [PHPStan](https://phpmd.org): discover bugs in your code without running it.
* [Psalm](https://psalm.dev): - another static analysis tool from Vimeo.
* [PHPMetrics](https://www.phpmetrics.org) provides various metrics.

As well as config file for popular continuous integration tool.

Expand Down Expand Up @@ -54,16 +54,23 @@ Once installed, the project will automatically be configured so you can run thos

### tests

`composer tests` run [`phpcs`](https://github.com/squizlabs/PHP_CodeSniffer), [`php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer), [`phpmd`](https://github.com/phpmd/phpmd), [`phpstan`](https://github.com/phpstan/phpstan),[`psalm`](https://psalm.dev) and [`phpunit`](https://github.com/sebastianbergmann/phpunit).
`composer tests` run `cs`, `sa`, and `test`.

### coverage
### coverage, pcov

`composer coverage` builds test coverage report.
`composer coverage` builds test coverage report. `coverage` use XDebug, `pcov` use [pcov](https://github.com/krakjoe/pcov).

### cs-fix
### cs, cs-fix

`composer cs-fix` run [`php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) and [`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically) to fix up the PHP code to follow the coding standards. (Check only command `compposer cs` is also available.)
`composer cs` checks coding standard. `composer cs-fix` fix up the PHP code.

### sa

`composer sa` run static code analysis tools. (phpstan and psalm)

### metrics

`composer metrics` reports code [metrics](https://www.phpmetrics.org).

## Setup continuous integration

Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
codecov:
notify:
require_ci_to_pass: yes

coverage:
status:
project:
default:
target: 100%
patch:
default:
target: 100%

comment: false
21 changes: 12 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
}
],
"require": {
"php": ">=7.2.0"
"php": "^7.2 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5",
"friendsofphp/php-cs-fixer": "^2.16",
"phpmd/phpmd": "^2.8",
"phpmd/phpmd": "^2.9",
"phpstan/phpstan" : "^0.12",
"vimeo/psalm": "^3.8",
"phpmetrics/phpmetrics": "^2.6"
"vimeo/psalm": "^3.17",
"phpmetrics/phpmetrics": "^2.7",
"doctrine/coding-standard": "^8.1"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -56,10 +56,13 @@
"./vendor/bin/psalm --init"
],
"test": ["vendor/bin/phpunit"],
"tests": ["@cs", "./vendor/bin/phpmd src,tests text ./phpmd.xml", "./vendor/bin/phpstan analyse -c phpstan.neon --no-progress", "./vendor/bin/psalm", "@test"],
"tests": ["@cs", "@sa", "@test"],
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"cs": ["./vendor/bin/php-cs-fixer fix -v --dry-run", "./vendor/bin/phpcs --standard=phpcs.xml src;"],
"cs-fix": ["./vendor/bin/php-cs-fixer fix -v", "./vendor/bin/phpcbf src tests"],
"metrics": ["phpmetrics --report-html=build/metrics --excluded-dirs=src/Exception src"]
"pcov": ["php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml"],
"cs": ["./vendor/bin/phpcs --standard=phpcs.xml src tests"],
"cs-fix": ["./vendor/bin/phpcbf src tests"],
"sa": ["phpstan analyse -c phpstan.neon", "psalm --show-info=true"],
"metrics": ["phpmetrics --report-html=build/metrics --excluded-dirs=src/Exception src"],
"build": ["@cs", "@sa", "@pcov","@metrics"]
}
}
Loading

0 comments on commit 7b58ccc

Please sign in to comment.