.circleci/config.yml

Summary

Maintainability
Test Coverage
# Ruby CircleCI 2.1 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
version: 2.1

orbs:
  ruby: circleci/ruby@1.7.1

jobs:
  build_and_test:
    parameters:
      ruby_version:
        type: string
      elasticsearch_version:
        type: string

    docker:
      - image: cimg/ruby:<< parameters.ruby_version >>
      - image: redis:6.2
      - image: docker.elastic.co/elasticsearch/elasticsearch:<< parameters.elasticsearch_version >>
        environment:
          - xpack.security.enabled: false
          - discovery.type: single-node

    working_directory: ~/app

    steps:
      - checkout
      - run:
          name: Copy config files for Flickr
          command: |
            cp -p config/flickr.yml.example config/flickr.yml
      # Install gems with Bundler
      - ruby/install-deps:
          # Need to clear the gem cache? Set or bump the CACHE_VERSION in your
          # CircleCi project: Project Settings > Environment Variables
          key: gems-ruby-<< parameters.ruby_version >>-v{{ .Environment.CACHE_VERSION }}
      - run:
          name: Prepare Code Climate Test Reporter
          command: |
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter
            ./cc-test-reporter before-build
      - run:
          name: Wait for Elasticsearch
          command: dockerize --wait http://localhost:9200 -timeout 1m
      - ruby/rspec-test:
          # Need to temporarily test with a particular seed? Use:
          # order: rand:123
          order: rand
      - run:
          name: Report Test Results
          command: |
            ./cc-test-reporter after-build

workflows:
  build_and_test:
    jobs:
      - build_and_test:
          name: "Ruby << matrix.ruby_version >>, ES << matrix.elasticsearch_version >>"
          matrix:
            parameters:
              ruby_version:
                - 3.0.6
                - 3.1.4
              elasticsearch_version:
                - 7.17.7
                # not yet compatible with Elasticsearch 8