image: 'ruby:2.3'

.test_job: &test_job
  environment: testing
  cache:
    paths:
      - cache/bundler
  before_script:
    - bundle install --without development -j $(nproc) --path=cache/bundler
  tags:
    - ruby

test:rubocop:
  <<: *test_job
  script: bundle exec rubocop
  only:
    - dev

test:rspec:
  <<: *test_job
  script: bundle exec rspec
  artifacts:
    paths:
      - coverage/

pages:
  stage: deploy
  dependencies:
    - test:rspec
  script:
    - mv coverage/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master

deploy:rubygems:
  stage: deploy
  dependencies:
    - test:rspec
  before_script:
    - gem install dpl
  script:
    - dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
  only:
    - tag

.test_job: &test_job
  environment: testing
  cache:
    paths:
      - cache/bundler
  before_script:
    - bundle install --without development -j $(nproc) --path=cache/bundler
  tags:
    - ruby

.test_job_2_3: &test_job_2_3
  image: 'ruby:2.3'

.test_job_2_4: &test_job_2_4
  image: 'ruby:2.4'

test:rubocop_2_3:
  <<: *test_job_2_3
  script: bundle exec rubocop
  only:
    - dev

test:rubocop_2_4:
  <<: *test_job_2_4
  script: bundle exec rubocop
  only:
    - dev

test:rspec_2_3:
  <<: *test_job_2_3
  script: bundle exec rspec
  artifacts:
    paths:
      - coverage/

test:rspec_2_4:
  <<: *test_job_2_4
  script: bundle exec rspec
  artifacts:
    paths:
      - coverage/

pages:
  stage: deploy
  dependencies:
    - test:rspec_2_4
  script:
    - mv coverage/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master

deploy:rubygems:
  stage: deploy
  dependencies:
    - test:rspec_2_4
  before_script:
    - gem install dpl
  script:
    - dpl --provider=rubygems --api-key=$RUBYGEMS_API_KEY
  only:
    - tag

Test multiple ruby versions (2.3 and 2.4)
Test multiple ruby versions (2.3 and 2.4)
