Last active
May 18, 2023 00:09
-
-
Save nashirox/e26a13889da1ac69d525909981d2c390 to your computer and use it in GitHub Desktop.
CircleCI config for Rails 6 + Ruby 2.6 + Postgres + Redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
build: | |
working_directory: ~/my-app | |
docker: | |
- image: circleci/ruby:2.6.3-node-browsers | |
environment: | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
DATABASE_URL: postgres://postgres:password@localhost:5432/tech_cast_test | |
RAILS_ENV: test | |
REDIS_URL: redis://127.0.0.1:6379 | |
- image: circleci/postgres:11-alpine | |
- image: circleci/redis:3.2-alpine | |
steps: | |
- checkout | |
# Install dependencies for Ruby Gems | |
- restore_cache: | |
keys: | |
- my-app-bundle-v1-{{ checksum "Gemfile.lock" }} | |
- my-app-bundle-v1- | |
- run: | |
name: Configure Bundler | |
command: | | |
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV | |
source $BASH_ENV | |
gem install bundler | |
- run: | |
name: Bundle Install | |
command: bundle check || bundle install | |
- save_cache: | |
key: my-app-bundle-v1-{{ checksum "Gemfile.lock" }} | |
paths: | |
- vendor/bundle | |
# Preparing database | |
- run: | |
name: Wait for DB | |
command: dockerize -wait tcp://127.0.0.1:5432 -timeout 1m | |
- run: | |
name: Database setup | |
command: bin/rails db:create db:schema:load --trace | |
# Run test suits | |
- run: | |
name: Run rubocop in parallel | |
command: bundle exec rubocop --parallel --config .rubocop.yml | |
- run: | |
name: Run rspec in parallel | |
command: | | |
bundle exec rspec --profile 10 \ | |
--format RspecJunitFormatter \ | |
--out /tmp/test-results/rspec.xml \ | |
--format progress \ | |
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) | |
# Save artifacts | |
- store_test_results: | |
path: /tmp/test-results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment