Created
September 8, 2016 23:43
-
-
Save w0rd-driven/172644e9a3f809dd7529fa5e0697a0af to your computer and use it in GitHub Desktop.
Gitlab CI for Laravel 5.x: Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APP_ENV=test | |
APP_DEBUG=true | |
APP_KEY=SomeRandomString | |
APP_URL=http://localhost | |
DB_CONNECTION=mysql | |
DB_HOST=mysql | |
DB_PORT=3306 | |
DB_DATABASE=homestead | |
DB_USERNAME=homestead | |
DB_PASSWORD=secret | |
CACHE_DRIVER=file | |
SESSION_DRIVER=file | |
QUEUE_DRIVER=sync | |
REDIS_HOST=127.0.0.1 | |
REDIS_PASSWORD=null | |
REDIS_PORT=6379 | |
MAIL_DRIVER=smtp | |
MAIL_HOST=mailtrap.io | |
MAIL_PORT=2525 | |
MAIL_USERNAME=null | |
MAIL_PASSWORD=null | |
MAIL_ENCRYPTION=null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://gitlab.com/nasirkhan/laravel-5-starter, https://gist.github.com/iolson/791fb1c1d1a8cfb5ffa7 and | |
# https://gist.github.com/iolson/5e3695bc5c9f7afafeb3, and finally | |
# https://laracasts.com/discuss/channels/testing/laravel-ci-testing-with-gitlab | |
# Composer stores all downloaded packages in the vendor/ directory. | |
# Do not use the following if the vendor/ directory is commited to | |
# your git repository. | |
cache: | |
paths: | |
- vendor/ | |
- node_modules/ | |
- bower_components/ | |
# Before Tests | |
before_script: | |
- bash ci/docker_setup.sh > /dev/null | |
# Services | |
services: | |
- mysql:latest | |
# Variables | |
variables: | |
WITH_XDEBUG: "1" | |
MYSQL_ROOT_PASSWORD: secret | |
MYSQL_DATABASE: homestead | |
MYSQL_USER: homestead | |
MYSQL_PASSWORD: secret | |
COMPOSER_HOME: /cache/composer | |
# Stages | |
stages: | |
- test | |
# PHP 5.6 FPM | |
php:5.6-fpm: | |
image: php:5.6-fpm | |
stage: test | |
script: | |
- php -v | |
- php vendor/bin/phpunit --colors --debug --coverage-text | |
# PHP 7.0 FPM | |
php:7-fpm: | |
image: php:7-fpm | |
stage: test | |
script: | |
- php -v | |
- php vendor/bin/phpunit --colors --debug --coverage-text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# We need to install dependencies only for Docker | |
[[ ! -e /.dockerenv ]] && [[ ! -e /.dockerinit ]] && exit 0 | |
set -xe | |
# Update packages and install composer and PHP dependencies. | |
apt-get update -yqq | |
apt-get install git zlib1g-dev -yqq | |
# Compile PHP, include these extensions. | |
docker-php-ext-install pdo_mysql zip | |
# Install Composer and project dependencies. | |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
# Ping the mysql container | |
ping -c 3 mysql | |
# Composer install parallel install plugin | |
composer global require "hirak/prestissimo:^0.3" | |
# Composer install project dependencies | |
composer install --no-progress --no-interaction | |
# Copy over testing configuration. | |
cp .env.gitlab .env | |
# Generate an application key. Re-cache. | |
php artisan key:generate | |
php artisan config:cache | |
# Run database migrations. | |
php artisan migrate:refresh | |
# Run database seed. | |
php artisan db:seed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment