Skip to content

Instantly share code, notes, and snippets.

@nejdetkadir
Last active November 28, 2021 21:26
Show Gist options
  • Save nejdetkadir/47873d3c41f5d09b3023efa67a7cc406 to your computer and use it in GitHub Desktop.
Save nejdetkadir/47873d3c41f5d09b3023efa67a7cc406 to your computer and use it in GitHub Desktop.
Circleci setup for Ruby on Rails application with RSpec & Rubocop.
version: 2.1
orbs:
ruby: circleci/[email protected]
node: circleci/node@2
jobs:
build:
docker:
- image: cimg/ruby:3.0.0-node
steps:
- checkout
- ruby/install-deps
- node/install-packages:
pkg-manager: yarn
cache-key: "yarn.lock"
quality:
docker:
- image: cimg/ruby:3.0.0-node
steps:
- checkout
- ruby/install-deps
- run:
name: Run rubocop
command: bundle exec rubocop --require rubocop-rails
test:
parallelism: 3
docker:
- image: cimg/ruby:3.0.0-node
- image: postgres:14.1
environment:
POSTGRES_USER: user
POSTGRES_DB: db
POSTGRES_PASSWORD: password
POSTGRES_HOST: 127.0.0.1
environment:
BUNDLE_JOBS: "3"
BUNDLE_RETRY: "3"
PGHOST: 127.0.0.1
PGUSER: user
PGPASSWORD: password
RAILS_ENV: test
steps:
- checkout
- ruby/install-deps
- node/install-packages:
pkg-manager: yarn
cache-key: "yarn.lock"
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Database setup
command: bundle exec rails db:schema:load --trace
- run:
name: Run tests
command: bundle exec rspec
workflows:
version: 2
build_and_test:
jobs:
- build
- quality:
requires:
- build
- test:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment