├── .env.testing ├── .gitlab-ci.sh ├── .gitlab-ci.yml └── README.md /.env.testing: -------------------------------------------------------------------------------- 1 | APP_ENV=testing 2 | APP_DEBUG=true 3 | APP_KEY=w7VQXeA7U31DCdh1U39lpRz0iD7i0oCI 4 | APP_URL=http://yourapp.url 5 | 6 | DB_HOST=mysql 7 | DB_DATABASE=database_name 8 | DB_USERNAME=root 9 | DB_PASSWORD=secret 10 | 11 | -------------------------------------------------------------------------------- /.gitlab-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install dependencies only for Docker. 4 | [[ ! -e /.dockerenv ]] && exit 0 5 | set -xe 6 | 7 | # Update packages and install composer and PHP dependencies. 8 | apt-get update -yqq 9 | 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 10 | 11 | # Compile PHP, include these extensions. 12 | docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache 13 | 14 | # Install Composer and project dependencies. 15 | curl -sS https://getcomposer.org/installer | php 16 | php composer.phar install 17 | 18 | # Copy over testing configuration. 19 | cp .env.testing .env 20 | 21 | # Generate an application key. Re-cache. 22 | php artisan key:generate 23 | php artisan config:cache 24 | 25 | # Run database migrations. 26 | php artisan migrate 27 | 28 | # Run database seeder 29 | php artisan db:seed --class=UserTableSeeder 30 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - bash .gitlab-ci.sh 3 | 4 | variables: 5 | MYSQL_DATABASE: database_name 6 | MYSQL_ROOT_PASSWORD: secret 7 | 8 | phpunit:php5.5:mysql5.6: 9 | image: php:5.5 10 | services: 11 | - mysql:5.6 12 | script: 13 | - php vendor/bin/phpunit --colors 14 | 15 | phpunit:php5.6:mysql5.6: 16 | image: php:5.6 17 | services: 18 | - mysql:5.6 19 | script: 20 | - php vendor/bin/phpunit --colors 21 | 22 | phpunit:php5.5:mysql5.7: 23 | image: php:5.5 24 | services: 25 | - mysql:5.7 26 | script: 27 | - php vendor/bin/phpunit --colors 28 | 29 | phpunit:php5.6:mysql5.7: 30 | image: php:5.6 31 | services: 32 | - mysql:5.7 33 | script: 34 | - php vendor/bin/phpunit --colors 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel - Gitlab CI 2 | 3 | Laravel 5 Gitlab Continous Integration Setup. Build test will run automatically after you have commited your changes to gitlab 4 | 5 | # Method 6 | 7 | You may download or copy these files to your laravel root directory. Modify setup to your need. 8 | 9 | # Reference 10 | 11 | 1. https://laracasts.com/discuss/channels/testing/laravel-ci-testing-with-gitlab 12 | 2. https://about.gitlab.com/gitlab-ci/ 13 | --------------------------------------------------------------------------------