holyshared / coverallskit
PHP client for coveralls.io
Requires
- php: >=5.5.0
- eloquent/pathogen: ~0.6
- gitonomy/gitlib: ~1.0
- guzzlehttp/guzzle: ~6.2
- symfony/css-selector: ~3.0
- symfony/dom-crawler: ~3.0
- yosymfony/toml: ~0.3
- zendframework/zend-config: ~2.6
- zendframework/zend-console: ~2.6
Requires (Dev)
This package is auto-updated.
Last update: 2022-02-01 12:33:26 UTC
README
CoverallsKit is the library for transmitting the report of code coverage to coveralls.
This library works with PHP5.5 or more.
Requirements
- PHP >= 5.5
- Xdebug >= 2.2.2
Installation
Installation that uses the composer.
-
Install the composer.
-
Install the package.
composer require cloak/coverallskit --dev
Basic usage
You can generate a json file using the coverallskit/CoverallsReportBuilder.
You just set the code coverage of rows that have been executed.
Code coverage can be obtained easily by using the HHVM and xdebug.
$travis = new TravisCI( new Environment($_SERVER) ); $service = new CIService($travis); $builder = new CoverallsReportBuilder(); $builder->token('your repository token') ->service($service) ->repository(new GitRepository(__DIR__ . '/../')); $source = new SourceFile('path/to/file'); $source->addCoverage(CoverageResult::executed(1)); //The first line was executed $source->addCoverage(CoverageResult::unused(2)); //The second line is not executed $source->addCoverage(CoverageResult::executed(3)); //The third line is executed $builder->addSource($source); $builder->build()->saveAs(__DIR__ . '/tmp/coverage.json');
Using a configuration file
If you use a configuration file, you can send the report more easily.
use coverallskit\BuilderConfiguration; use coverallskit\CoverallsReportBuilder; $configuration = BuilderConfiguration::loadFromFile('coveralls.toml'); $builder = CoverallsReportBuilder::fromConfiguration($configuration); $builder->build()->save()->upload();
Configuration file format
It is also possible to use a configuration file.
The file format is toml format.
token = "{api-token}" service = "travis-ci" repositoryDirectory = "." [reportFile] output = "script/coveralls.json" [reportFile.input] type = "lcov" file = "script/report.lcov"
File format
Name | Required | Default | Description |
---|---|---|---|
token | optional | COVERALLS_REPO_TOKEN | coveralls.io api token. If you do not specify, use the environment variable COVERALLS_REPO_TOKEN. |
service | optional | travis-ci | CI(Continuous Integration) service name. You can use the travis-ci or travis-pro or circle-ci or drone.io or codeship |
reportFile | optional | Please look at the reportFile section. | |
repositoryDirectory | optional | . | Directory path of the git repository. Will specify a relative path from the directory containing the configuration file. |
reportFile
imput
Name | Required | Default | Description |
---|---|---|---|
type | optional | Will specify the file type in the code coverage report. You can specify the lcov or clover. | |
file | optional | coveralls.json | Will specify a file of code coverage report. |
output
will specify the json file name to be sent to the coveralls.io.
Will specify a relative path from the directory containing the configuration file.
Task for Robo
Support the robo of tasks, so you can easily send a report.
Please look at the robo-coveralls-kit for more information.
Detailed documentation
Run only unit test
composer test
How to run the example
vendor/bin/robo example:basic