diff --git a/.gitlab-ci.sh b/.gitlab-ci.sh index bc968b9b..dde4a291 100644 --- a/.gitlab-ci.sh +++ b/.gitlab-ci.sh @@ -1,31 +1,31 @@ -#!/bin/bash - -# Install dependencies only for Docker. -[[ ! -e /.dockerenv ]] && exit 0 -set -xe - -# Update packages and install composer and PHP dependencies. -apt-get update -yqq -apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq - -# Compile PHP, include these extensions. -docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache - -# Install Composer and project dependencies. -curl -sS https://getcomposer.org/installer | php -php composer.phar install - -# Copy over testing configuration. -cp .env-example .env - -# Install xdebug -pecl install xdebug && docker-php-ext-enable xdebug - -# Generate an application key. Re-cache. -php artisan key:generate -php artisan config:cache -php artisan config:clear -php artisan optimize - -# Run database migrations with seeder +#!/bin/bash + +# Install dependencies only for Docker. +[[ ! -e /.dockerenv ]] && exit 0 +set -xe + +# Update packages and install composer and PHP dependencies. +apt-get update -yqq +apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq + +# Compile PHP, include these extensions. +docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache + +# Install Composer and project dependencies. +curl -sS https://getcomposer.org/installer | php +php composer.phar install + +# Copy over testing configuration. +cp .env.testing .env + +# Install xdebug +pecl install xdebug && docker-php-ext-enable xdebug + +# Generate an application key. Re-cache. +php artisan key:generate +php artisan config:cache +php artisan config:clear +php artisan optimize + +# Run database migrations with seeder php artisan migrate:refresh --seed \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2570279..940f9e0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,47 +1,17 @@ -image: registry.gitlab.com/ciefworldwidesdnbhd/exchange:latest - before_script: - - mysql -u root - - CREATE USER 'francesco'@'localhost' IDENTIFIED BY 'some_pass'; - - CREATE DATABASE exchange; - - GRANT ALL PRIVILEGES ON exchange.* TO 'francesco'@'localhost'; - - quit; - -services: - - mysql:5.7 - -variables: - MYSQL_DATABASE: exchange - MYSQL_ROOT_PASSWORD: some_pass - DB_HOST: mysql - DB_USERNAME: francesco - + - bash .gitlab-ci.sh stages: - - test - - deploy - -unit_test: - stage: test + - testing + - staging +variables: + MYSQL_DATABASE: default + MYSQL_USER: default + MYSQL_PASSWORD: secret + MYSQL_ROOT_PASSWORD: root +unitTesting: + stage: testing + image: php:7.0.13 + services: + - mysql:5.7 script: - - cp .env-example .env - - composer install - - php artisan key:generate - - php artisan migrate - - vendor/bin/phpunit - -deploy_production: - stage: deploy - script: - - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - - eval $(ssh-agent -s) - - ssh-add <(echo "$SSH_PRIVATE_KEY") - - mkdir -p ~/.ssh - - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - - - ~/.composer/vendor/bin/envoy run deploy - environment: - name: production - url: http://192.168.1.1 - when: manual - only: - - master \ No newline at end of file + - vendor/bin/phpunit --coverage-text --colors=never --configuration phpunit.xml \ No newline at end of file