Skip to content

Instantly share code, notes, and snippets.

@einnar82
Last active February 24, 2020 02:17
Show Gist options
  • Save einnar82/d15249a949b2381a803d4e814b291695 to your computer and use it in GitHub Desktop.
Save einnar82/d15249a949b2381a803d4e814b291695 to your computer and use it in GitHub Desktop.
Basic CI / CD config file in Gitlab
image: registry.gitlab.com/sample/sample-repo:latest
stages:
- preparation
- building
- testing
variables:
MYSQL_DATABASE: api
MYSQL_ROOT_PASSWORD: password
DB_HOST: mysql
DB_USERNAME: root
composer:
stage: preparation
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.qa .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 1 days
when: always
cache:
paths:
- vendor/
only:
- master
db-seeding:
stage: building
services:
- name: mysql:8.0
alias: usp
command: ["--default-authentication-plugin=mysql_native_password"]
# Download the artifacts for these jobs
dependencies:
- composer
script:
- php artisan migrate:fresh --path=database/migrations/usp
artifacts:
paths:
- storage/logs # for debugging
expire_in: 1 days
when: always
only:
- master
phpunit:
stage: testing
services:
- name: mysql:8.0
command: ["--default-authentication-plugin=mysql_native_password"]
# Download the artifacts for these jobs
dependencies:
- composer
- db-seeding
script:
- php -v
- php artisan optimize:clear
- php artisan config:cache
- touch database/database.sqlite
- vendor/bin/phpunit
timeout: 3h
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure
only:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment