×

Search anything:

Continuous Integration in DevOps

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

Reading time: 30 minutes

Eric Ries, the Author of The Lean Start-up popularized the term continuous integration. It can be loosely defined as the process of building and integrating code as many times as possible in a given day.

This method of product building has been well received and vastly used by organizations globally.

CI2

Building software is no different from that of a factory. Continuous integration is like a software assembly line set-up in an IT factory. Let’s look at an example of a motor-bike & how it came into being to understand this better. A bike is not a single entity, it is a combination of different elements such as engine, headlight, metal, nuts and bolts that are fused together to create a single complete product as a motor-bike. It is most likely that each of these elements came from different sources. Each of these elements is fully functional components by itself, which went through its own set of processes before becoming a fully functional product. All these elements brought from different sources, manufactured under different conditions are assembled together at a factory to create what we see – a fully functional motorbike.

Likewise, in an IT factory, every complete product is an amalgamation of multiple software components that came from different sources, created by different people, from different geographies, across different time zones. This coming together of different components to create a complete software product is enabled by Continuous Integration in an IT software factory.

Martin Fowler, one of the authors of Agile manifesto, defines continuous integration as, “Continuous Integration usually refers to integrating, building, and testing code within the development environment.”

Process

ci

Look at the picture to understand how an IT/software assembly works to create software products. Continuous integration involves the following steps repeated several times over and over again.

Code->Test->Integrate->Repeat

Source Control:

Source control system maintains the history of changes made to the source code of a software. Developers first start by pulling the current version of the code from the source control repository. The development team then implements new features or fixes the bugs in the existing code or pushes the newer version of the code to the source code repository. The source code repository has the final project code at any given point in time. When another developer wants to start working and checks out their own copy of the code, the previous developer’s new changes will now be included.

Build:

The build server Takes in the source code and “builds” the code into an executable program which will then be tested and deployed. The build server regularly monitors the source control system and detects any new change made to the code by the development team. The latest copy of the code is then pulled and a new program file is built, that will have the latest changes.

During the build process, a compiler converts the human readable code written by developers to machine-readable instructions. The new file can then be sent to users or deployed to servers or otherwise executed. The product building is divided into multiple smaller phases, built and released at regular intervals.

Automated tests:

Automated tests help in testing the software to ensure that the product performs the designated tasks. Automated tests greatly reduce the time spent during manual software testing and reduces the chances of bugs being present in the released product. The code that is undergone automated testing, is sent for final integration. The following are the different types of testing:

  • Smoke testing: Special kind of initial checks done to ensure the proper functioning of basic implementations and environmental assumptions. These tests are usually done early during the testing cycle.
  • Unit testing: Unit tests are done to test the individual components of code in an isolated and highly targeted fashion. Used for maintaining internal consistency and correctness before subjecting it to a complex context.
  • Integration testing: After unit tests, integration testing is performed by grouping together components and testing them as an assembly. Integration tests are performed automatically when code is checked into the repository.
  • System testing: System tests are done once integration tests are done. System tests ensure that group of components function as a cohesive whole.
  • Acceptance testing: Acceptance tests are one of the last tests types that are performed on software prior to delivery. Acceptance testing is used to determine whether a piece of software satisfies all of the requirements from the business or user’s perspective.

Best Practices of CI

Maintain a single code repository:

  • Use version control
  • Store all things relevant to product in a single repository Automate deployment
  • Simplifying process of running the source code by automation
  • Self testing build
  • Commit code everyday
  • Fix broken builds without delay
  • Test code in a cloned environment
  • Keep latest deliverable accessible
  • Code should be available to everyone

Building software product involves a huge amount of data, files, code etc. While we are working with different teams sitting across different geographies, it gets very difficult to manage and maintain a source unless we have the right tools in place. Source code management tools are typically used to store your code and the developers use this as their reference to build from. Teams actively use what is called version-control to track and understand the different versions, changes that have been carried since day 1 of coding.

A source code management tool typically stores all things associated with the product such as database schema, files, third-party libraries, installation scripts etc.

Typically developers have what is called the main line from which different branches are born. Each branch is responsible for a set of features or a feature and different branches are built and maintained by different developers contributing to the main line.

Once we have the source code, it needs to be converted into a completed working system that can be used. This gets tricky considering the number of files, the compilation, loading schema etc. This like any other software development process can be automated.

Having automated environments for creating builds is the best practice that Development teams should follow.

Benefits of Continuous Integration

  • The primary benefit of continuous integration is the pace. Bugs, errors are identified early on and fixed immediately
  • Time to code review is reduced to a great extent.
  • Support for parallel builds, builds and tests can be carried out over multiple machines.
  • Developers integrate code and identify issues within the next couple of hours
  • Reduction in the number of errors or bugs
  • Code is tested on a regular basis, that reduces the overall number of errors or bugs in the product.
  • With automated testing, code is tested in the same way for every change and every change is tested before deployed to production.
  • Latest version of code is available always.

The main advantage of CI is the rapidity with which code is built and tested. The feedback loop is almost immediate and this helps development teams save a lot of time and cost. Benefits of CI are listed above.

Countinous Integration Tools

  • Jenkins
    Jenkins is an open source platform for countinuous integration.This tools used in Testing and reported changes. This tool help Developer to solve buf and detect problem through automated testing. Jenkins can be effectively set up and designed with the assistance of its web interface. It's can without much of a stretch circulate work over a few machines.

  • Gitlab CI
    GitLab CI is a piece of GitLab. It is a web application with an API that stores its state in a database. It oversees extends and gives an agreeable UI, other than offering the benefit of the considerable number of highlights of GitLab.

  • Semaphore
    Semaphore is a continuous integration device that permits to test and send your code at the push of a catch. It bolsters numerous dialects, systems and can be coordinated with Github. It can likewise perform programmed testing and deployment

Top 10 MNC using Continuous Integration Tools

Today, all popular software and open source projects like TensorFlow use CI. Some of the companies using Continuous Integration are:

  1. Amazon
  2. Netflix
  3. Target
  4. Walmart
  5. Nordstrom
  6. Facebook
  7. Etsy
  8. Adobe
  9. Sony Pictures Entertainment
  10. Fidelity Worldwide Investment

With this, you have the complete idea of Continuous Integration (CI) in DevOps.

Continuous Integration in DevOps
Share this