Skip to content

Instantly share code, notes, and snippets.

@raymadrona
Last active July 26, 2018 07:36
Show Gist options
  • Save raymadrona/95d2112f574971f75447a48ec4728cd5 to your computer and use it in GitHub Desktop.
Save raymadrona/95d2112f574971f75447a48ec4728cd5 to your computer and use it in GitHub Desktop.
Laravel Gitlab Continuous Integration (CI) Configuration Scripts with PHP 7.2 and MySQL 5.7
#!/bin/bash
# Install dependencies only for Docker.
[[ ! -e /.dockerinit ]] && [[ ! -e /.dockerenv ]] && exit 0
set -xe
# Update packages and install composer and PHP dependencies.
apt-get update -yqq > /dev/null
apt-get install wget 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 > /dev/null
# Compile PHP, include these extensions.
docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache bcmath zip > /dev/null
# Install composer dependencies
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 global require "hirak/prestissimo:^0.3"
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
cache:
paths:
- vendor/
before_script:
- bash .gitlab-ci.sh
variables:
MYSQL_DATABASE: testing
MYSQL_ROOT_PASSWORD: secret
phpunit:php7.2:mysql5.7:
image: php:7.2
services:
- mysql:5.7
script:
- php vendor/bin/phpunit --colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment