[RUBY] Circle CI environment construction


In this article, I'm a Circle CI beginner, and I'll summarize how to run Circle CI in the cloud environment (run a test every time you push with git).

Circle CI environment construction

1) Cooperation with GitHub

Circle CI can be linked with two services, GitHub and Bitbucket, but I think that there are more links with GitHub, so I will describe how to do it here.

As a method, please press the link button from the CircleCI site while logged in to ** GitHub ** and proceed according to the procedure.

2) Add project

After authentication on GitHub is completed, create a GitHub project (repository) on CircleCI as well. It seems that the method of adding a project is different depending on whether it is a personal repository, an organization repository, or a private repository, but here, the method for personal + public repository is described.

3) CircleCI execution environment

Ultimately, the goal is to run CircleCI in a cloud environment. To do this, we'll start by running it in a local environment.

4) Local job execution

A ** job ** is a collection of steps.

** Step ** is a list of commands executed by CircleCI.

You can run tests to build an execution environment from scratch by running a job, delete it when you're done, and so on. This area is an introductory knowledge of CircleCI, so it is easy to understand by referring to the following articles.

I've just started CircleCI, so I've summarized it in an easy-to-understand manner

Let's create an environment for local job execution!

4-1) Installation of Circle CLI

Jobs are executed in the local environment using the Circle CLI. Circle CLI runs on the Docker container, so if you haven't installed Docker yet, install it first. By the way, with CircleCI, if you have basic knowledge of Docker, it is basically okay, so it is recommended to work after touching Docker lightly.

Now, type the following command to install it.


~ % curl -fLSs https://circle.ci/cli | bash

If the installation is successful, the following message will be displayed.


Starting installation.
Installing CircleCI CLI v0.1.5879
Installing to /usr/local/bin

The CircleCI CLI installation is complete. However, if you see the following message, you need to update.


You are running 0.1.5879
A new release is available (0.1.6949)
You can update with `circleci update install`

When this message is displayed, execute the circleci update install command to update.

4-2) Creating a config.yml file

You need to create a .circleci folder in your app directory and a config.yml file in that directory to do the job. If you do not write the correct syntax in YAML format in this file, you will not be able to execute the top part.

Execute the following commands in order.


% mkdir -p .circleci
% touch .circleci/config.yml

If you have successfully created it, you can check the following with the ls -al command.


total 0
drwr-xr-x 3 xxxxx xxx 96 8 3 18:13 .
drwr-xr-x 20 xxxxx xxx 640 8 3 18:11 ..
drwr-xr-x 2 xxxx xxx 64 8 3 18:13 .circlci

If it is displayed like this, it is successful.

4-3) Validation of config.yml

The CircleCI CLI provides commands to check for syntax and configuration errors. For example, ruby's CircleCI syntax is as follows. This notation is a slightly customized version of the official one. ** The notation is officially prepared for each language **, so please check it.


version: 2.1
  ruby: circleci/[email protected] 

      - image: circleci/ruby:2.6.5-stretch-node
    executor: ruby/default
      - checkout
      - run: gem install bundler:2.2.3
      - run:
          name: Which bundler?
          command: bundle -v
      - ruby/bundle-install

If you try to execute the validation command on this, you will see how.


% circleci config validate
config file at .circleci/config.yml is valid.

If it is displayed like this, there is no error and you can see that the grammar and settings are correct. By the way, if there is an error, the following will be displayed.


Cause of error

Create a file, write it, and run it once before running!

4-4) Job execution

Use the circleci local execute command to execute the job.


% circleci local execute
Docker image digest: sha256:9c32926d78c37f0c050a02dd13dc1596b6e4621b1df9362cd51368fb957951a0


====>> Preparing environment variables
Using build environment variables:


Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:


If you see Success!, Your local job is successful.

Check in the cloud

Once done, try pushing your changes on Github. Next, let's go to the CircleCI site and check it. If the [success] part of the image below is [Runnin], it means that you are running the test. If this display is [Failed], there is an error, so let's check the error. c8dd22412e019b44a8a74420f056d2a8.png

This is the end of environment construction.


"Introduction to CircleCI Practice-Both development speed and quality brought about by CI/CD"

Recommended Posts

Circle CI environment construction
[Java] Environment construction
Java environment construction
[Spring] Environment construction
Docker environment construction
Penronse environment construction [Windows]
[Environment construction] Eclipse installation
[Flutter] Ubuntu 20.04 environment construction
Rails Docker environment construction
CI / CD practice for beginners --Part1 --Environment construction
java development environment construction
Rails6 development environment construction [Mac]
Rails engineer environment construction ruby2.7.1
EC-CUBE4 environment construction (local edition)
I tried node-jt400 (Environment construction)
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
MySQL 5.7 (Docker) environment construction memo
JavaFX environment construction in Java 13
Redmine (Docker) environment construction memo
[Docker] Rails 5.2 environment construction with docker
AtCoder Challenge Environment Construction (Java 8)
Offline environment construction Ruby edition
Docker × Spring Boot environment construction
[Super easy] Ruby environment construction
[Rails / MySQL] Mac environment construction
[Docker] postgres, pgadmin4 environment construction
Laravel environment construction (Ubuntu 18.04 LTS)
React environment construction with Docker
Offline environment construction CentOS edition
Rails + MySQL environment construction with Docker
[Windows] WSL2 + Ubuntu + Node.js environment construction
Node.js environment construction with Docker Compose
◆ Spring Boot + gradle environment construction memo
Environment construction with Docker for beginners
Laravel + Docker Laradock usage environment construction
[Unity] Android development environment construction procedure
Make a language! (JavaCC environment construction)
[Circle CI 2.0] Set to support JavaScript
Ruby on Rails 6.0 environment construction memo
[Environment construction with Docker] Rails 6 & MySQL 8
CentOS8 + Anaconda 4.9.2 + jupyterhub environment construction procedure
[Java & SpringBoot] Environment Construction for Mac
Troublesome Rails environment construction flow [Windows 10]
[Environment construction] Uninstall rails from local
[Rails] AWS EC2 instance environment construction
Java runtime environment construction method (Tomcat @ Linux)
SQL statement learning ~ Environment construction ~ Docker + MySQL
CentOS8 + Anaconda + Django development environment construction procedure
GPU environment construction with Docker [October 2020 version]
[Processing x Java] Construction of development environment
Rails environment construction with Docker (personal apocalypse)
Spring Boot environment construction memo on mac
Laravel development environment construction with Docker (Mac)
Sapper × Go (echo) × Docker development environment construction
Universal Robotics UR Caps development environment construction
Java development environment construction memo on Mac
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Rails API server environment construction using docker-compose
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Play Framework 2.6 (Java) environment construction in Eclipse
Redmine (Scrum, Agile plug-in) environment construction memorandum