version: 2 jobs: build: working_directory: /home/circleci/app docker: - image: circleci/ruby:2.7.2-node environment: RACK_ENV: test RAILS_ENV: test COVERAGE: true # CC_TEST_REPORTER_ID: YOUR_REPO_CC_TEST_REPORTER_ID # ENV var set in CircleCI user interface steps: - checkout # libpq-dev: required for compiling the `pg` gem # nodejs: required for asset compilation (see https://github.com/rails/execjs) - run: name: Install apt dependencies command: | sudo apt update -q \ && sudo apt upgrade -q - restore_cache: key: v3-bundler-{{ checksum "Gemfile.lock" }}-{{ arch }} - run: gem install bundler - run: bundle config build.nokogiri --use-system-libraries - run: bundle install --without staging:production --path=vendor/bundle --jobs=4 --retry=3 - save_cache: key: v3-bundler-{{ checksum "Gemfile.lock" }}-{{ arch }} paths: - vendor/bundle - run: name: Collect and filter specs command: | mkdir -p tmp/circleci circleci tests glob "spec/**/*_spec.rb" > tmp/circleci/all_tests.txt circleci tests split --split-by=timings < tmp/circleci/all_tests.txt > tmp/circleci/tests_to_run.txt echo "These specs will be run:" cat tmp/circleci/tests_to_run.txt - run: name: Parallel RSpec command: | bundle exec rspec \ --color \ --format progress \ --require spec_helper \ --format RspecJunitFormatter --out /tmp/rspec/junit.xml \ $(cat tmp/circleci/tests_to_run.txt) # actually not necessary for test results to be collected, but these files # won't show up in the web UI otherwise - store_artifacts: path: /tmp/rspec/ destination: rspec - store_test_results: path: /tmp/rspec/