Oddly enough - this is on my todo list (although that's basically infinite...). I think maybe @bashy has poked at this more? :: flutters eyelashes :: ;-)
Mar 1, 2016
32
Level 6
Laravel CI Testing with GitLab
I'd love to set Laravel up on GitLab with CI, however I can not find any tutorials on how to configure the .gitlab-ci.yml file for a basic Laravel 5.2 installation. Does anyone have any experience with this? Currently I'm just on gitlab.com using their shared runners.
Level 6
Alright, I wanted to work with the official PHP docker builds, so here's what I ended up doing. It tests using PHP v5.5, v5.6, and v7 with MySQL v5.6 and v5.7; six tests in total. A test takes about 6-7 minutes on average to compile before running. Thanks for the help!
.gitlab-ci.yml:
before_script:
- bash .gitlab-ci.sh
variables:
MYSQL_DATABASE: project_name
MYSQL_ROOT_PASSWORD: secret
phpunit:php5.5:mysql5.6:
image: php:5.5
services:
- mysql:5.6
script:
- php vendor/bin/phpunit --colors
phpunit:php5.6:mysql5.6:
image: php:5.6
services:
- mysql:5.6
script:
- php vendor/bin/phpunit --colors
phpunit:php7.0:mysql5.6:
image: php:7.0
services:
- mysql:5.6
script:
- php vendor/bin/phpunit --colors
phpunit:php5.5:mysql5.7:
image: php:5.5
services:
- mysql:5.7
script:
- php vendor/bin/phpunit --colors
phpunit:php5.6:mysql5.7:
image: php:5.6
services:
- mysql:5.7
script:
- php vendor/bin/phpunit --colors
phpunit:php7.0:mysql5.7:
image: php:7.0
services:
- mysql:5.7
script:
- php vendor/bin/phpunit --colors
.gitlab-ci.sh:
#!/bin/bash
# Install dependencies only for Docker.
[[ ! -e /.dockerinit ]] && 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
# Generate an application key. Re-cache.
php artisan key:generate
php artisan config:cache
# Run database migrations.
php artisan migrate
.env.testing:
APP_ENV=testing
APP_DEBUG=true
APP_KEY=key
DB_HOST=mysql
DB_DATABASE=project_name
DB_USERNAME=root
DB_PASSWORD=secret
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync
MAIL_DRIVER=log
6 likes
Please or to participate in this conversation.