First attempt of adding CI/CD for php

This commit is contained in:
Daniel_I_Am 2021-09-04 13:32:35 +02:00
parent 81356ac945
commit c7704c11b4

View File

@ -1,7 +1,46 @@
stages: stages:
- build
- test
- docker - docker
- deploy - deploy
variables:
MYSQL_DATABASE: portfolio
MYSQL_ROOT_PASSWORD: password
php-build-job:
stage: build
image: composer:2
script:
- composer install
artifacts:
paths:
- vendor/
php-test-job:
stage: test
image: php:8-cli
services:
- mysql:5
needs:
- php-build-job
dependencies:
- php-build-job
script:
- yes | pecl install xdebug
- echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini
- echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini
- export DB_CONNECTION=mysql
- export DB_HOST=mysql
- export DB_PORT=3306
- export DB_DATABASE="$MYSQL_DATABASE"
- export DB_USERNAME=root
- export DB_PASSWORD="$MYSQL_ROOT_PASSWORD"
- ./vendor/bin/phpunit --coverage-cobertura code-coverage.xml
artifacts:
reports:
cobertura: code-coverage.xml
docker-auth-job: docker-auth-job:
stage: docker stage: docker
image: docker:stable image: docker:stable
@ -21,6 +60,8 @@ docker-build-job:
only: only:
refs: refs:
- master - master
needs:
- php-test-job
tags: tags:
- docker - docker
script: script: