فهرست منبع

fix CI config and add coverage support

Olivier Massot 2 سال پیش
والد
کامیت
dda9f1e228
3فایلهای تغییر یافته به همراه67 افزوده شده و 23 حذف شده
  1. 5 23
      .gitlab-ci.yml
  2. 1 0
      phpunit.xml.dist
  3. 61 0
      tests/ci_docker_install.sh

+ 5 - 23
.gitlab-ci.yml

@@ -4,38 +4,20 @@ stages:
 variables:
   APP_ENV: ci
   SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
-
-before_script:
-  # /!\ Attention: la configuration du SSH est indispensable pour pouvoir cloner notre repo foselastica
-  # Install packages
-  - apt-get -yqq update
-  - apt-get -yqq install zip unzip git openssh-client
-
-  # Run ssh-agent and add private key
-  - eval $(ssh-agent -s)
-  - mkdir -p ~/.ssh
-  - chmod 700 ~/.ssh
-  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
-  - ssh-add <(echo "$SSH_PRIVATE_KEY")
-  - git config --global user.email "exploitation@opentalent.fr"
-  - git config --global user.name "git"
-
-  # install composer
-  - curl -sS https://composer.github.io/installer.sig > installer.sig
-  - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
-  - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
-  - php composer-setup.php
-  - php -r "unlink('composer-setup.php'); unlink('installer.sig');"
+  XDEBUG_MODE: coverage
 
 cache:
   paths:
     - ./vendor
 
+before_script:
+  - bash tests/ci_docker_install.sh > /dev/null
+  - php -v
+
 unit:
   stage: test
 
   script:
-    - php composer.phar install --no-interaction --ignore-platform-reqs
     - php bin/phpunit --configuration phpunit.xml.dist --colors=never --no-interaction
 
   artifacts:

+ 1 - 0
phpunit.xml.dist

@@ -7,6 +7,7 @@
     </include>
     <report>
       <html outputDirectory="./coverage" lowUpperBound="35" highLowerBound="70"/>
+      <text outputFile="php://stdout" showUncoveredFiles="true" showOnlySummary="true"/>
     </report>
   </coverage>
   <php>

+ 61 - 0
tests/ci_docker_install.sh

@@ -0,0 +1,61 @@
+#!/bin/bash
+# Setup a php:8.2.1-fpm docker image
+
+# We need to install dependencies only for Docker
+[[ ! -e /.dockerenv ]] && exit 0
+
+# Quit on error
+set -xe
+
+# Install packages
+apt-get update
+apt-get install -yqq --fix-missing apt-utils gnupg git build-essential openssh-client zip
+
+apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9C74FEEA2098A6E
+echo "deb https://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
+echo "deb-src https://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
+
+apt-get update
+
+apt-get install -yqq --fix-missing --no-install-recommends unzip zlib1g-dev libicu-dev g++ \
+                               libzip-dev libpng-dev libtidy-dev libssl-dev \
+                               libxslt-dev libxrender-dev libxrender1 libxt6 libxtst6 openssh-server \
+                               xorg iputils-ping wget gdebi ca-certificates wget \
+                               fontconfig acl procps libmagickwand-dev imagemagick
+
+apt-get clean
+rm -r /var/lib/apt/lists/*
+
+# Configure docker
+#docker-php-ext-configure intl
+#docker-php-ext-install intl opcache pdo_mysql exif bcmath calendar gd tidy
+#docker-php-ext-enable libxslt-dev
+#docker-php-ext-enable intl
+#docker-php-ext-enable exif
+#docker-php-ext-enable tidy
+#docker-php-ext-install zip
+#docker-php-ext-install xsl
+#pecl install apcu-5.1.21
+
+# Install XDebug (required for coverage)
+pecl install xdebug
+docker-php-ext-enable xdebug
+
+# Run ssh-agent and add private key (/!\ Attention: la configuration du SSH est indispensable pour pouvoir cloner notre repo foselastica)
+eval $(ssh-agent -s)
+mkdir -p ~/.ssh
+chmod 700 ~/.ssh
+echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
+ssh-add <(echo "$SSH_PRIVATE_KEY")
+git config --global user.email "exploitation@opentalent.fr"
+git config --global user.name "git"
+
+# Install composer
+curl -sS https://composer.github.io/installer.sig > installer.sig
+php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
+php composer-setup.php
+php -r "unlink('composer-setup.php'); unlink('installer.sig');"
+
+# Install modules
+php composer.phar install --no-interaction --ignore-platform-reqs