.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:
environment:
APP_SECRET: eff4949db97d2f67e375b25784984a4c36bb3d7103a4a32562204cba199b01919903635efb901b78f04c5bb55ef5079fca664b35a03b5c59eb6c2721972251c5
DEVISE_SECRET: 2af89dd48125b17425532c09c78c051923b0574ac3a1175bbf18c40c8c147c2ba54736323d436b11003a8cc6ef18165a46d7128cfc672f14ca611615e13ba7f4
GRAPHQL_URL: /graphql
REDIS_NAMESPACE: cortex_test
CACHE_URL: redis://localhost:6379/0/cache
SESSION_STORE_URL: redis://localhost:6379/0/cache
ELASTICSEARCH_ADDRESS: localhost:9200
DATABASE_NAME: cortex_starter_test
DATABASE_USERNAME: root
DATABASE_HOST: localhost
DATABASE_PORT: 5432
docker:
# specify the version you desire here
- image: circleci/ruby:2.5.1-node-browsers
# 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:10.4-alpine
- image: redis:4.0-alpine
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.10
environment:
xpack.security.enabled: false
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
- run:
name: install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.3.0
- run:
name: Wait for Postgres
command: dockerize -wait tcp://localhost:5432 -timeout 2m
- run:
name: Wait for Redis
command: dockerize -wait tcp://localhost:6379 -timeout 2m
- run:
name: Wait for ElasticSearch
command: dockerize -wait tcp://localhost:9200 -timeout 2m
# Database setup
- run: spec/dummy/bin/setup
# run tests!
- run:
name: run tests
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
spec/dummy/bin/rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results