.circleci/config.yml
version: 2.1
executors:
circleci-ruby-executor:
docker:
- image: circleci/ruby:2.5.3-stretch
jobs:
build:
working_directory: ~/santander-cycles
environment:
BUNDLE_PATH: vendor/bundle # path to install gems and use for caching
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
executor: circleci-ruby-executor
steps:
- checkout
- run:
name: Which bundler?
command: bundle -v
- restore_cache:
keys:
# when lock file changes, use increasingly general patterns to restore cache
- v2.5.3-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- v2.5.3-gem-cache-{{ arch }}-{{ .Branch }}-
- v2.5.3-gem-cache-{{ arch }}-
- run: bundle check || bundle install && bundle clean
- save_cache:
paths:
- vendor/bundle
key: v2.5.3-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- run:
name: Install 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
- run:
name: Notify Code Climate of new pending test report
command: |
./tmp/cc-test-reporter before-build
# Test
# This would typically be a build job when using workflows, possibly combined with build
# This is based on your 1.0 configuration file or project settings
- run:
name: Run tests
command: |
bundle exec rspec
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter after-build
deploy:
executor: circleci-ruby-executor
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master