Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Last active December 6, 2019 11:56
Show Gist options
  • Save khaosdoctor/5f6989c4fc27ecc03955 to your computer and use it in GitHub Desktop.
Save khaosdoctor/5f6989c4fc27ecc03955 to your computer and use it in GitHub Desktop.
Travis CI Example for a PHP Application with Coveralls integration
# Set folder to clover (must be the same on travis)
coverage_clover: build/logs/clover.xml
# Same folder here
json_path: build/logs/coveralls-upload.json
# Don't touch that
service_name: travis-ci
# This needs a travis file: https://gist.github.com/khaosdoctor/5f6989c4fc27ecc03955
# Set language
language: php
# Set php versions we can work with
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
# Thing to install before the actual building process
install:
- composer self-update # This should not be required, but it is always a good practice to update composer
- composer install
- composer require satooshi/php-coveralls:~1.0@stable # Require phpCoveralls
# Run before the build
before_script:
- mkdir -p build/logs # Create a folder to store clover files
# Set list of allowed build failures
matrix:
allow_failures:
- php: 5.4 # Too Old
- php: 7.0 # Too New
- php: hhvm # Too unstable
# Build Script. Notice: We are demanding unit to generate a clover file to our previously created folder
script:
# Syntax: phpunit --coverage-clover <folder>/<name>.xml --text-suffix .php [--colors] [--report-useless-tests] <tests location>.php
- phpunit --coverage-clover build/logs/clover.xml --test-suffix .php --colors --report-useless-tests tests/test.php
# After success, run sh to bind coveralls
after_success:
- sh -c 'if( [ "$TRAVIS_PHP_VERSION" != "hhvm" ] ); then php vendor/bin/coveralls -v; fi;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment