DEV Community

Cover image for CI/CD: Continuous Integration & Delivery Explained

CI/CD: Continuous Integration & Delivery Explained

Marko Anastasov on October 03, 2019

CI/CD enables the best tech companies to improve their products many times per day. Here’s what you need to know to do the same. What is ...
Collapse
 
mike_hasarms profile image
Mike Healy

Could you elaborate on this point please:

...if you develop in feature branches, they should live no longer than a day. When you need more time to develop new features, use feature flags.

Should feature branches be short lived so they stay closer in sync to master?
How do feature flags let you restrict unstable work from being used?

Collapse
 
markoa profile image
Marko Anastasov

How do feature flags let you restrict unstable work from being used?

Feature flags are basically

if current_user.can_use_feature?(“new-feature”)
  render_new_feature_widget
end

So you don’t even load the related code unless the user is part of the dev team or a small group of beta testers. It can be totally unfinished, nobody will be affected. So you can work on it in small iterations and make sure each iteration is well integrated with the system as a whole. Much easier to deal with than a big-bang merge.

Collapse
 
mike_hasarms profile image
Mike Healy

Thank you, looks good

Collapse
 
markoa profile image
Marko Anastasov

Should feature branches be short lived so they stay closer in sync to master?

Exactly. The longer it lives the higher the chance they will diverge and make it harder to integrate. Not just merge code on line by line level, but make sure it doesn’t introduce unforeseen bugs at runtime (because of how some APIs or dependencies changed in the meantime).

Collapse
 
martin profile image
Martin Beentjes

Great piece, Marko! CI/CD is one of the most powerful things to work on and to get right. But to get it right is really hard.

What I also experience is the difficulty in getting the implementation of CI/CD well known within the organization. I am one of the few who do maintain our pipelines and understand how to work on it. So, writing and documenting the implementation of CI/CD is good for future employees and people who never worked on it.

I like the usage of the twenty minutes rule. It also forces you to keep changes small, and let the process of delivery be short.

Would there be a manual check in a Continuous Deployment process? We always do a last check before going to production.

Collapse
 
markoa profile image
Marko Anastasov

Thank you!

Technically if you have a manual check it’s not “Continuous Deployment” but if it goes fast it doesn’t make much of a difference in my view.

Btw, on the difficulty that you describe, is it about getting devs to collaborate on configuring the pipelines for their projects, or something else?

Collapse
 
michael profile image
Michael Lee 🍕

Great breakdown and explanation of CI/CD Marko! I enjoyed reading about how the two differ and then how the two can coexist. Thanks for sharing your knowledge on the subject.

Collapse
 
anortef profile image
Adrián Norte

If you have any sort of branching then you are not doing CI, you are doing promiscuous integration but not continuous integration.

Collapse
 
markoa profile image
Marko Anastasov

I’m aware of this ideology but I think that branching has too many practical and psychological benefits. :)

I’d be curious to hear how it works in practice with a specific project and team.

If you merge multiple times per day, it implies that average lifetime of branches is less than a day, and that’s as continuous as you can do imo.

Collapse
 
anortef profile image
Adrián Norte

Branching generates a lot of integrational and operational cost to the software development process.

In there I explained my point of view.

Collapse
 
hungluong profile image
Hung Luong

Do you mean it's better to work on master and/or a monorepo approach?

Collapse
 
anortef profile image
Adrián Norte

yes, absolutely.

Collapse
 
adamszaloczi profile image
Adam Szaloczi

Gatsby + Netlify: netlify is linked to the git commit, as soon as I commit the repo, it appears on Netlify. Trigger deploy -> job done. I like the sleek workflow like this.

Collapse
 
markoa profile image
Marko Anastasov

For that kind of a project, that’s a perfectly fine setup!

Collapse
 
adamszaloczi profile image
Adam Szaloczi

abusalem.dev - just launched a months ago