gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 13:22:17 26 4
gpt4 key购买 nike

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

job list in gitlab.com project

我的配置是这样的:

.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

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

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

no code coverage found job output

我已经更新了 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 安装正确的版本,所以我不得不在 before_script 部分添加一个 pecl install xdebug 调用:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com