Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
125 lines (119 sloc) 3.79 KB
version: 2.1
executors:
rails:
docker:
- image: circleci/ruby:2.6.5-node-browsers
environment:
BUNDLE_JOBS: 4
BUNDLE_PATH: vendor/bundle
PGHOST: 127.0.0.1
PGUSER: postgres
RAILS_ENV: test
- image: circleci/postgres:11.2-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: app_prototype_test
POSTGRES_PASSWORD: ""
commands:
bundle-install:
description: Install Ruby gems
steps:
- restore_cache:
keys: # Include fallbacks to increase the likeliness of a cache hit
- gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- gem-cache-{{ arch }}-{{ .Branch }}
- gem-cache-{{ arch }}-
- run:
name: Install gems and remove unused gems
command: |
gem install bundler
bundle check || bundle install
bundle clean --force
- save_cache:
key: gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
yarn-install:
description: Install JavaScript dependencies
steps:
- restore_cache:
name: Restore Yarn cache
keys: # Include fallbacks to increase the likeliness of a cache hit
- yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-{{ arch }}-{{ .Branch }}
- yarn-cache-{{ arch }}-
- run:
name: Install JS dependencies
command: yarn install --cache-folder .yarn-cache
- save_cache:
key: yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- .yarn-cache
db-setup:
description: Set up database
steps:
# Using structure.sql? Install postgresql-client for loading structure.
#- run: sudo apt-get install postgresql-client
- run:
name: Set up database
command: bundle exec rake db:setup
# Ensure sample_data runs without issues (note: data is loaded into the development database)
- run:
name: Seed with sample data
command: bundle exec rake db:sample_data
rspec:
description: Run RSpec tests
steps:
- run:
name: Run RSpec tests in parallel
command: |
circleci tests glob "spec/**/*_spec.rb" > /tmp/rspec_files
TEST_FILES=$(circleci tests split --split-by=timings --timings-type=filename < /tmp/rspec_files)
echo -e "Testing" $(echo $TEST_FILES | wc -w) "of" $(cat /tmp/rspec_files | wc -w) "files on this container.\n"
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out ./test-results/rspec/results.xml -- \
$TEST_FILES
# Save test results, so the the timings can be used in future parallel runs
- store_test_results:
path: ./test-results
# Save the test logs for debugging
- store_artifacts:
path: ./log/test.log
destination: test.log
# Save screenshots for debugging
- store_artifacts:
path: ./tmp/screenshots
jobs:
install_dependencies:
executor: rails
steps:
- checkout
- bundle-install
- yarn-install
static_analysis:
executor: rails
steps:
- checkout
- bundle-install
- yarn-install
# Rubocop compliance
- run: bundle exec rubocop
rspec:
executor: rails
steps:
- checkout
- bundle-install
- yarn-install
- rspec
workflows:
version: 2
build:
jobs:
- install_dependencies
- static_analysis:
requires:
- install_dependencies
- rspec:
requires:
- install_dependencies
You can’t perform that action at this time.