CircleCI

Prithvi A Parit
5 min readJan 28, 2022

--

CircleCI is the continuous integration & delivery platform that helps the development teams to release code rapidly and automate the build, test, and deploy. CircleCI can be configured to run very complex pipelines efficiently with caching, docker layer caching, resource classes and many more.

What is continuous integration?

Continuous integration is a practice that encourages developers to integrate their code into a main branch of a shared repository early and often. Instead of building out features in isolation and integrating them at the end of a development cycle, code is integrated with the shared repository by each developer multiple times throughout the day.

Salient features of CircleCI

  • Serves around 30000 clients and is capable of running a million tasks per day.
  • Offers performance-based scaling options.
  • Incorporates SSH into the build and test runs to debug.
  • Enables setting up of parallel builds for faster execution of the process.
    Runs every task as a new container which prevents stale build data causing issues.
  • Announces the end of task execution via Email Notification.
  • Offers numerous orbs (plugins) that help in connecting the existing tools setup.

Pipelines Overview.

CircleCI pipelines are the highest-level unit of work, encompassing a project’s full .circleci/config.yml file. Pipelines include your workflows, which coordinate your jobs. They have a fixed, linear lifecycle, and are associated with a specific actor. Pipelines trigger when a change is pushed to a project that has a CircleCI configuration file included, and can also be scheduled, triggered manually through the CircleCI app, or using the API.

Using Workflows to Schedule Jobs.

  • Sequential job execution example
  • Fan-out/fan-in workflow example

Executors and Images.

CircleCI offers several execution environments. We call these executors. An executor defines the underlying technology or environment in which to run a job. Set up your jobs to run in the docker, machine, macos or windows executor and specify an image with the tools and packages you need.

Orbs

CircleCI orbs are open-source, shareable packages of parameterizable reusable configuration elements, including jobs, commands, and executors. Use orbs to reduce configuration complexity and help you integrate with your software and services stack quickly and easily across many projects.

Writing to the cache in workflows

Jobs in one workflow can share caches. This makes it possible to create race conditions in caching across different jobs in workflows.

Cache is immutable on write. Once a cache is written for a specific key like node-cache-main, it cannot be written to again. Consider a workflow of 3 jobs, where Job3 depends on Job1 and Job2: {Job1, Job2} -> Job3. They all read and write to the same cache key.

In a run of the workflow, Job3 may use the cache written by Job1 or Job2. Since caches are immutable, this would be whichever job saved its cache first. This is usually undesirable, because the results are not deterministic. Part of the result depends on chance. You could make this workflow deterministic by changing the job dependencies. For example, make Job1 and Job2 write to different caches, and Job3 loads from only one. Or ensure there can be only one ordering: Job1 -> Job2 ->Job3.

How CircleCI Works

  • VCS integration:
    CircleCI integrates with GitHub, GitHub Enterprise, and Bitbucket. Every time you commit code, CircleCI creates a pipeline.
  • Automated testing:
    CircleCI automatically runs our pipeline in a clean container or virtual machine, allowing us to test every commit.
  • Notifications:
    Your team is notified if a pipeline fails so issues can be fixed quickly. Automate notifications with our Slack integration.
  • Automated deployment:
    Passing pipelines are deployed to various environments so our product goes to market faster.

CircleCI in your workflow

A software repository on a supported version control system needs to be authorized and added as a project on circleci.com. Every code change then triggers automated tests in a clean container or virtual machine. CircleCI runs each job in a separate container or virtual machine.

CircleCI then sends an email notification of success or failure after the tests complete. CircleCI also includes integrated slack and IRC notification.

Code test coverage results are available from the details page for any project for which a reporting library is added.CircleCI may be configured to deploy code to various environments, including:

  • AWS CodeDeploy
  • AWS EC2 Container Service (ECS)
  • AWS S3, Google Kubernetes Engine (GKE)
  • Microsoft Azure
  • Heroku

Benefits of CircleCI

CircleCI can be configured to run very complex pipelines efficiently with sophisticated caching, docker layer caching, and resource classes for running on faster machines.

As a developer using CircleCI we can:

  • SSH into any job to debug our build issues.
  • Set up parallelism in your .circleci/config.yml file to run jobs faster.
  • Configure caching with two simple keys to reuse data from previous jobs in our workflow.
  • Configure self-hosted runners for unique platform support.
  • Access Arm resources for the machine executor.
  • Use orbs, reusable packages of configuration, to integrate with third parties.
  • Use pre-built Docker images in a variety of languages.
  • Use the API to retrieve information about jobs and workflows.
  • Use the CLI to access advanced tools locally.
  • Get flaky test detection with test insights.

As an operator or administrator of CircleCI installed on our own servers, CircleCI provides monitoring and insights into your builds and uses Nomad for scheduling.

Powerful Features:

  • Faster performance
  • Complete control
  • Flexible job orchestration
  • Unparalleled flexibility
  • Choose the CPU/RAM we need
  • Language-agnostic support
  • Powerful caching
  • SSH or run local builds for easy debugging
  • Unmatched security
  • Insights dashboard

--

--