From 22831bebaf23ba6cb2133105e286bee4dfde6137 Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Thu, 13 Jul 2017 14:39:26 +0200 Subject: [PATCH] test ci --- .gitlab-ci.yml | 44 +++++++++++++++++++++++++++++++++++ ci/docker_install_database.sh | 14 +++++++++++ ci/docker_install_php.sh | 14 +++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 ci/docker_install_database.sh create mode 100644 ci/docker_install_php.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000000..97fd16969a4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +services: + - postgres:latest + +variables: + POSTGRES_DB: "MaarchCourrier" + POSTGRES_USER: maarch + POSTGRES_PASSWORD: "" + +stages: + - test + +before_script: + - apt-get update > /dev/null + - apt-get install wget -yqq > /dev/null + - apt-get install npm -yqq > /dev/null + - apt-get install git -yqq > /dev/null + - bash ci/docker_install_php.sh > /dev/null + - bash ci/docker_install_database.sh > /dev/null + - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > 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');" + - php composer.phar install + - mv composer.phar /usr/local/bin/composer + - chmod +x /usr/local/bin/composer + +job_php-7.0: + image: php:7.0-apache + stage: test + script: + - mkdir -p /var/www/html/ + - cp -R /builds/maarch/MaarchCourrier/ /var/www/html/ + - cd /var/www/html/MaarchCourrier + - mkdir -p /var/www/html/MaarchCourrier + - composer -n install + - npm install --production + - sed 's/<databaseserver>.*<\/databaseserver>/<databaseserver>postgres<\/databaseserver>/;s/<databasepassword>.*<\/databasepassword>/<databasepassword><\/databasepassword>/;s/<databasename>.*<\/databasename>/<databasename>MaarchCourrier<\/databasename>/;s/<databaseuser>.*<\/databaseuser>/<databaseuser>maarch<\/databaseuser>/' apps/maarch_entreprise/xml/config.xml.default > apps/maarch_entreprise/xml/config.xml + - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar + - chmod +x /usr/local/bin/phpunit + #- cd App/MaarchRM + - phpunit --coverage-text -c phpunit.xml + only: + - gitlab-ci-test diff --git a/ci/docker_install_database.sh b/ci/docker_install_database.sh new file mode 100644 index 00000000000..49391be80e6 --- /dev/null +++ b/ci/docker_install_database.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# We need to install dependencies only for Docker +[[ ! -e /.dockerenv ]] && exit 0 + +set -xe + +apt-get install postgresql-client -yqq + +#export PGPASSWORD=$POSTGRES_PASSWORD + +psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/MaarchCourrier/sql/structure.sql +psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/MaarchCourrier/sql/data_fr.sql + diff --git a/ci/docker_install_php.sh b/ci/docker_install_php.sh new file mode 100644 index 00000000000..977308c0f0b --- /dev/null +++ b/ci/docker_install_php.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# We need to install dependencies only for Docker +[[ ! -e /.dockerenv ]] && exit 0 + +set -xe + +apt-get install -y libpq-dev libxml2-dev libxslt1-dev \ +&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ +&& docker-php-ext-install pdo_pgsql pgsql xsl zip +#&& pecl install xdebug \ +#&& docker-php-ext-enable xdebug + + -- GitLab