# Generic config to build a gem
version: 2.1

# Checkout with a fetch and pull
checkout_repo: &checkout
  run:
    name: Checkout
    command: 'git config user.name "circleci" && git config user.email "richard.parratt@sharesight.co.nz" && git fetch && git checkout master && git pull && git merge --no-edit $CIRCLE_BRANCH && git status'

# Install Ruby dependencies
run: &bundle_install
  name: Bundle Install
  command: 'gem install bundler && bundle --version && bundle install'

jobs:
  test:
    parameters:
      ruby-version:
        type: string
    docker:
      - image: circleci/ruby:<< parameters.ruby-version >>

    steps:
      - checkout

      - *checkout

      - run: *bundle_install

      - run: bundle exec rubocop

      - run:
          name: 'Test gem'
          command: rake test

# using a matrix to test against multiple Ruby version
# https://circleci.com/docs/2.0/configuration-reference/#matrix-requires-version-21
workflows:
  test:
    jobs:
      - test:
          matrix:
            parameters:
              ruby-version: ["2.7.1", "2.7.3"]

# Generic config to build a gem
version: 2.1

# Checkout with a fetch and pull
checkout_repo: &checkout
  run:
    name: Checkout
    command: 'git config user.name "circleci" && git config user.email "richard.parratt@sharesight.co.nz" && git fetch && git checkout master && git pull && git merge --no-edit $CIRCLE_BRANCH && git status'

# Install Ruby dependencies
run: &bundle_install
  name: Bundle Install
  command: 'gem install bundler && bundle --version && bundle install'

jobs:
  test:
    parameters:
      ruby-version:
        type: string
    docker:
      - image: cimg/ruby:<< parameters.ruby-version >>

    steps:
      - checkout

      - *checkout

      - run: *bundle_install

      - run: bundle exec rubocop

      - run:
          name: 'Test gem'
          command: rake test

# using a matrix to test against multiple Ruby version
# https://circleci.com/docs/2.0/configuration-reference/#matrix-requires-version-21
workflows:
  test:
    jobs:
      - test:
          matrix:
            parameters:
              ruby-version: ["2.7.1", "2.7.3"]

Address image deprecation from 2020
Address image deprecation from 2020
