There is a wealth of information out there on how to implement continuous integration (CI) as a process. But why is CI important? We sat down with VP of Delivery at Exadel, Mikhail Andrushkevich, to understand CI in detail and delve into CI principles.
Importance of Continuous Integration
What exactly is continuous integration (CI) and why is CI important?
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, that is why continuous integration is important for the software development teams.
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 continuous integration is important from a business point of view?
As I mentioned earlier, the importance of continuous integration is high as it helps to reduce 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 CI 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 and what is the importance of continuous integration?
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. So the importance of continuous integration in software development is high, bringing sufficient value to the whole business.
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 about Exadel DevOps services and the challenges Exadel DevOps experts can help to solve.