Development nowadays has become a bit more complicated than it used to be. On the other hand, the importance of having a website has grown too. It can be the most important part of our business.
What is this CI/CD?
First – let’s start with some theory.
CI stands for Continuous Integration, which means that we should test every change in our code. Thanks to this we are able to find bugs early on and fix them.
CD has two meanings. It’s either Continuous Development, which means we are preparing our application to be deployed all the time, but it’s released when a person responsible for this makes the call.
Or it means Continuous Deployment, which means that every time we merge our code into our main branch the application gets deployed.
So, overall it just means that we should run the tests every time we commit some changes and run the build&deploy process as a part of our pipeline.
What can happen if we won’t use CI/CD?
There is one perfect gif for this:
This chaos is quite easy to achieve. If we won’t have a test suite, every new feature will bring lots of chances that something in our code will break. This means that we won’t be able to push changes with confidence.
As result, quite quickly we’ll realize that, and either we’ll start adding some tests (which is great, because it means we learned from our mistakes) or we’ll start finding excuses not to write those tests (which means we didn’t learn anything).
Does using CI/CD fix the problem?
In short – yes, it does.
There is a reason, that all the big WordPress agencies use it. If you’ll read or listen to WebDevStudios, HumanMade, Alley, 10up, or Upstatement, you’ll see that all of them are using some form of CI/CD. They may use different applications (Buddy, GitHub Actions, BitBucket Pipelines) or different tools for testing (PHPUnit, Pest, Codeception, etc), but in general, they are testing their code all the time.
Why? There are many reasons. Let’s concentrate on those most important.
Time and money
Every time you’ll ship a bug, you have to fix it. Which means you’ll have to spend some extra time. So instead of working on a new feature or project (and earning money), you are wasting your time fixing code. At some point, this can become a very big problem for your company, because your assumptions about the project’s length will be false.
Having a solid test suite will save you time and money in the long run, even if writing tests will take a few extra hours.
Kind of obvious, but good companies ship code that works. If you are constantly fixing things (especially those that could be avoided), you aren’t doing a good job.
There are many tests that are necessary, but boring to check manually. If you are manually checking out things that code sniffers, linters, or static analysis tools can do, you are doing the most boring part of code review. You should focus on the algorithm, instead of checking if the code has tabs or spaces.
Without CI/CD there is a big chance we’ll start handing away passwords to our servers. Why? Because developers have to push code in some way. It’s also easy to lose track of who has which accesses.
Storing everything in a CI/CD solves this problem – because the moment we’ll cut the developer from it, we’ll automatically cut him from any access.
What are the biggest problems in implementing CI/CD in your project?
There are two most popular excuses. It’s either too complicated or we don’t have time to do it.
Is it so complicated? It is, a bit – but that’s what differentiates good developers from mediocre ones. If you’ll try to implement everything at once then you’ll probably fail. I would recommend doing this step by step. If you’ll start testing your code at least partially then you are already a step closer to a full CI/CD pipeline.
I wrote about this here.
When it comes to the time aspect. Yes, adding tests does require some extra time, but it makes our work much more predictable, as you won’t be constantly fixing stuff.
Overall, both arguments are just excuses, to be a mediocre developer or manager.
Time to sum up
While the benefits of implementing CI/CD are obvious, still many developers and managers are doing everything to avoid using it. And OK, they are grownups and this is the path they took.
I just hope that you will at least try to pick a different one. The one that focuses on working smart rather than hard.