CoverallsKit is the library for transmitting the report of code coverage to coveralls.
This library works with PHP5.5 or more.
- PHP >= 5.5
- Xdebug >= 2.2.2
Installation that uses the composer.
-
Install the composer.
-
Install the package.
composer require cloak/coverallskit --dev
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');
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();
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"
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. |
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. |
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.
Support the robo of tasks, so you can easily send a report.
Please look at the robo-coveralls-kit for more information.
composer test
vendor/bin/robo example:basic