Skip to content

Commit

Permalink
Travis: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vasa-c committed Dec 10, 2015
1 parent ce5c6e9 commit e52858c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ vendor
.idea
phpunit.xml
phpmd.xml
build/*
53 changes: 45 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Travis config for PHP library
#
# Normal build - only phpunit
#
# Build with checks:
# - code sniffer
# - phpunit with coverage
# - sending coverage data to coveralls.io
# Checks are used only for one version (PHP 5.4)

language: php

matrix:
Expand All @@ -6,25 +16,52 @@ matrix:
env: CHECKS=yes
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7
- php: hhvm

sudo: false

before_install:
# Some versions (HHVM for example) may not support XDebug
- XDEBUG_INI=/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- if [ -f $XDEBUG_INI ]; then XDEBUG_ENABLED="yes"; fi;
# Disable xdebug for composer (https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer)
# Do not use `phpenv config-rm` because we need xdebug.ini for enable it for phpunit coverage.
- if [ "$XDEBUG_ENABLED" = "yes" ]; then mv $XDEBUG_INI xdebug.ini; fi;
# Travis container may contain outdated version of composer
- composer self-update
# Checks if the system phpunit is broken (sometimes it happens). Then install phpunit from composer.
- phpunit --version || PHPUNIT_BROKEN="yes"
# Info
- if [ "$CHECKS" = "yes" ]; then echo "Checks mode"; else echo "Normal mode"; fi;
- if [ "$XDEBUG_ENABLED" = "yes" ]; then echo "XDebug is supported"; else echo "XDebug is not supported"; fi;
- if [ "$PHPUNIT_BROKEN" = "yes" ]; then echo "PHPUnit is broken"; else echo "PHPUnit is ok"; fi;

install:
- composer install
- if [ "$CHECKS" = "yes" ]; then composer require satooshi/php-coveralls --dev; fi;
- if [ "$CHECKS" = "yes" ]; then composer require squizlabs/php_codesniffer="~2.3" --dev; fi;
# Composer can not used dist (github required the auth token). Just specify prefer-source.
- composer install --prefer-source
# In order not to litter in the local dev-version specify checks-packages here instead composer.json
- if [ "$PHPUNIT_BROKEN" = "yes" ]; then composer require phpunit/phpunit --prefer-source; fi;
- if [ "$PHPUNIT_BROKEN" = "yes" ]; then PU="php vendor/bin/phpunit"; else PU=phpunit; fi;
- if [ "$CHECKS" = "yes" ]; then composer require squizlabs/php_codesniffer="~2.3" --prefer-source; fi;
- if [ "$CHECKS" = "yes" ]; then composer require satooshi/php-coveralls --dev --prefer-source; fi;
# Generate the coveralls config (not to keep it in the repo)
- >
if [ "$CHECKS" = "yes" ]; then
echo "src_dir: ." > .coveralls.yml &&
echo "json_path: coveralls-upload.json" >> .coveralls.yml &&
echo "coverage_clover: clover.xml" >> .coveralls.yml;
fi;
script:
- if [ "$CHECKS" = "yes" ]; then mkdir -p build/logs; fi;
- if [ "$CHECKS" = "yes" ]; then phpunit --coverage-clover build/logs/clover.xml; else phpunit; fi;
# Normal run - only phpunit
- if [ ! "$CHECKS" = "yes" ]; then $PU; fi;
# Run with checks
- if [ "$CHECKS" = "yes" ]; then php vendor/bin/phpcs --standard=PSR2 --encoding=utf-8 --ignore=vendor .; fi;

after_success:
# Enable xdebug for coverage
- if [ "$CHECKS" = "yes" ] && [ "$XDEBUG_ENABLED" = "yes" ]; then phpenv config-add xdebug.ini; fi;
- if [ "$CHECKS" = "yes" ]; then $PU --coverage-clover clover.xml; fi;
# Coveralls in `script` section instead `after_succes` for build fail if when error
- if [ "$CHECKS" = "yes" ]; then php vendor/bin/coveralls -c .coveralls.yml; fi;

notifications:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Specifying paths within the system.
[![License](https://poser.pugx.org/axy/syspaths/license)](LICENSE)

* The library does not require any dependencies (except composer packages).
* Tested on PHP 5.4+, PHP 7, HHVM (on Linux).
* Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).
* Install: `composer require axy/syspaths`.
* License: [MIT](LICENSE).

Expand Down

0 comments on commit e52858c

Please sign in to comment.