language: ruby
cache:
  bundler: true
  yarn: true
  directories:
    - node_modules
    - public/assets
    - public/packs-test
    - tmp/cache/babel-loader
dist: trusty
sudo: false

notifications:
  email: false

env:
  global:
    - LOCAL_DOMAIN=cb6e6126.ngrok.io
    - LOCAL_HTTPS=true
    - RAILS_ENV=test
    - PARALLEL_TEST_PROCESSORS=2
    - ALLOW_NOPAM=true

addons:
  postgresql: 9.4
  apt:
    sources:
      - trusty-media
      - sourceline: deb https://dl.yarnpkg.com/debian/ stable main
        key_url: https://dl.yarnpkg.com/debian/pubkey.gpg
    packages:
      - ffmpeg
      - libicu-dev
      - libprotobuf-dev
      - protobuf-compiler
      - yarn

rvm:
  - 2.4.3
  - 2.5.1

services:
  - redis-server

install:
  - nvm install
  - bundle install --path=vendor/bundle --with pam_authentication --without development production --retry=3 --jobs=16
  - yarn install

# https://github.com/travis-ci/travis-ci/issues/9333
before_install:
  - gem install bundler

before_script:
  - travis_wait ./bin/rails parallel:create parallel:load_schema parallel:prepare assets:precompile

script:
  - travis_retry bundle exec parallel_test spec/ --group-by filesize --type rspec
  - yarn run test:jest
  - bundle exec i18n-tasks check-normalized && bundle exec i18n-tasks unused
