I ran SystemSpec (RSpec) and Rubocop using CircleCI.
I've compiled the source code that I actually used from basic learning, so I hope it will be helpful.
Teaching materials: Introduction Guide-CircleCI I've just started CircleCI, so I've summarized it in an easy-to-understand manner
I did the officially prepared Introduction Guide --CircleCI to know the basic usage. It is recommended that you can study while moving your hands and it will take about 30 minutes.
Next, I read I've just started CircleCI, so I've summarized it in an easy-to-understand manner. This article describes CircleCI in great detail. After a quick read at first, I reread this article if I had any questions.
Based on the official CircleCI-Public / circleci-demo-ruby-rails I implemented it while referring to [circleCI] Run rubocop and rspec test in cooperation with github with Rails app.
Since the official sample uses the latest version, there were not many references such as Qiita.
This time I will use the latest version: 2.1.
--You must have a github account --You already have a rails project --Mysql is used for the database. --rspec and rubocop are installed and configured
.circleci/config.yml
yml:.circleci/config.yml
version: 2.1
orbs:
  ruby: circleci/[email protected]
jobs:
  build:
    docker:
      - image: circleci/ruby:2.5.1-node-browsers
        environment:
          BUNDLER_VERSION: 2.1.4
    steps:
      - checkout
      - ruby/install-deps
  test:
    parallelism: 3
    docker:
      - image: circleci/ruby:2.5.1-node-browsers
        environment:
          DB_HOST: 127.0.0.1
          RAILS_ENV: test
          BUNDLER_VERSION: 2.1.4
      - image: circleci/mysql:8.0
        command: --default-authentication-plugin=mysql_native_password
        environment:
          MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
          MYSQL_ROOT_HOST: '%'
    steps:
      - checkout
      - ruby/install-deps
      - run: mv config/database.yml.ci config/database.yml 
      - run:
          name: Wait for DB
          command: dockerize -wait tcp://localhost:3306 -timeout 1m
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load
      # Run rspec in parallel
      - ruby/rspec-test
      - ruby/rubocop-check
workflows:
  version: 2
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build
config/database.yml.ci
yml:config/database.yml.ci
test:
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: 'root'
  port: 3306
  host: '127.0.0.1'
  database: ci_test
        Recommended Posts