Skip to content

Commit

Permalink
Merge pull request #52 from lcobucci/improve-ci-and-tooling
Browse files Browse the repository at this point in the history
Improve CI and tooling
  • Loading branch information
lcobucci authored Jul 2, 2020
2 parents 0b375f5 + fa39dd0 commit 66c6d8e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
20 changes: 9 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/templates export-ignore
/tests 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
/.github export-ignore
/templates export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.*.yml export-ignore
/*.dist export-ignore
/Makefile export-ignore
/README.md export-ignore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/vendor/
/composer.lock
/.phpcs.cache
/infection-log.txt
/infection.log
/.phpunit.result.cache
23 changes: 14 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist: trusty
sudo: false
os: linux
dist: bionic
language: php

php:
Expand All @@ -12,12 +12,17 @@ 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
install:
- |
if [ $TRAVIS_PHP_VERSION = 'nightly' ]; then
travis_retry travis_retry make vendor EXTRA_FLAGS="--ignore-platform-reqs";
else
travis_retry travis_retry make vendor;
fi
script:
- ./vendor/bin/phpunit
- make unit-test

jobs:
allow_failures:
Expand All @@ -30,25 +35,25 @@ jobs:
- 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
- make unit-test EXTRA_FLAGS="--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
- make coding-standard

- stage: Code Quality
env: STATIC_ANALYSIS=1
script:
- ./vendor/bin/phpstan analyse
- make static-analysis

- 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=$(nproc) --min-msi=100 --min-covered-msi=100
- make mutation-test
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
MIN_MSI=100
MIN_COVERED_MSI=100

ifeq ("${CI}", "true")
PARALLELISM=4
else
PARALLELISM=$(shell nproc)
endif

.PHONY: valid test coding-standard-fix coding-standard static-analysis unit-test mutation-test

valid: coding-standard-fix coding-standard static-analysis test

test: unit-test mutation-test

vendor: composer.json
composer install $(EXTRA_FLAGS)
@touch -c vendor

coding-standard: vendor
vendor/bin/phpcs --parallel=$(PARALLELISM)

coding-standard-fix: vendor
vendor/bin/phpcbf --parallel=$(PARALLELISM) || true

static-analysis: vendor
vendor/bin/phpstan analyse $(EXTRA_FLAGS)

unit-test: vendor
vendor/bin/phpunit --testsuite unit --stop-on-error --stop-on-failure $(EXTRA_FLAGS)

mutation-test: vendor
vendor/bin/infection --no-progress -j=$(PARALLELISM) -s --min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) $(EXTRA_FLAGS)
2 changes: 1 addition & 1 deletion infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"directories": ["src"]
},
"logs": {
"text": "infection-log.txt"
"text": "infection.log"
}
}

0 comments on commit 66c6d8e

Please sign in to comment.