-
-
Save jasonfb/c3a5b01ba2b0125f60270ab8da673255 to your computer and use it in GitHub Desktop.
Sample circle CI config for circleci/ruby@1.0, circleci/node@2, and circleci/browser-tools@1.2.3
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 | |
version: 2.1 # Use 2.1 to enable using orbs and other features. | |
# Declare the orbs that we'll use in our config. | |
# read more about orbs: https://circleci.com/docs/2.0/using-orbs/ | |
orbs: | |
ruby: circleci/ruby@1.0 | |
node: circleci/node@2 | |
browser-tools: circleci/browser-tools@1.2.3 | |
jobs: | |
build: # our first job, named "build" | |
docker: | |
- image: cimg/ruby:3.1.2-browsers # use a tailored CircleCI docker image. | |
auth: | |
username: mydockerhub-user | |
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference | |
- image: redis:6.2.6 | |
steps: | |
- checkout # pull down our git code. | |
- ruby/install-deps # use the ruby orb to install dependencies | |
# use the node orb to install our packages | |
# specifying that we use `yarn` and to cache dependencies with `yarn.lock` | |
# learn more: https://circleci.com/docs/2.0/caching/ | |
- node/install-packages: | |
pkg-manager: yarn | |
cache-key: "yarn.lock" | |
- run: | |
name: Build assets | |
command: bundle exec rails assets:precompile | |
test: # our next job, called "test" | |
parallelism: 1 | |
# here we set TWO docker images. | |
docker: | |
- image: cimg/ruby:3.1.2-browsers # this is our primary docker image, where step commands run. | |
auth: | |
username: mydockerhub-user | |
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference | |
- image: redis:6.2.6 | |
- image: circleci/postgres:9.5-alpine | |
auth: | |
username: mydockerhub-user | |
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference | |
environment: # add POSTGRES environment variables. | |
POSTGRES_USER: circleci-demo-ruby | |
POSTGRES_DB: your-database-app-name | |
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: | |
- browser-tools/install-chrome | |
- browser-tools/install-chromedriver | |
- checkout | |
- ruby/install-deps | |
- node/install-packages: | |
pkg-manager: yarn | |
cache-key: "yarn.lock" | |
- run: | |
name: yarn build | |
command: yarn build | |
# 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: Load schema | |
command: bin/rails db:schema:load RAILS_ENV=test | |
# Run rspec in parallel | |
- ruby/rspec-test | |
# 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