Skip to content
This repository has been archived by the owner on Aug 21, 2021. It is now read-only.

Enable Travis linting #3

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
language: php

sudo: false

matrix:
include:
- php: 7.2
- php: 7.1
env: deps='dev'
- php: 7.1
env: deps='low'
# XXX This needs proper fixing
# - php: 7.1
# env: lint=1
env: lint=1
sudo: required
services:
- docker
addons:
apt:
packages:
- docker-ce

fast_finish: true

cache:
Expand All @@ -21,9 +24,6 @@ cache:
before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.3.2/php-cs-fixer.phar; fi
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
Expand All @@ -38,5 +38,4 @@ script:
export SYMFONY_DEPRECATIONS_HELPER=strict
fi
- if [[ ! $lint ]]; then vendor/bin/phpunit --verbose; fi
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi
- if [[ $lint = 1 ]]; then phpstan analyse -c phpstan.neon -l5 --ansi src tests; fi
- if [[ $lint = 1 ]]; then make ci; fi
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
QA_DOCKER_IMAGE=jakzal/phpqa:1.23-alpine
QA_DOCKER_COMMAND=docker run -it --rm -v "$(shell pwd):/project" -w /project ${QA_DOCKER_IMAGE}

ci: cs-full-check phpstan
lint: cs-full-check phpstan

phpstan:
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon --level 6 ."

cs:
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"

cs-full:
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff"

cs-full-check:
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run"

in-docker-install-dev:
rm -f composer.lock
cp composer.json _composer.json
composer.phar config minimum-stability dev
composer.phar update --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi
mv _composer.json composer.json

.PHONY: phpstan cs cs-full cs-full-checks
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
parameters:
autoload_files:
- vendor/autoload.php
excludes_analyse:
- vendor/
- %currentWorkingDirectory%/tests/**

ignoreErrors:
# Tests
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
#- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
#- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy::\$[a-zA-Z0-9_]+#'
#- '#Call to an undefined method PHPUnit_Framework_MockObject_MockObject::[a-zA-Z0-9_]+\(\)#'
#- '#expects\s+[^\s]+, PHPUnit_Framework_MockObject_MockObject(\[\])? given#'
Expand Down