.circleci/config.yml
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
build:
docker:
# Specify the Ruby version you desire here
- image: circleci/ruby:2.7.5-node-browsers
environment:
RAILS_ENV: test
CC_TEST_REPORTER_ID: 92362c9253cd1a4a5a164c83bf5157e6677fc1d91fee9b7a7690c1e1123fd87b
COVERAGE: true
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:11.4-alpine
environment:
POSTGRES_USER: circleci
POSTGRES_DB: ohana_api_test
working_directory: ~/ohana-api
steps:
- checkout
- restore-cache:
key: ohana-api-{{ checksum "Gemfile.lock" }}
- run:
name: Wait for db
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Install dependencies
command: |
gem install bundler
bundle install --deployment --jobs=4 --retry=3 --without development production --path vendor/bundle
sudo apt-get update
sudo apt-get install postgresql-client
- run:
name: Install Code Climate Test Reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
# Store bundle cache
- save-cache:
key: ohana-api-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Test Setup
command: |
psql -U circleci -q -d ohana_api_test -f db/structure.sql -h localhost -p 5432
cp config/application.example.yml config/application.yml
bundle exec rake assets:precompile
- run:
name: Run Tests
command: |
mkdir /tmp/test-results
./cc-test-reporter before-build
bundle exec rspec --format progress
bundle exec haml-lint app/views
- run:
name: Upload Test Results to Code Climate
command: |
./cc-test-reporter format-coverage -t simplecov $CIRCLE_ARTIFACTS/coverage/.resultset.json
./cc-test-reporter upload-coverage
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results