--- version: 2.1 references: bundle_install: &bundle_install run: name: Bundle command: | gem install bundler --no-document && \ bundle config set no-cache 'true' && \ bundle config set jobs '4' && \ bundle config set retry '3' && \ bundle install cache_bundle: &cache_bundle save_cache: key: bundle-<< parameters.ruby_version >>-<< parameters.rails_version >>-{{ checksum "statesman.gemspec" }}-{{ checksum "Gemfile" }} paths: - vendor/bundle restore_bundle: &restore_bundle restore_cache: key: bundle-<< parameters.ruby_version >>-<< parameters.rails_version >>-{{ checksum "statesman.gemspec" }}-{{ checksum "Gemfile" }} steps: &steps - add_ssh_keys - checkout - run: name: "Add dependencies" command: | sudo apt-get update && sudo apt-get install -y sqlite3 libsqlite3-dev - *restore_bundle - *bundle_install - *cache_bundle - run: dockerize -wait tcp://localhost:$DATABASE_DEPENDENCY_PORT -timeout 1m - run: name: Run specs command: | bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) --profile --format progress --format RspecJunitFormatter -o /tmp/circle_artifacts/rspec.xml - run: name: "Rubocop" command: bundle exec rubocop --extra-details --display-style-guide --parallel --force-exclusion - store_artifacts: path: /tmp/circle_artifacts/ - store_test_results: path: /tmp/circle_artifacts/ ruby_versions: &ruby_versions - "2.7" - "3.0" - "3.1" rails_versions: &rails_versions - "5.2.7" - "6.0.4" - "6.1.5" - "7.0.2" - "main" mysql_versions: &mysql_versions - "5.7" psql_versions: &psql_versions - "9.6" jobs: rspec_mysql: working_directory: /mnt/ramdisk parameters: ruby_version: type: string rails_version: type: string mysql_version: type: string docker: - image: cimg/ruby:<< parameters.ruby_version >> environment: CIRCLE_TEST_REPORTS: /tmp/circle_artifacts/ DATABASE_URL: mysql2://foobar:password@127.0.0.1/statesman_test DATABASE_DEPENDENCY_PORT: "3306" - image: cimg/mysql:<< parameters.mysql_version >> environment: MYSQL_ROOT_PASSWORD: password MYSQL_USER: foobar MYSQL_PASSWORD: password MYSQL_DATABASE: statesman_test steps: *steps rspec_postgres: working_directory: /mnt/ramdisk parameters: ruby_version: type: string rails_version: type: string psql_version: type: string docker: - image: cimg/ruby:<< parameters.ruby_version >> environment: CIRCLE_TEST_REPORTS: /tmp/circle_artifacts/ DATABASE_URL: postgres://postgres@localhost/statesman_test DATABASE_DEPENDENCY_PORT: "5432" - image: circleci/postgres:<< parameters.psql_version >> environment: POSTGRES_USER: postgres POSTGRES_DB: statesman_test POSTGRES_PASSWORD: statesman steps: *steps workflows: version: 2 tests: jobs: - rspec_mysql: matrix: parameters: mysql_version: *mysql_versions ruby_version: *ruby_versions rails_version: *rails_versions - rspec_postgres: matrix: parameters: psql_version: *psql_versions ruby_version: *ruby_versions rails_version: *rails_versions