diff --git a/.circleci/config.yml b/.circleci/config.yml index 6554e1f..328d592 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,26 +1,68 @@ # Use the latest 2.1 version of CircleCI pipeline process engine. # See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 - +orbs: + ruby: circleci/ruby@1.8.0 + node: circleci/node@2 # Define a job to be invoked later in a workflow. # See: https://circleci.com/docs/2.0/configuration-reference/#jobs jobs: - say-hello: + build: # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor docker: - - image: cimg/base:stable + - image: cimg/ruby:2.7.2-node + auth: + username: mydockerhub-user + password: $DOCKERHUB_PASSWORD # Add steps to the job # See: https://circleci.com/docs/2.0/configuration-reference/#steps steps: - checkout + - ruby/install-deps + + test: + parallelism: 3 + docker: + - image: cimg/ruby:2.7.2-node + auth: + username: mydockerhub-user + password: $DOCKERHUB_PASSWORD + - image: circleci/postgres:9.5-alpine + auth: + username: mydockerhub-user + password: $DOCKERHUB_PASSWORD + environment: + POSTGRES_USER: circleci-demo-ruby + POSTGRES_DB: rails_blog_test + POSTGRES_PASSWORD: "" + environment: + BUNDLE_JOBS: "3" + BUNGLE_RETRY: "3" + PGHOST: 127.0.0.1 + PGUSER: circleci-demo-ruby + PGPASSWORD: "" + RAILS_ENV: test + + steps: + - checkout + - ruby/install-deps + - run: + name: wait for db + command: dockerize -wait tcp://localhost:5432 -timeout 1m + - run: + name: database setup + command: bundle exec rake db:{create,migrate} - run: - name: "Say hello" - command: "echo Hello, World!" + name: run tests + command: bundle exec rspec # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows workflows: - say-hello-workflow: + build-and-test: jobs: - - say-hello + - build + - test: + requires: + - build \ No newline at end of file