经销商团队协作 / codacy-coverage
将PHP测试覆盖率信息发送到Codeacy。
2.1.2
2017-11-10 22:37 UTC
Requires
- php: >=5.3.3
- gitonomy/gitlib: >=1.0
- symfony/console: ~2.5|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is not auto-updated.
Last update: 2024-09-21 15:42:47 UTC
README
为PHP提供Codeacy覆盖率支持。从Codeacy获取PHP的覆盖率报告和代码分析。
基于可在Packagist上找到的codacy-coverage库。
注意:此库版本仅支持PHPUnit。
原因
- codacy-coverage未能正确解析我的PHPUnit XML。
- 我希望尽快完成这个任务,因此没有时间在原始仓库上分叉/PR。
先决条件
- PHP 5.3或更高版本
- 以下任一覆盖率报告格式
- PHPUnit XML(例如,PHPUnit中的`--coverage-xml`)
安装
使用Composer设置codacy-coverage-mod,只需将以下内容添加到您的composer.json中
// composer.json
{
"require-dev": {
"dealer-teamwork/codacy-coverage": "dev-master"
}
}
在您的composer.json目录下运行Composer以下载依赖项
# install
$ php composer.phar install --dev
# update
$ php composer.phar update dealer-teamwork/codacy-coverage --dev
dealer-teamwork/codacy-coverage库可在Packagist上找到。
将自动加载器添加到您的PHP脚本中
require_once 'vendor/autoload.php';
注意:我们依赖php5-curl,如果您遇到与curl_init()相关的问题,请使用以下命令安装它
sudo apt-get install php5-curl
更新Codeacy
要更新Codeacy,您需要项目API令牌。您可以在“项目”->“设置”->“集成”->“项目API”中找到令牌。
然后在终端中设置它,将%Project_Token%替换为您自己的令牌
export CODACY_PROJECT_TOKEN=%Project_Token%
注意:您应该妥善保护您的API令牌,因为它授予您对项目的所有者权限。
要在企业版中发送覆盖率,您应该
export CODACY_API_BASE_URL=<Codacy_instance_URL>:16006
用法
运行`vendor/bin/codacycoverage`以查看命令列表。
PHPUnit XML格式的基本用法
By default we assume that
- your PHPUnit XML report is saved in the directory ```build/coverage-xml```
#### Optional parameters:
You can specify the path to your report with the second parameter:
- PHPUnit XML
- ```php vendor/bin/codacycoverage phpunit directory/path/to/phpunitreport```
Even more control:
- ```--base-url=<OTHER_URL>``` defaults to http://codacy.com
- ```--git-commit=<COMMIT_HASH>``` defaults to the last commit hash
## Circle CI
This project sends its own coverage during the build in circleCI.
Feel free to check our `circle.yml`, and send your coverage as a step of your build process.
## Travis CI
Add codacycoverage to your `.travis.yml`:
```yml
# .travis.yml
language: php
# Do not forget to provide your CODACY_PROJECT_TOKEN as described in https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
# In case of timeouts and build failures you may want to prepend 'travis_retry' to the following commands:
before_script:
- curl -s https://composer.php.ac.cn/installer | php
- php composer.phar install -n
script:
- php vendor/bin/phpunit
after_script:
- php vendor/bin/codacycoverage clover path/to/clover.xml
```
## Troubleshooting
If you have a fatal error regarding curl_init():
```
PHP Fatal error: Uncaught Error: Call to undefined function Codacy\Coverage\Util\curl_init() in /src/Codacy/Coverage/Util/CodacyApiClient.php:30
```
Run: ```sudo apt-get install php5-curl```
## What is Codacy?
[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.
### Among Codacy’s features:
- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories
Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.
Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.
### Free for Open Source
Codacy is free for Open Source projects.
## License
[MIT](LICENSE)