Git Product home page Git Product logo

php-coveralls's Introduction

php-coveralls

Static Code Analysis CI Coverage Status

Latest Stable Version Total Downloads

PHP client library for Coveralls.

Prerequisites

Installation

Download phar file

We started to create a phar file, starting from the version 0.7.0 release. It is available at the URLs like:

https://github.com/php-coveralls/php-coveralls/releases/download/v2.7.0/php-coveralls.phar

Download the file and add exec permissions:

$ wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.7.0/php-coveralls.phar
$ chmod +x php-coveralls.phar

Install by composer

To install php-coveralls with Composer, run the following command:

$ composer require --dev php-coveralls/php-coveralls

If you need support for PHP versions older than 5.5, you will need to use a 1.x version:

$ composer require --dev 'php-coveralls/php-coveralls:^1.1'

You can see this library on Packagist.

Composer installs autoloader at ./vendor/autoloader.php. If you use php-coveralls in your php script, add:

require_once 'vendor/autoload.php';

If you use Symfony2, autoloader has to be detected automatically.

Use it from your git clone

Or you can use git clone command:

# HTTP
$ git clone https://github.com/php-coveralls/php-coveralls.git
# SSH
$ git clone [email protected]:php-coveralls/php-coveralls.git

Configuration

Currently php-coveralls supports clover style coverage report and collects coverage information from clover.xml.

PHPUnit

Make sure that phpunit.xml.dist is configured to generate "coverage-clover" type log named clover.xml like the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit ...>
    <logging>
        ...
        <log type="coverage-clover" target="build/logs/clover.xml"/>
        ...
    </logging>
</phpunit>

You can also use --coverage-clover CLI option.

phpunit --coverage-clover build/logs/clover.xml

phpcov

Above settings are good for most projects if your test suite is executed once a build and is not divided into several parts. But if your test suite is configured as parallel tasks or generates multiple coverage reports through a build, you can use either coverage_clover configuration in .coveralls.yml (see below coverage clover configuration section) to specify multiple clover.xml files or phpcov for processing coverage reports.

composer.json

    "require-dev": {
        "php-coveralls/php-coveralls": "^2.7",
        "phpunit/phpcov": "^2.0"
    },

phpunit configuration

Make sure that phpunit.xml.dist is configured to generate "coverage-php" type log:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit ...>
    <logging>
        ...
        <log type="coverage-php" target="build/cov/coverage.cov"/>
        ...
    </logging>
</phpunit>

You can also use --coverage-php CLI option.

# use --coverage-php option instead of --coverage-clover
phpunit --coverage-php build/cov/coverage-${component_name}.cov

phpcov configuration

And then, execute phpcov.php to merge coverage.cov logs.

# get information
php vendor/bin/phpcov.php --help

# merge coverage.cov logs under build/cov
php vendor/bin/phpcov.php merge --clover build/logs/clover.xml build/cov

# in case of memory exhausting error
php -d memory_limit=-1 vendor/bin/phpcov.php ...

clover.xml

php-coveralls collects count attribute in a line tag from clover.xml if its type attribute equals to stmt. When type attribute equals to method, php-coveralls excludes its count attribute from coverage collection because abstract method in an abstract class is never counted though subclasses implement that method which is executed in test cases.

<!-- this one is counted as code coverage -->
<line num="37" type="stmt" count="1"/>
<!-- this one is not counted -->
<line num="43" type="method" name="getCommandName" crap="1" count="1"/>

Travis CI

Add php php-coveralls.phar or php vendor/bin/php-coveralls to your .travis.yml at after_success.

# .travis.yml
language: php
php:
  - 5.5
  - 5.4
  - 5.3

env:
  global:
    - XDEBUG_MODE=coverage

matrix:
  allow_failures:
    - php: 5.5

install:
  - curl -s http://getcomposer.org/installer | php
  - php composer.phar install --dev --no-interaction

script:
  - mkdir -p build/logs
  - php vendor/bin/phpunit -c phpunit.xml.dist

after_success:
  - travis_retry php vendor/bin/php-coveralls
  # or enable logging
  - travis_retry php vendor/bin/php-coveralls -v

CircleCI

Enable Xdebug in your circle.yml at dependencies section since currently Xdebug extension is not pre-enabled. composer and phpunit are pre-installed but you can install them manually in this dependencies section. The following sample uses default ones.

machine:
  php:
    version: 5.4.10

## Customize dependencies
dependencies:
  override:
    - mkdir -p build/logs
    - composer install --dev --no-interaction
    - sed -i 's/^;//' ~/.phpenv/versions/$(phpenv global)/etc/conf.d/xdebug.ini

## Customize test commands
test:
  override:
    - phpunit -c phpunit.xml.dist

Add COVERALLS_REPO_TOKEN environment variable with your coveralls repo token on Web UI (Tweaks -> Environment Variable).

Codeship

You can configure CI process for Coveralls by adding the following commands to the textarea on Web UI (Project settings > Test tab).

In the "Modify your Setup Commands" section:

curl -s http://getcomposer.org/installer | php
php composer.phar install --dev --no-interaction
mkdir -p build/logs

In the "Modify your Test Commands" section:

php vendor/bin/phpunit -c phpunit.xml.dist
php vendor/bin/php-coveralls

Next, open Project settings > Environment tab, you can set COVERALLS_REPO_TOKEN environment variable.

In the "Configure your environment variables" section:

COVERALLS_REPO_TOKEN=your_token

GitHub Actions

Add a new step after phpunit generate coverage report.

- name: Upload coverage results to Coveralls
  env:
    COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    composer global require php-coveralls/php-coveralls
    php-coveralls --coverage_clover=build/logs/clover.xml -v

From local environment

If you would like to call Coveralls API from your local environment, you can set COVERALLS_RUN_LOCALLY environment variable. This configuration requires repo_token to specify which project on Coveralls your project maps to. This can be done by configuring .coveralls.yml or COVERALLS_REPO_TOKEN environment variable.

$ export COVERALLS_RUN_LOCALLY=1

# either env var
$ export COVERALLS_REPO_TOKEN=your_token

# or .coveralls.yml configuration
$ vi .coveralls.yml
repo_token: your_token # should be kept secret!

php-coveralls set the following properties to json_file which is sent to Coveralls API (same behaviour as the Ruby library will do except for the service name).

  • service_name: php-coveralls
  • service_event_type: manual

Parallel Builds

Coveralls provides the ability to combine coverage result from multiple parallel builds into one. To enable the feature you can set the following in your environment variable.

COVERALLS_PARALLEL=true

To distinguish your job name, please set the COVERALLS_FLAG_NAME environment variable.

COVERALLS_FLAG_NAME=$YOUR_PHP_VERSION

Bear in mind that you will need to configure your build to send a webhook after all the parallel builds are done in order for Coveralls to merge the results.

Refer to Parallel Builds Webhook for more information for setup on your environment.

CLI options

You can get help information for coveralls with the --help (-h) option.

php vendor/bin/php-coveralls --help
  • --config (-c): Used to specify the path to .coveralls.yml. Default is .coveralls.yml
  • --verbose (-v): Used to show logs.
  • --dry-run: Used not to send json_file to Coveralls Jobs API.
  • --exclude-no-stmt: Used to exclude source files that have no executable statements.
  • --env (-e): Runtime environment name: test, dev, prod (default: "prod")
  • --coverage_clover (-x): Coverage clover xml files(allowing multiple values)
  • --json_path (-o): Used to specify where to output json_file that will be uploaded to Coveralls API. (default: build/logs/coveralls-upload.json)
  • --root_dir (-r): Root directory of the project. (default: ".")

.coveralls.yml

php-coveralls can use optional .coveralls.yml file to configure options. This configuration file is usually at the root level of your repository, but you can specify other path by --config (or -c) CLI option. Following options are the same as Ruby library (see reference on coveralls.io).

  • repo_token: Used to specify which project on Coveralls your project maps to. This is only needed for repos not using CI and should be kept secret
  • service_name: Allows you to specify where Coveralls should look to find additional information about your builds. This can be any string, but using travis-ci or travis-pro will allow Coveralls to fetch branch data, comment on pull requests, and more.

Following options can be used for php-coveralls.

  • entry_point: Used to specify API endpoint for sending reports. Useful when using self-hosted coveralls or other other, similar service (eg opencov). Default is https://coveralls.io.
  • coverage_clover: Used to specify the path to clover.xml. Default is build/logs/clover.xml
  • json_path: Used to specify where to output json_file that will be uploaded to Coveralls API. Default is build/logs/coveralls-upload.json.
# .coveralls.yml example configuration

# same as Ruby lib
repo_token: your_token # should be kept secret!
service_name: travis-pro # travis-ci or travis-pro

# for php-coveralls
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json

coverage clover configuration

You can specify multiple clover.xml logs at coverage_clover. This is useful for a project that has more than two test suites if all of the test results should be merged into one json_file.

#.coveralls.yml

# single file
coverage_clover: build/logs/clover.xml

# glob
coverage_clover: build/logs/clover-*.xml

# array
# specify files
coverage_clover:
  - build/logs/clover-Auth.xml
  - build/logs/clover-Db.xml
  - build/logs/clover-Validator.xml

You can also use --coverage_clover (or -x) command line option as follows:

coveralls --coverage_clover=build/logs/my-clover.xml

root_dir detection and override

This tool assume the current directory is the project root directory by default. You can override it with --root_dir command line option.

Change log

See changelog

Wiki

See wiki

php-coveralls's People

Contributors

adrenalinkin avatar alnutile avatar bartfeenstra avatar benmorel avatar carusogabriel avatar craue avatar dannyvdsluijs avatar dmitry-ivanov avatar dshemin avatar fefas avatar fisharebest avatar garak avatar gelolabs avatar grahamcampbell avatar hkdobrev avatar jimmycleuren avatar jrfnl avatar jubianchi avatar justincy avatar kazuakim avatar keradus avatar localheinz avatar martin-georgiev avatar onema avatar peter279k avatar philsturgeon avatar renan avatar sanmai avatar shadowhand avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-coveralls's Issues

Log enhancement

  • show file size of json_file

If a API request fails due to large file size, this message might be helpful for troubleshooting.

  • show number of included source files

Currently list included files, but it's hard to recognize number of files if a project has many source files.

  • show elapsed time and memory usage

Current implementation does not cause memory exhausting (so far). For large project, it might be a problem. So, these metrics will give me insight for further improvement.

  • show coverage

coveralls-ruby show total coverage.

$coverage = ($coveredStatements / $statements) * 100
  • show response to console:

Coveralls API returns response as json and it contains build page URL.

on success:

# response json
{
     "message":"Job #109431.1",
     "url":"https://coveralls.io/jobs/59240"
}
# log
Accepted Job #109431.1
You can see the build on https://coveralls.io/jobs/59240

on invalid repo_token:

# response json
{
    "message": "Build processing error."
    "error": "true"
    "url": ""
}
# log
Build processing error.

Problems with Travis CI environment variables "Requirements are not satisfied."

I have problem with Travis CI integration

$ php vendor/bin/coveralls -v
Load coverage clover log:
  - /home/travis/build/Mahout/Mahout/build/artifacts/logs/clover.xml
Found 3 source files:
  - 100.00% Mahout/Request.php
  - 100.00% Mahout/Utils.php
  - 100.00% Mahout/Utils/KeySpaceConstrainedParams.php
Coverage: 100.00% (192/192)
Collect git info
Read environment variables
Requirements are not satisfied.
  - TRAVIS='true'
  - TRAVIS_JOB_ID='18683918'
  - CI_NAME='travis-ci'
  - COVERALLS_REPO_TOKEN='EEqvgAJ379f5x05BlyQo87E7oYC3kzh0t'
Set environment variables properly like the following.
For Travis users:
  - TRAVIS
  - TRAVIS_JOB_ID
For CircleCI users:
  - CIRCLECI
  - CIRCLE_BUILD_NUM
  - COVERALLS_REPO_TOKEN
For Jenkins users:
  - JENKINS_URL
  - BUILD_NUMBER
  - COVERALLS_REPO_TOKEN
From local environment:
  - COVERALLS_RUN_LOCALLY
  - COVERALLS_REPO_TOKEN
elapsed time: 0.071 sec memory: 4.25 MB

Job url: https://travis-ci.org/Mahout/Mahout/jobs/18683918
Github url: http://github.com/Mahout/Mahout/

Error when using whitelist / blacklist with phpunit.xml

I am running into the following error after setting up blacklist and whitelist directories in phpunit.xml:

ubuntu@box284:~/server$ COVERALLS_REPO_TOKEN=mytoken php lib/php/vendor/bin/coveralls --verbose          
Load coverage clover log:
  - /home/ubuntu/server/lib/php/build/logs/clover.xml
Collect git info
Read environment variables



  [RuntimeException]        
  source_files must be set  



Exception trace:
 () at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Entity/JsonFile.php:278
 Contrib\Bundle\CoverallsV1Bundle\Entity\JsonFile->ensureJobs() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Entity/JsonFile.php:145
 Contrib\Bundle\CoverallsV1Bundle\Entity\JsonFile->fillJobs() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Api/Jobs.php:93
 Contrib\Bundle\CoverallsV1Bundle\Api\Jobs->collectEnvVars() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:247
 Contrib\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->collectEnvVars() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:151
 Contrib\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->runApi() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:103
 Contrib\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() at /home/ubuntu/server/lib/php/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at /home/ubuntu/server/lib/php/vendor/symfony/console/Symfony/Component/Console/Application.php:904
 Symfony\Component\Console\Application->doRunCommand() at /home/ubuntu/server/lib/php/vendor/symfony/console/Symfony/Component/Console/Application.php:192
 Symfony\Component\Console\Application->doRun() at /home/ubuntu/server/lib/php/vendor/symfony/console/Symfony/Component/Console/Application.php:122
 Symfony\Component\Console\Application->run() at /home/ubuntu/server/lib/php/vendor/satooshi/php-coveralls/composer/bin/coveralls:34


coveralls:v1:jobs [-c|--config[="..."]] [--dry-run] [--exclude-no-stmt] [-e|--env[="..."]]

The big difference I can see is that the clover.xml file is considerable larger (2.4MB vs a couple 100KB) after enabling the whitelist. Could the size of the clover.xml file be too large or maybe missing other required information?

isRelativePath on Windows

isRelativePath function (vendor\satooshi\php-coveralls\src\Satooshi\Component\File\Path.php) doesn't work on Windows and for path C:\\prod\!NYTDL\Tests\1.json returns true
DIRECTORY_SEPARATOR is \

As result always this exception

  [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
  json_path is not writable

Static Code analysis flags up guzzle/guzzle

Hi there

We're building a Laravel 5.1 app and part of the procedure is running static code analysis (using Checkmarx) against the whole codebase. "guzzle/guzzle" (i.e. Guzzle v3) is a requirement of the php-coveralls package and is currently the only thing throwing up errors.

Would there be any issue moving up to v4+ of Guzzle? (i.e. guzzlehttp/guzzle) Would be happy to work on a PR for this.

Add option: exclude files that have no statements

Files containing only interface usually do not have executable statements. It can be done to exclude them by configuring <filter> in the phpunit.xml. But it's troublesome for maintenance.

Now considering to add option to either or both,

  • CLI option (--exclude-no-stmt)
  • .coveralls.yml (exclude_no_stmt)

and these are set to false by default.

Update README

Fix mistakes and add descriptions.

  • indentation of yml for travis and circleci are 4 spaces and 2 spaces respectively
  • add description of CLI option
    • --verbose
    • --exclude-no-stmt
  • add phpunit configurations
    • --coverage-clover CLI option
    • case of phpcov usage
  • add troubleshooting
    • composer install failed!
      • try --prefer-source
    • failed to submit json_file
      • try to use -v or --verbose to confirm server response status
      • 500 error
        • restart build
      • 400 error
        • configuration is wrong
    • want to ignore interface files from coveralls stats
      • use --exclude-no-stmt CLI option
      • or add exclude_no_stmt in .coveralls.yml

Phar support?

The best way to avoid dependency conflict is to make phar file? It could reduce composer install time (compared to downloading 1 coveralls.phar file).

But I'm not sure what the phar format is...

"src directory is not found" Error

I am trying to use this library to integrate coveralls.io with my travis-ci builds.

The repo in question is https://github.com/F21/Paradox.

I have tried many things, but this error always occurs:

$ php vendor/bin/coveralls -v

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]

src directory is not found

Exception trace:

() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:120

Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->ensureSrcDir() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:96

Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->createConfiguration() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:33

Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->load() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:119

Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->loadConfiguration() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:88

Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() at /home/travis/build/F21/Paradox/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244

Symfony\Component\Console\Command\Command->run() at /home/travis/build/F21/Paradox/vendor/symfony/console/Symfony/Component/Console/Application.php:897

Symfony\Component\Console\Application->doRunCommand() at /home/travis/build/F21/Paradox/vendor/symfony/console/Symfony/Component/Console/Application.php:191

Symfony\Component\Console\Application->doRun() at /home/travis/build/F21/Paradox/vendor/symfony/console/Symfony/Component/Console/Application.php:121

Symfony\Component\Console\Application->run() at /home/travis/build/F21/Paradox/vendor/satooshi/php-coveralls/composer/bin/coveralls:33

coveralls:v1:jobs [-c|--config[="..."]] [--dry-run] [--exclude-no-stmt] [-e|--env[="..."]]

This is my .travis.yml:

language: php
php:
  - "5.4"
  - "5.5"

before_script:
  - composer self-update
  - chmod 777 ./tests/bin/setup.sh
  - ./tests/bin/setup.sh
  - composer install --prefer-source --no-interaction --dev

script: 
  - mkdir -p build/logs
  - phpunit --configuration ./tests/phpunit.xml --coverage-clover build/logs/clover.xml

after_script:
  - php vendor/bin/coveralls -v

This is the failing build: https://travis-ci.org/F21/Paradox/jobs/14595662

Remove ext-curl dependency

Since php-coveralls replaced http client implementation with guzzle, ext-curl dependency should be removed (guzzle has this dependency).

"source_files must be set" error when running the CLI

I've followed the instruction and installed the library via Composer, but when trying to run it with php vendor/bin/coveralls -v, it returns :

Load coverage clover log:
- /home/travis/build/kamisama/cakephp/app/Plugin/CakeResque/build/logs/clover.xml
Collect git info
Read environment variables
source_files must be set

You can see the travis build here

Is it because of the folder structure ? SInce the src_dir contains the Test dir ?

Add connection error handling

According to guzzle doc, Guzzle\Http\Exception\CurlException is thrown if connection error occur. But current implementation of CoverallsV1JobsCommand, this exception is not caught. So the error handling should be implemented.

Edge case: end of file should not be included in code coverage

If the case of using autoloader generaged by Composer, and a new line (\n) is at the end of file, unexpected line coverage will appear in clover.xml. To ignore this line coverage, source file should be trim() before getting number of lines.

Since Coveralls removes the last new line at the end of file, the change will not break consistency to previous code coverage data.

If the case of using require_once() to load classes in a source file, any blank lines are not considered as a statement line.

Show helpful message if the requirements are not satisfied

A RuntimeException will occur with the message "requirements are not satisfied. " if environment variables are not configured properly. To help to configure them properly, it is better to show more intuitive message and what variables are read.

Requirements are not satisfied.

CI=true
CI_NAME=xxx
...

Set environment variables properly like the following.
For Travis users,
...
For CircleCI users,
...

Refactor test cases

  • extract super class that has makeProjectDirs()
  • rename test method more readable

Intermittent issue submitting coverage results (Unable to parse response body into JSON: 4)

@jmalloc and I have been experiencing this issue intermittently for the past week-and-a-bit. Every now and then we get this error from Coveralls:

[Guzzle\Common\Exception\RuntimeException]  
Unable to parse response body into JSON: 4

I think it's quite possible that it's a flaky server on Coveralls' end, because the problem usually fixes itself with a re-run, but I thought I'd bring it up here in case you have any ideas?

Change namespace

Top level namespace should be vendor name and I change it to my user name.

Contrib -> Satooshi

src directory is not found

php-coveralls keeps failing on travis with following exception:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]

Failing build is https://travis-ci.org/lioman/blog-retrospection/jobs/63439207

My .coverall.yml

service_name: travis-ci
src_dir: .
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json

My .travis.yml

language: php

notifications:
  on_success: never
  on_failure: change

php:
  - 5.3
  - 5.5

env:
  - WP_VERSION=latest WP_MULTISITE=0

matrix:
  include:
    - php: 5.3
      env: WP_VERSION=latest WP_MULTISITE=1

before_script:
  - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
  - curl -s http://getcomposer.org/installer | php
  - php composer.phar install --no-interaction

script:
  - mkdir -p build/logs
  - phpunit --coverage-clover build/logs/clover.xml

after_script:
  - php vendor/bin/coveralls -v

How can I fix this?

New Release

Hello,

the last release of PHP-Coveralls is from 2013, but there are many fixes since the last release. It would be nice to create a new version for people who prefer using fixed versions rather than installing from dev-master.

CloverXmlCoverageCollector could not handle root directory

As found in issue #41, in Satooshi\Bundle\CoverallsV1Bundle\Collector\CloverXmlCoverageCollector, $rootDir should be existing directory without trailing directory separator. If the case of $rootDir === "/", the collector could not find source files correctly.

    public function collect(\SimpleXMLElement $xml, $rootDir)
    {
        $root = $rootDir . DIRECTORY_SEPARATOR;

New release?

It would be great if you could provide a more current release tag.
A lot has happened between 0.6.1 and master.

Error using alternate vendor diretory

In my composer configuration I have:

"config": {
        "vendor-dir": "lib/php/vendor/"
    },

I believe this is causing the following error when I try to run lib/php/vendor/bin/coveralls:

  [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]  
  coverage_clover XML file is not readable

I notice that is is trying to read the clover.xml from /Users/ashinn/Projects/server/lib/php/build/logs/clover.xml when the file actually exists at /Users/ashinn/Projects/server/build/logs/clover.xml.

I tried manually specifying other paths and using the .coveralls.yml file. But the command line doesn't seem to pick up that file even when specified with --config.

Any idea of how to work around this or could it be a bug?

Allow to use the library without curl

Hey!

I'm digging into an issue which does not allow me to push my report to coveralls. Basically, one of my test suite disables curl on travis in order to ensure that some behaviors runs as expected. As it is compiled with it, I have just mark curl_init as disabled for security reason in the php.ini to reflect curl is disabled. (See the after_script part of this build: https://travis-ci.org/egeloen/ivory-http-adapter/jobs/32118374)

For my specific use case, I can re-enable it, it's not really problematic but it can if people don't want/can't install it.

What I propose it to refactor the fact it relies on Guzzle/curl and rely on an http adapter library I just wrote few days ago (https://github.com/egeloen/ivory-http-adapter) which allow to use the library you want through the same API. By default, we can rely on fopen, file_get_contents or socket which does not require extra packages and let the ability to end user to use the library he wants.

What's your opinion?

Deprecated "Symfony\Component\Yaml\Yaml::parse" method usage

I'm using library to generate Coveralls IO compatible coverage information from PHPUnit's clover.xml. Currently it works just fine, but following appears in Travis CI logs when I run php vendor/bin/coveralls -v:

PHP Deprecated:  The ability to pass file names to the Symfony\Component\Yaml\Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead. in /home/travis/build/qa-tools/qa-tools/vendor/symfony/yaml/Yaml.php on line 59
PHP Stack trace:
PHP   1. {main}() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/composer/bin/coveralls:0
PHP   2. Symfony\Component\Console\Application->run() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/composer/bin/coveralls:33
PHP   3. Symfony\Component\Console\Application->doRun() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:126
PHP   4. Symfony\Component\Console\Application->doRunCommand() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:195
PHP   5. Symfony\Component\Console\Command\Command->run() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:878
PHP   6. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Command/Command.php:259
PHP   7. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->loadConfiguration() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:88
PHP   8. Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->load() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:119
PHP   9. Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->parse() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:30
PHP  10. Symfony\Component\Yaml\Yaml::parse() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:53
PHP  11. trigger_error() /home/travis/build/qa-tools/qa-tools/vendor/symfony/yaml/Yaml.php:59

Deprecated: The ability to pass file names to the Symfony\Component\Yaml\Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead. in /home/travis/build/qa-tools/qa-tools/vendor/symfony/yaml/Yaml.php on line 59

Call Stack:
    0.0002     643344   1. {main}() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/composer/bin/coveralls:0
    0.0168    3412184   2. Symfony\Component\Console\Application->run() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/composer/bin/coveralls:33
    0.0202    3995056   3. Symfony\Component\Console\Application->doRun() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:126
    0.0204    3995312   4. Symfony\Component\Console\Application->doRunCommand() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:195
    0.0204    3995480   5. Symfony\Component\Console\Command\Command->run() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Application.php:878
    0.0208    3995352   6. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() /home/travis/build/qa-tools/qa-tools/vendor/symfony/console/Command/Command.php:259
    0.0219    4153056   7. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->loadConfiguration() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:88
    0.0224    4229072   8. Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->load() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:119
    0.0224    4229072   9. Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator->parse() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:30
    0.0229    4309824  10. Symfony\Component\Yaml\Yaml::parse() /home/travis/build/qa-tools/qa-tools/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php:53
    0.0229    4310392  11. trigger_error() /home/travis/build/qa-tools/qa-tools/vendor/symfony/yaml/Yaml.php:59

Error: Configurator::process() must be of the type array, string given.

I'm experiencing this issue. The error i'm getting is:

PHP Catchable fatal error: Argument 1 passed to Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator::process() must be of the type array, string given, called in /home/travis/build/ARCANEDEV/Stripe/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php on line 31 and defined in /home/travis/build/ARCANEDEV/Stripe/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Config/Configurator.php on line 68

Support environment prop in json_file

the same props in coveralls-ruby but only including packagist_version. I don't think other props are valuable since they should have been included in json_file.

# json_file looks like

{
    "environment": { "packagist_version": "0.6.0" },
    "git": {...},
    "service_name": "foo_ci",
    "service_number": "123",
    ...
}

file names need to be relative to the git repo root

Hi, Coveralls founder here -- we're now only keeping an md5 of the source and pulling it from the Github API on demand for display. To do so, we need to use the exact path to the file as it resides within the git repo, which should come in from your library's API post as the source file name.

I've added the ability to add extra folders to the path prefix (or remove them if it's a full path) for the overall project, but it would be ideal if your integration library used relative paths from the beginning.

There's more info in the source section of our updated API docs.

Let me know if that's doable, thank you!

PHP Catchable fatal error: Method Satooshi\Bundle\CoverallsV1Bundle\Entity\JsonFile::__toString() must return a string value

Please see https://travis-ci.org/burzum/cakephp-file-storage/jobs/73852737

This started happening some time ago if you look at the build history. Everything else works fine just this lib is causing issues.

Dump submitting json file: /home/travis/build/burzum/cakephp-file-storage/build/logs/coveralls-upload.json
PHP Catchable fatal error: Method Satooshi\Bundle\CoverallsV1Bundle\Entity\JsonFile::__toString() must return a string value in /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Api/Jobs.php on line 116
PHP Stack trace:
PHP 1. {main}() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/composer/bin/coveralls:0
PHP 2. Symfony\Component\Console\Application->run() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/composer/bin/coveralls:33
PHP 3. Symfony\Component\Console\Application->doRun() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:126
PHP 4. Symfony\Component\Console\Application->doRunCommand() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:195
PHP 5. Symfony\Component\Console\Command\Command->run() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:878
PHP 6. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Command/Command.php:259
PHP 7. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->executeApi() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:91
PHP 8. Satooshi\Bundle\CoverallsV1Bundle\Repository\JobsRepository->persist() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:140
PHP 9. Satooshi\Bundle\CoverallsV1Bundle\Repository\JobsRepository->dumpJsonFile() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Repository/JobsRepository.php:68
PHP 10. Satooshi\Bundle\CoverallsV1Bundle\Api\Jobs->dumpJsonFile() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Repository/JobsRepository.php:139
PHP 11. file_put_contents() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Api/Jobs.php:116
Catchable fatal error: Method Satooshi\Bundle\CoverallsV1Bundle\Entity\JsonFile::__toString() must return a string value in /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Api/Jobs.php on line 116
Call Stack:
0.0003 241368 1. {main}() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/composer/bin/coveralls:0
0.0217 2405760 2. Symfony\Component\Console\Application->run() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/composer/bin/coveralls:33
0.0262 2815608 3. Symfony\Component\Console\Application->doRun() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:126
0.0264 2816504 4. Symfony\Component\Console\Application->doRunCommand() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:195
0.0264 2816960 5. Symfony\Component\Console\Command\Command->run() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Application.php:878
0.0269 2820648 6. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->execute() /home/travis/build/burzum/cakephp-file-storage/vendor/symfony/console/Command/Command.php:259
0.0368 3701480 7. Satooshi\Bundle\CoverallsV1Bundle\Command\CoverallsV1JobsCommand->executeApi() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:91
0.0448 4382888 8. Satooshi\Bundle\CoverallsV1Bundle\Repository\JobsRepository->persist() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Command/CoverallsV1JobsCommand.php:140
0.5040 13266232 9. Satooshi\Bundle\CoverallsV1Bundle\Repository\JobsRepository->dumpJsonFile() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Repository/JobsRepository.php:68
0.5041 13266336 10. Satooshi\Bundle\CoverallsV1Bundle\Api\Jobs->dumpJsonFile() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Repository/JobsRepository.php:139
0.5041 13266384 11. file_put_contents() /home/travis/build/burzum/cakephp-file-storage/vendor/satooshi/php-coveralls/src/Satooshi/Bundle/CoverallsV1Bundle/Api/Jobs.php:116
The command "sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"" exited with 255.
Done. Your build exited with 1.

Is the repo token required?

I have all the correct setup (or i think so) using Travis. I can even see the results on a travis build. But it is always returning an 500 error.

Is it because of the repo token?

Output:

Coverage:  58.82% (150/255)
Collect git info
Read environment variables
Dump submitting json file: /home/travis/build/algorit/synchronizer/tests/coveralls.json
File size: 36.65 kB
Submitting to https://coveralls.io/api/v1/jobs
Server error occurred. status: 500 Internal Server Error
Build processing error.
elapsed time: 2.375 sec memory: 6.50 MB

Build: https://travis-ci.org/algorit/synchronizer/jobs/21061165
Repository: https://github.com/algorit/synchronizer

From the readme it's hard to tell if I should use coverage-clover or coverage-php for phpunit

The README cites both options, it first says

Make sure that phpunit.xml.dist is configured to generate "coverage-clover" type log named clover.xml like the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit ...>
    <logging>
        ...
        <log type="coverage-clover" target="build/logs/clover.xml"/>
        ...
    </logging>
</phpunit>

You can also use --coverage-clover CLI option.

phpunit --coverage-clover build/logs/clover.xml

... but later on goes on to include:

phpunit configuration

Make sure that phpunit.xml.dist is configured to generate "coverage-php" type log:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit ...>
    <logging>
        ...
        <log type="coverage-php" target="build/cov/coverage.cov"/>
        ...
    </logging>
</phpunit>
You can also use --coverage-php CLI option.

use --coverage-php option instead of --coverage-clover

phpunit --coverage-php build/cov/coverage-${component_name}.cov

Which is supported? Or is it both? Is one preferred over the other?

Composing gives error

composer gives:

[RuntimeException]
Source directory .../vendor/satooshi/php-coveralls has uncommitted changes.

This is on every lib I have requiring satooshi/php-coveralls in dev

Suggests that installation/update is modifying local files. Do I need to dig deeper?

Using outdated Guzzle version

Guzzle made some breaking changes starting with version 4.0 and php-coveralls doesn't work with the newer versions. From what I can tell only the Jobs::upload() method will need to be changed and the composer.json updated.

Next Tagged Release?

Is there any plan on tagging a release soon? I feel bad pulling in "dev-master".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.