对于在https://www.gitlab.com托管的项目,我想在CI设置中设置代码覆盖率,以便可以在作业列表中显示它

php - 如何在gitlab.com上的PHP项目的作业列表中启用代码覆盖率输出-LMLPHP

我的配置如下所示:

.gitlab-ci.yml

image: php:7.1.1

cache:
  paths:
  - vendor/

before_script:
# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git -yqq

# Install composer
- curl -sS https://getcomposer.org/installer | php

# Install all project dependencies
- php composer.phar install

# Run our tests
test:
    only:
        - master
        - develop
    script:
        - vendor/bin/phpunit --configuration phpunit.xml --coverage-text --colors=never

作业成功,但显示错误消息

错误:没有可用的代码覆盖率驱动程序

php - 如何在gitlab.com上的PHP项目的作业列表中启用代码覆盖率输出-LMLPHP

我已经更新了setting for Test coverage parsing并将正则表达式设置为
^\s*Lines:\s*\d+.\d+\%

PHP/PHPUnit的示例。

当我运行命令
vendor/bin/phpunit --coverage-text --colors=never

在本地,我得到以下输出:
Code Coverage Report:
  2017-06-21 14:52:55

 Summary:
  Classes: 100.00% (4/4)
  Methods: 100.00% (14/14)
  Lines:   100.00% (43/43)

\Rodacker\CartExample::Article
  Methods: 100.00% ( 6/ 6)   Lines: 100.00% ( 11/ 11)
\Rodacker\CartExample::ArticleLoader
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 21/ 21)
\Rodacker\CartExample::ArticleRepository
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% (  6/  6)
\Rodacker\CartExample::Image
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% (  5/  5)

最佳答案

问题是在Docker镜像中缺少Xdebug安装。我无法使用apt-get安装正确的版本,因此必须在pecl install xdebug部分中添加一个before_script调用:

image: php:7.1.1

cache:
  paths:
  - vendor/

before_script:
# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git -yqq

# Install Xdebug
- pecl install xdebug
- docker-php-ext-enable xdebug

# Install composer
- curl -sS https://getcomposer.org/installer | php

# Install all project dependencies
- php composer.phar install

# Run our tests
test:
    only:
        - master
    script:
        - vendor/bin/phpunit --configuration phpunit.xml --coverage-text --colors=never

关于php - 如何在gitlab.com上的PHP项目的作业列表中启用代码覆盖率输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44676780/

10-09 06:50