image: "ruby:2.1"

services:
  - mysql:latest
  - postgres:latest
  - redis:latest

variables:
  MYSQL_ALLOW_EMPTY_PASSWORD: "1"

before_script:
  - ./scripts/prepare_build.sh
  - ruby -v
  - which ruby
  - gem install bundler --no-ri --no-rdoc
  - cp config/gitlab.yml.example config/gitlab.yml
  - touch log/application.log
  - touch log/test.log
  - bundle install --without postgres production --jobs $(nproc)  "${FLAGS[@]}"
  - bundle exec rake db:reset db:create RAILS_ENV=test

spec:feature:
  script:
    - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
  tags:
    - ruby
    - mysql

spec:api:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
  tags:
    - ruby
    - mysql

spec:models:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
  tags:
    - ruby
    - mysql

spec:lib:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
  tags:
    - ruby
    - mysql

spec:services:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
  tags:
    - ruby
    - mysql

spec:benchmark:
  script:
    - RAILS_ENV=test bundle exec rake spec:benchmark
  tags:
    - ruby
    - mysql
  allow_failure: true

spec:other:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
  tags:
    - ruby
    - mysql

spinach:project:half:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
  tags:
    - ruby
    - mysql

spinach:project:rest:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
  tags:
    - ruby
    - mysql

spinach:other:
  script:
    - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
  tags:
    - ruby
    - mysql

teaspoon:
  script:
    - RAILS_ENV=test bundle exec teaspoon
  tags:
    - ruby
    - mysql

rubocop:
  script:
    - bundle exec rubocop
  tags:
    - ruby
    - mysql

brakeman:
  script:
    - bundle exec rake brakeman
  tags:
    - ruby
    - mysql

flog:
  script:
    - bundle exec rake flog
  tags:
    - ruby
    - mysql

flay:
  script:
    - bundle exec rake flay
  tags:
    - ruby
    - mysql

bundler:audit:
  script: 
    - "bundle exec bundle-audit update"
    - "bundle exec bundle-audit check"
  tags:
    - ruby
    - mysql
  allow_failure: true
