services:
  - postgres

variables:
  POSTGRES_DB: portalmec_test
  POSTGRES_USER: portalmec
  POSTGRES_PASSWORD: 123mudar

stages:
  - test
  - deploy

before_script:
  - apt-get update -y
  - apt-get install default-jre postgresql-client -y
  # official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
  - export PGPASSWORD=$POSTGRES_PASSWORD
  - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
  # gems
  - gem install bundler
  - bundle install --jobs $(nproc) --path=/cache/bundler

test:
  stage: test
  script:
    - bundle exec rake db:migrate:reset RAILS_ENV=test
    - rake test
  tags:
    - ruby
    - postgres
    - elasticsearch
    - redis

#deploy:
#  stage: deploy
#  script:
#    - mina deploy
#  only:
#    - master
#  tags:
#    - ruby
#    - postgres
#    - elasticsearch
#    - redis