doximity/es-elasticity

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1

executors:
  # used for building the gem
  ruby-latest:
    resource_class: small
    docker:
      - image: cimg/ruby:3.1
        environment:
          BUNDLE_VERSION: '~> 2.3.4'

  # used for testing the gem:
  ruby_2_7:
    resource_class: small
    docker:
      - image: cimg/ruby:2.7
        environment:
          BUNDLE_VERSION: '~> 2.3.4'
      - image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
        environment:
          - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
          - discovery.type=single-node
          - xpack.security.enabled=false
  ruby_3_0:
    resource_class: small
    docker:
      - image: cimg/ruby:3.0
        environment:
          BUNDLE_VERSION: '~> 2.3.4'
      - image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
        environment:
          - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
          - discovery.type=single-node
          - xpack.security.enabled=false

  ruby_3_1:
    resource_class: small
    docker:
      - image: cimg/ruby:3.1
        environment:
          BUNDLE_VERSION: '~> 2.3.4'
      - image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
        environment:
          - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
          - discovery.type=single-node
          - xpack.security.enabled=false

# yaml anchor filters
master_only: &master_only
  filters:
    branches:
      only: master
    tags:
      ignore: /.*/
pr_only: &pr_only
  filters:
    branches:
      ignore: master
    tags:
      ignore: /.*/
version_tags_only: &version_tags_only
  filters:
    branches:
      ignore: /.*/
    tags:
      only: /^v.*/

jobs:
  build_2_7:
    executor: ruby_2_7
    steps:
      - checkout
      - run:
          name: Install Bundler specific version
          command: |
            gem install bundler --version "${BUNDLE_VERSION}" --force
      - restore_cache:
          keys:
            - v3-bundle-ruby_2_7-{{ checksum "Gemfile.lock" }}
      - run:
          name: Install Ruby Dependencies
          command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
      - save_cache:
          key: v3-bundle-ruby_2_7-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - run:
          name: Wait for ElasticSearch
          command: dockerize -wait http://127.0.0.1:9200 -timeout 1m
      - run:
          name: Run Tests
          command: bundle exec rspec
      - persist_to_workspace:
          root: .
          paths:
            - vendor/bundle
  build_3_0:
    executor: ruby_3_0
    steps:
      - checkout
      - run:
          name: Install Bundler specific version
          command: |
            gem install bundler --version "${BUNDLE_VERSION}" --force
      - restore_cache:
          keys:
            - v3-bundle-ruby_3_0-{{ checksum "Gemfile.lock" }}
      - run:
          name: Install Ruby Dependencies
          command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
      - save_cache:
          key: v3-bundle-ruby_3_0-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - run:
          name: Wait for ElasticSearch
          command: dockerize -wait http://127.0.0.1:9200 -timeout 1m
      - run:
          name: Run Tests
          command: bundle exec rspec
      - persist_to_workspace:
          root: .
          paths:
            - vendor/bundle

  build_3_1:
    executor: ruby_3_1
    steps:
      - checkout
      - run:
          name: Install Bundler specific version
          command: |
            gem install bundler --version "${BUNDLE_VERSION}" --force
      - restore_cache:
          keys:
            - v3-bundle-ruby_3_1-{{ checksum "Gemfile.lock" }}
      - run:
          name: Install Ruby Dependencies
          command: bundle check --path=vendor/bundle || bundle install --local --frozen --path=vendor/bundle --jobs=4 --retry=3
      - save_cache:
          key: v3-bundle-ruby_3_1-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - run:
          name: Wait for ElasticSearch
          command: dockerize -wait http://127.0.0.1:9200 -timeout 1m
      - run:
          name: Run Tests
          command: bundle exec rspec
      - persist_to_workspace:
          root: .
          paths:
            - vendor/bundle

workflows:
  version: 2
  trunk:
    jobs:
      - build_2_7:
          <<: *master_only
      - build_3_0:
          <<: *master_only
      - build_3_1:
          <<: *master_only

  pull-requests:
    jobs:
      - build_2_7:
          <<: *pr_only
      - build_3_0:
          <<: *pr_only
      - build_3_1:
          <<: *pr_only

  final-release:
    jobs:
      - build_2_7:
          <<: *version_tags_only
      - build_3_0:
          <<: *version_tags_only
      - build_3_1:
          <<: *version_tags_only