toptal/database_validations

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1

ruby-env: &ruby-env
  BUNDLE_JOBS: 3
  BUNDLE_RETRY: 3
  BUNDLE_PATH: vendor/bundle
  DB_HOST: 127.0.0.1
  DB_USER: root
  DB_PASSWORD: test

postgres-env: &postgres-env
  POSTGRES_USER: root
  POSTGRES_DB: database_validations_test
  POSTGRES_PASSWORD: test

mysql-env: &mysql-env
  MYSQL_ROOT_HOST: '%'
  MYSQL_ROOT_PASSWORD: test
  MYSQL_DATABASE: database_validations_test

jobs:
  rails42:
    parallelism: 3
    docker:
      - image: circleci/ruby:2.4
        environment:
          <<: *ruby-env
          GEMFILE_PATH: gemfiles/rails42.gemfile

      - image: circleci/postgres:9.6
        environment:
          <<: *postgres-env

      - image: circleci/mysql:5.6
        environment:
          <<: *mysql-env

    steps: &steps
      - checkout

      - run:
          name: Install bundler
          command: gem install bundler

      - run:
          name: Which bundler?
          command: bundle -v

      - run:
          name: Bundle Install
          command: bundle install

      - run:
          name: Wait for PostgreSQL DB
          command: dockerize -wait tcp://localhost:5432 -timeout 2m

      - run:
          name: Wait for MySQL DB
          command: dockerize -wait tcp://localhost:3306 -timeout 2m

      - run:
          name: Run rspec in parallel
          command: |
            bundle exec rspec --profile 10 \
                              --format RspecJunitFormatter \
                              --out test_results/rspec.xml \
                              --format progress \
                              $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)

      - store_test_results:
          path: test_results

  rails52:
    parallelism: 3
    docker:
      - image: circleci/ruby:2.5
        environment:
          <<: *ruby-env
          GEMFILE_PATH: gemfiles/rails52.gemfile

      - image: circleci/postgres:9.6
        environment:
          <<: *postgres-env

      - image: circleci/mysql:5.6
        environment:
          <<: *mysql-env

    steps: *steps

  rails61:
    parallelism: 3
    docker:
      - image: circleci/ruby:2.7
        environment:
          <<: *ruby-env
          GEMFILE_PATH: gemfiles/rails61.gemfile

      - image: circleci/postgres:9.6
        environment:
          <<: *postgres-env

      - image: circleci/mysql:5.6
        environment:
          <<: *mysql-env

    steps: *steps

  railsmaster:
    parallelism: 3
    docker:
      - image: circleci/ruby:latest
        environment:
          <<: *ruby-env
          GEMFILE_PATH: gemfiles/railsmaster.gemfile

      - image: circleci/postgres:9.6
        environment:
          <<: *postgres-env

      - image: circleci/mysql:5.6
        environment:
          <<: *mysql-env

    steps: *steps

workflows:
  version: 2
  rails42:
    jobs:
      - rails42
      - rails52
      - rails61
      - railsmaster