version: 2.0 defaults: &defaults docker: - image: circleci/ruby:2.5-stretch-node working_directory: ~/coins_paid jobs: checkout_code: <<: *defaults steps: - checkout - run: mkdir log - save_cache: key: v4-repo-{{ .Environment.CIRCLE_SHA1 }} paths: - ~/coins_paid download_cc_reporter: <<: *defaults steps: - run: name: Download cc-test-reporter command: | mkdir -p cc/ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc/cc-test-reporter chmod +x ./cc/cc-test-reporter - persist_to_workspace: root: ~/coins_paid paths: - cc/cc-test-reporter run_bundler: <<: *defaults steps: - restore_cache: key: v4-repo-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: v4-bundle-{{ checksum "Gemfile" }} - run: echo "export rvm_ignore_gemsets_flag=1" >> ~/.rvmrc - run: sudo apt-get update && sudo apt-get install -y libsodium-dev - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - save_cache: key: v4-bundle-{{ checksum "Gemfile" }} paths: - ~/coins_paid/vendor/bundle run_rspec_tests: <<: *defaults docker: - image: circleci/ruby:2.5-stretch-node environment: RACK_ENV: "test" CIRCLE_ARTIFACTS: "./tmp" steps: - restore_cache: key: v4-repo-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: v4-bundle-{{ checksum "Gemfile" }} - attach_workspace: at: ~/coins_paid - run: sudo apt-get update && sudo apt-get install -y libsodium-dev - run: bundle check --path vendor/bundle - run: bundle exec rspec spec - run: ./cc/cc-test-reporter format-coverage -t simplecov -o cc/codeclimate.rspec.json tmp/coverage/.resultset.json - persist_to_workspace: root: ~/coins_paid paths: - cc/codeclimate.rspec.json upload_cc_coverage: <<: *defaults steps: - attach_workspace: at: ~/coins_paid - run: name: Upload coverage results to Code Climate command: | ./cc/cc-test-reporter upload-coverage -i cc/codeclimate.rspec.json deploy: <<: *defaults steps: - restore_cache: key: v4-repo-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: key: v4-bundle-{{ checksum "Gemfile" }} - run: mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts - run: sudo apt-get update && sudo apt-get install -y libsodium-dev - run: bundle check --path vendor/bundle - run: bundle exec rake deploy:branch_or_label workflows: version: 2 build_test_deploy: jobs: - checkout_code - download_cc_reporter: requires: - checkout_code - run_bundler: requires: - download_cc_reporter - run_rspec_tests: requires: - run_bundler - upload_cc_coverage: requires: - run_rspec_tests