User Tools

Site Tools


gitlab-ci-phpunit

Gitlab PHPUnit

Generate junit reports in PHPUnit and upload it as Artifact to Gitlab reports.

phpunit:
  image: php:7.4 # A PHP Image with xDebug enabled
  stage: test
  # Upload Artifact so Gitlab can display Test in Job -> Tests tab
  artifacts:
    when: always
    paths:
      - phpunit-report.xml
    reports:
      junit: phpunit-report.xml
  script:
    - ./vendor/bin/phpunit --coverage-text --log-junit phpunit-report.xml

If you can't find a xdebug enabled php image, build it yourself:

FROM php:<php-version>

RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    && echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
 
CMD ["php", "-a"]
 
WORKDIR /var/www/html
gitlab-ci-phpunit.txt · Last modified: 2021/03/30 07:18 by admin