diff --git a/.gitattributes b/.gitattributes index 73be232a..01cea47b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,9 @@ -/.gitattributes export-ignore -/.gitignore export-ignore -/README.md export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/infection.json.dist export-ignore +/phpcs.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore +/README.md export-ignore diff --git a/.gitignore b/.gitignore index 4fbb073c..95bdd5e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor/ /composer.lock +/.phpcs.cache +/infection-log.txt diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..25196c66 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,38 @@ +build: + environment: + mysql: false + postgresql: false + redis: false + rabbitmq: false + mongodb: false + php: + version: 7.2 + + cache: + disabled: false + directories: + - ~/.composer/cache + + dependencies: + override: + - composer install --no-interaction --prefer-dist + + nodes: + analysis: + project_setup: + override: true + tests: + override: + - php-scrutinizer-run + - phpcs-run + +checks: + php : true + +tools: + external_code_coverage: true + +build_failure_conditions: + - 'elements.rating(<= C).new.exists' + - 'issues.severity(>= MAJOR).new.exists' + - 'project.metric_change("scrutinizer.test_coverage", < -0.01)' diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..442449f7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,54 @@ +dist: trusty +sudo: false +language: php + +php: + - 7.2 + - nightly + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" + - composer self-update + +install: travis_retry composer install + +script: + - ./vendor/bin/phpunit + +jobs: + allow_failures: + - php: nightly + + include: + - stage: Code Quality + env: TEST_COVERAGE=1 + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/phpunit --coverage-clover ./clover.xml + after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover ./clover.xml + + - stage: Code Quality + env: CODE_STANDARD=1 + script: + - ./vendor/bin/phpcs + + - stage: Code Quality + env: STATIC_ANALYSIS=1 + script: + - ./vendor/bin/phpstan analyse + + - stage: Code Quality + env: MUTATION_TESTS=1 + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for mutation tests"; exit 1; fi + script: + - ./vendor/bin/infection --threads=4 --min-msi=100 --min-covered-msi=100 diff --git a/composer.json b/composer.json index 716dc5bb..ea019a71 100644 --- a/composer.json +++ b/composer.json @@ -22,5 +22,14 @@ "php": "^7.2", "fig/http-message-util": "^1.1", "psr/http-server-middleware": "^1.0" + }, + "require-dev": { + "doctrine/coding-standard": "^4.0", + "infection/infection": "^0.8", + "phpstan/phpstan": "^0.10@dev", + "phpstan/phpstan-phpunit": "^0.10@dev", + "phpstan/phpstan-strict-rules": "^0.10@dev", + "phpunit/phpunit": "^7.0", + "squizlabs/php_codesniffer": "^3.2" } } diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 00000000..398b4ae4 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,9 @@ +{ + "timeout": 1, + "source": { + "directories": ["src"] + }, + "logs": { + "text": "infection-log.txt" + } +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..baa7a2d3 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,28 @@ + + + + + + + + + + src + tests + + + + + + + + + + + + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..7af1f41d --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,9 @@ +includes: + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-strict-rules/rules.neon + +parameters: + level: 7 + paths: + - src + - tests diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..c681944b --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + tests + + + + + + src + + +