DEV Community

Cover image for What is CI (Continuous Integration)? A Guide with Interactive Tool
CiCube for CICube

Posted on • Originally published at cicube.io

What is CI (Continuous Integration)? A Guide with Interactive Tool


cicube.io

Introduction

What is CI?

Continuous Integration is a software engineering practice wherein developers integrate their code changes frequently, probably into one main repository. Due to this fact, the source code has passed automated building and tests, which will, in effect, catch the bugs rather sooner than later, avoid merge conflicts, and thereby assure the quality of software by means of automated verification.

Being a DevOps for more than a decade, I've watched numerous teams wrestle with the integration of code. Let me give an analogy: building a house. Each one is supposed to take care of a different part: a kitchen, a bathroom, or maybe the living room. Now imagine they all complete their work but then try to put it all together, and nothing fits! The pipes of the kitchen block the door to the bathroom, the living room is tiny, and the electric wiring is all wrong.

I've seen just this very situation happen in software development when Continuous Integration is not implemented. Being a DevOps engineer myself, I have been in a position to introduce CI into many teams and have observed how it revolutionized their productivity. Let me try explaining what CI is in simple terms; let me use some real examples that I have faced in my line of work.

Steps we'll cover:

Monitoring GitHub Actions Workflows

CICube is a GitHub Actions monitoring tool that provides you with detailed insights into your workflows to further optimize your CI/CD pipeline. With CICube, you will be able to track your workflow runs, understand where the bottlenecks are, and tease out the best from your build times. Go to cicube.io now and create a free account to better optimize your GitHub Actions workflows!
CICube GitHub Actions Workflow Duration Monitoring

The Problem CI Solves

Let me illustrate a real-life scenario I faced once with the team before we went ahead implementing CI:

🧩 Without CI: The Chaos I've Witnessed

  1. Monday: A developer adds a login button
  2. Tuesday: Another developer in turn alters how users' names are displayed
  3. Wednesday: Schema updated by DB team
  4. Thursday: I can still remember the panic in their eyes when they tried to put their work together.
    • Login button breaks with the new display changes
    • The information cannot be stored properly in the database.
    • Nobody knows which change has caused the problems.
    • I watch the team spend days fixing these issues.

🌟 With CI: The Solution I Implemented

Here is how I transformed their workflow:

  1. Monday Morning:

    • Developer Creates a button for login
    • My CI pipeline tells me whether this works with everything else.
    • Immediate feedback within the team
  2. Afternoon Monday:

    • Another developer updates how names are displayed
    • CI verifies it works with the login button
    • Any problems are identified and fixed immediately
  3. Tuesday Morning:

    • Updating the schema by the database team
    • CI checks that it works with both previous changes
    • Everything keeps on working together!

How CI Works: A Simple Example

Imagine you're writing a message in a group chat. Before sending, you:

  1. Spell check
  2. Check it makes sense
  3. Ensure you send it to the right group.

CI does the same for code:

name: Simple CI Check

on: [push]  # Whenever someone saves their work

jobs:
  check-code:
    runs-on: ubuntu-latest
    steps:
      - name: Get the code
        uses: actions/checkout@v3
      - name: Check spelling, as spell-check does
        run: npm run lint
      - name: Ensure that it works (like preview)
        run: npm test
      - name: Try to build it (like send the message)
        run: npm run build
Enter fullscreen mode Exit fullscreen mode

Common Problems CI Helps Solve

  1. "It Works on My Computer!"

    Without CI: "It works fine for me, I don't know why it's broken for you!"

    With CI: That means, because it is CI testing in a clean environment, it will therefore work if it works there for everyone.

  2. Finding Problems Late

    Without CI: We learn about problems on Friday when everything is due.

    With CI: Find and fix little problems all week

  3. Not Knowing What Broke

    Without CI: "Something's broken, but we don't know what changed!"

    With CI: Knowing exactly which change caused it straight away

How to Choose the Right CI Tool?

Popular CI Tools Compared

When starting with CI, one of the first decisions you'll need to make is which CI tool to use. Let me break down the most popular options in simple terms:

CI Tool Best For Hosting Free Tier Setup Difficulty Key Feature
GitHub Actions GitHub projects Cloud 2000 mins/month Easy Direct GitHub integration
Jenkins Custom workflows Self-hosted Unlimited Complex Highly customizable
GitLab CI GitLab projects Both 400 mins/month Medium Built into GitLab
CircleCI Quick setup Cloud 6000 mins/month Easy Fast performance
Travis CI Open source Cloud OSS only Easy Simple configuration
Azure Pipelines Microsoft ecosystem Cloud 1800 mins/month Medium .NET integration

How to Know If CI is Working Well

Think of CI as an eager assistant, which should:

  1. Be Quick: Like a spell-checker, it should give fast feedback
  2. Be Reliable: Like a calculator, it should give consistent results
  3. Be Clear: Like a traffic light - it should be easy to understand
  4. Be Helpful: It should act like a GPS telling you how to fix problems.

Getting Started with CI

If you are new to CI, here is how you get started.

  1. Start Small

    • Begin with the basic checks such as spelling/grammar checks for code
    • Add basic tests
    • Keep it simple!
  2. Add Gradually

    • Learning to cook, start off with simple recipes
    • Add more ingredient tests as you become comfortable
    • Learn from mistakes and improve
  3. Use the Right Tools

    • GitHub Actions - what we used in the examples
    • Other popular tools include: Jenkins or GitLab
    • Select the best fit for your team

Common Questions

Q: Must I be a guru at programming to use CI?

A: No! If you can use spell-check or follow a recipe, you can understand and use CI.

Q: How often should CI run?

A: Ideally every time someone saves their work - like spell-check checking as you type.

Q: What if a Problem is found by CI?

A: Like when spell-check has underlined a word for you: you fix it before moving on.

Q: Is CI expensive to set up?

A: Most of these tools, like GitHub Actions, are free for basic use. The time you save is worth it.

Monitoring Your CI Pipelines

No matter which CI tool you decide to use, there's a need for monitoring their performance. That's where tools like CICube come in:

  • Tracking build times across various tools
  • Monitor success rates
  • Compare performance
  • Gain insights for optimization

Top comments (0)