version: 2 workspace_root: &workspace_root ~/zerobounce defaults: &defaults working_directory: *workspace_root docker: - image: circleci/ruby:2.4 attach_workspace: &attach_workspace attach_workspace: at: *workspace_root restore_repo: &restore_repo restore_cache: name: Restore repository keys: - v1-repo-{{ .Branch }}-{{ .Revision }} restore_gems: &restore_gems restore_cache: name: Restore gems keys: - v1-zerobounce-{{ checksum "Gemfile.lock" }} jobs: checkout-code: <<: *defaults steps: - checkout - save_cache: key: v1-repo-{{ .Branch }}-{{ .Revision }} paths: - *workspace_root bundle-dependencies: <<: *defaults steps: - *restore_repo - *restore_gems - run: name: Install Bundler dependencies command: | bin/bundle install --path=vendor/bundle \ --jobs=4 \ --retry=3 - run: name: Setup Code Climate test-reporter command: | mkdir -p tmp/ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter chmod +x ./tmp/cc-test-reporter - save_cache: key: v1-zerobounce-{{ checksum "Gemfile.lock" }} paths: - vendor/bundle - persist_to_workspace: root: *workspace_root paths: - vendor/bundle - tmp/cc-test-reporter run-specs: <<: *defaults parallelism: 2 steps: - *restore_repo - *attach_workspace - run: name: Set bundler path command: bin/bundle --path vendor/bundle - run: name: Run tests command: | bin/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) ./tmp/cc-test-reporter format-coverage \ -t simplecov \ -o tmp/codeclimate.${CIRCLE_NODE_INDEX}.json \ ${CIRCLE_ARTIFACTS}/coverage/.resultset.json - persist_to_workspace: root: *workspace_root paths: - tmp - store_test_results: path: test_results - store_artifacts: path: test_results destination: test-results - store_artifacts: path: coverage destination: test-coverage upload-coverage: <<: *defaults steps: - *attach_workspace - run: name: Upload coverage results to Code Climate command: | ./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 2 -o tmp/codeclimate.total.json ./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json run-rubocop: <<: *defaults steps: - *restore_repo - *attach_workspace - run: name: Set bundler path command: bin/bundle --path vendor/bundle - run: name: Run rubocop command: bin/bundle exec rubocop workflows: version: 2 build-test: jobs: - checkout-code - bundle-dependencies: requires: - checkout-code - run-rubocop: requires: - bundle-dependencies - run-specs: requires: - bundle-dependencies - upload-coverage: requires: - run-specs