Run SystemSpec (RSpec) and Rubocop on CircleCI

Introduction

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.

Basic learning

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.

CircleCI implementation

References

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.

Premise

--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

File to create

.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

Run SystemSpec (RSpec) and Rubocop on CircleCI
Run Rubocop and RSpec on CircleCI and deploy to ECS
Compile and run Java on the command line
Notes on creating a many-to-many Factory with Rspec and testing it with SystemSpec [RSpec, FactoryBot]
Run Ruby on Rails RSpec tests with GitHub Actions
Run STS4 on Mac
Test run on rails
Run PostgreSQL on Java
SystemSpec introduction and writing
Run Processing on Ant
Run tiscamera on Ubuntu 18.04
Run phpunit on Docker
Until you run Quarkus and run docker image on Amazon ECS
How to run React and Rails on the same server