# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/ruby/tags/

cache:
  paths:
    - vendor/ruby # cache gems in between builds

before_script:
  - ruby -v # Print out ruby version for debugging
  - gem install bundler  --no-ri --no-rdoc # Bundler is not installed with the image
  # install nproc (coreutils) for bundle -j
  # install git for building the gemspec
  # install make, gcc for building gem native extension (commonmarker)
  # libc-dev for musl-dev dependency (stdlib.h) needed by gcc
  - apk --no-cache add coreutils git make gcc libc-dev
  - bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
  - rake install # install the gem

test:2.4:
  stage: test
  image: ruby:2.4-alpine
  script:
    - rubocop
    - rake test

test:2.5:
  stage: test
  image: ruby:2.5-alpine
  script:
    - rubocop
    - rake test

pages:
  stage: deploy
  image: ruby:2.4-alpine
  script:
    - yard doc
    - mkdir public
    - mv doc/* public/
  artifacts:
    paths:
      - public
  only:
    - master