Last active
September 21, 2021 22:18
-
-
Save peimelo/698126b1c9ff1145f31a331bbce6026b to your computer and use it in GitHub Desktop.
CircleCI - Ruby on Rails
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
# .circleci/config.yml | |
version: 2.1 | |
orbs: | |
ruby: circleci/ruby@1.0 | |
jobs: | |
build: | |
docker: | |
- image: circleci/ruby:2.6.6-stretch-node | |
executor: ruby/default | |
steps: | |
- checkout | |
- ruby/install-deps | |
test: # our next job, called "test" | |
# we run "parallel job containers" to enable speeding up our tests; | |
# this splits our tests across multiple containers. | |
parallelism: 3 | |
# here we set TWO docker images. | |
docker: | |
- image: circleci/ruby:2.6.6-stretch-node # this is our primary docker image, where step commands run. | |
- image: circleci/postgres:9.5-alpine | |
environment: # add POSTGRES environment variables. | |
POSTGRES_USER: circleci-demo-ruby | |
POSTGRES_DB: saudecontrolada_api_test | |
POSTGRES_PASSWORD: '' | |
# environment variables specific to Ruby/Rails, applied to the primary container. | |
environment: | |
BUNDLE_JOBS: '3' | |
BUNDLE_RETRY: '3' | |
PGHOST: 127.0.0.1 | |
PGUSER: circleci-demo-ruby | |
PGPASSWORD: '' | |
RAILS_ENV: test | |
# A series of steps to run, some are similar to those in "build". | |
steps: | |
- checkout | |
- ruby/install-deps | |
# Here we make sure that the secondary container boots | |
# up before we run operations on the database. | |
- 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 Rspec | |
command: RAILS_ENV=test bundle exec rspec --format progress $TEST_FILES | |
# We use workflows to orchestrate the jobs that we declared above. | |
workflows: | |
version: 2 | |
build_and_test: # The name of our workflow is "build_and_test" | |
jobs: # The list of jobs we run as part of this workflow. | |
- build # Run build first. | |
- test: # Then run test, | |
requires: # Test requires that build passes for it to run. | |
- build # Finally, run the build job. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment