There is a wealth of information out there on how to implement continuous integration (CI) as a process. But why is it so important? We sat down with VP of Delivery at Exadel, Mikhail Andrushkevich, to understand CI in detail and delve into its benefits.
What exactly is continuous integration?
Continuous integration (CI) is a development practice that requires programmers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early. By integrating regularly, you can detect and locate errors quickly and easily. Using this approach allows software development teams to get nearly immediate feedback on changes as they implement them.
Ideally, how often should developers integrate code into a shared repository?
I think it should be done several times a day, but this also depends on the project. There could be projects where it is better to integrate code once a day. But, you wouldn’t really be getting the full advantage of CI if you were to integrate code, say, once every three days.
Why do we need to integrate code into a shared repository so often? Why can’t we do it once a week?
If we integrate the code infrequently we run the risk of conducting the merge too slowly meaning that we won’t meet our schedules. For some releases it might be okay to merge code over the course of a few hours, but for others we would be faced with conflicts within the code, which could take days to resolve. When developers merge code on a regular basis we essentially have a working build at all times. If we were to do it once a week, we wouldn’t actually have a working build at any given time.
Why is continuous integration so important from a business point of view?
As I mentioned earlier, using continuous integration reduces the risk that scheduled deliveries will not be made on time. If we don’t merge the code on a regular basis there is always a risk that we will find code compatibility problems on the release date. The merge will be slow and difficult. If merges are made regularly, we generally detect the code incompatibilities much earlier—pretty much as soon as they occur.
Another quick example: let’s imagine that a customer asked us to build a new version or some feature of their product ASAP. Applying continuous integration on their project allows us to arrange branches quickly. Then, we can program simultaneously and safely in tandem with the master code.
Does continuous integration compress the product release timeframe?
If we are talking about the frequency of releases, yes. Continuous integration allows us to make releases more often. Applying CI gives us an opportunity to receive feedback more quickly as well as detect and correct errors at the early stages of development. This generally increases the quality of the code along with the speed of production.
What is branching and why do we need it?
Branching is the practice of creating copies of programs or objects in development, to work in parallel versions. With branching, development teams retain the original code while working on or making changes to a particular branch. Each copy is considered a branch; the original program from which the branch is taken is referred to as the trunk, the baseline, the mainline, or the master.
Branching allows us to simultaneously conduct two types of development: integration and implementation of new functionality.
How can branching be misapplied?
Misunderstanding the use of branching often leads to anti-patterns. For example, sometimes more junior developers are afraid to merge code causing the negative effects of delayed integration to accumulate and compound. Problems also arise when branches do not exchange complete changes, opting instead for one gigantic union at the end.
Why do we need testing in the CI stage?
When following continuous integration principles, unit tests reduce the cost of code merges. Therefore, the cost of testing the results of these merges becomes critical. The general idea here is that finding those defects in the earlier stages is much cheaper than fixing them in the later stages. Automation is a great tool for finding these bugs earlier. This then has a positive impact on the project down the road.
What is the business value of CI?
When it comes to CI, the biggest win for businesses is a certain steady cadence for development and a degree of predictability that is much harder to get otherwise. With CI it is much more rare to miss important release deadlines because of unexpected merging problems. The other great benefit is that continuous integration practices allow stakeholders to give feedback earlier in the process. That way everyone is always on the same page.
About the Series
This is just one article in the Our DevOps Methodologies series in which we explain the DevOps approaches we use in our DevOps work. Here’s what we have published so far:
Learn more here about Exadel’s Digital Transformation practice and the challenges it can solve. Ask to speak with our experts to find out even more.