How to include code coverage output in the job list for a PHP project on gitlab.com

For a project hosted at https://www.gitlab.com I would like to configure code coverage in the CI setup so that it can be displayed in the job list

job list in gitlab.com project

My configuration is as follows:

.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

Job completed successfully but error message is displayed

Error: coverage code driver unavailable

no code coverage result found

I updated the parameter to parse the test coverage and set the regex to

^\s*Lines:\s*\d+.\d+\%

example for PHP / PHPUnit.

When i run the command

vendor/bin/phpunit --coverage-text --colors=never

locally, I get the following output:

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)
+4
source share
1

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
+2

Source: https://habr.com/ru/post/1679813/


All Articles