Have you ever wondered how some companies, startups, or indie developers enjoy the release of their apps on a daily basis? sometimes twice a day?
Today we are going to talk about this, because THIS, is one of the most important topics any programmer can learn, not only because it makes you more productive for your company, but because it saves you time, and time is more valuable than any salary you can gain.
This is CI/CD (read it as you hear, This is CS50)
I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.
So, let's start with the Why?
Here is a couple of cases that you will really appreciate a CI place
- Bro, I need you to review my Pull request (and you are so busy with something else)
- Have you run the tests?
- Bro there is a vulnerability here, also you should put a weak self here, and WTF is this?
And another solid example for a CD
- Hey! we have a crash on production, people are unable to make it to the checkout! (so you are racing time to push a hotfix to production asap?)
- We expect a build by end of the day (damn it, I wanted to leave early today!)
- Tester: Hey can you send me screenshots of the Home screen in Spanish and Arabic?
- Product Team: Bro, we need the app in all iPhone device sizes as well as the iPad sizes, when can we get that so we can make our mockups?
And lots of use cases that can and will save you on average 2 hrs per day
And what is a CI/CD anyways?
CI = Continuous Integration
CD = Continuous Delivery
In basic terms, this means that you are able to continuously integrate your code with the team with minimal supervision or human interaction from your part and theirs, so you can open a PR, a bot will be responsible for scanning the code, searching for any vulnerabilities or debt or code smells or basically just linting the code (it can actually edit it and commit)
It can run the tests and make sure that you only revise the code when it is passing the tests
so that's for integration, what about delivery?
If you are a backend developer, you know very well how important deployment is since sometimes human error can be catastrophic, and like any iOS developer who needs to send a build, you know very well how time-consuming this is, so why automate it?
Why don't we push a release, if we push any merge to the main (master) branch?
Why don't we, automatically revise a pull request, when a merge request is opened on the develop branch?
Why don't we, automatically send a slack message, when a release hits the app store?
All of this is possible in so many ways, and we will see that soon.
Sold? Let's dig in!
Step 1: Know your tools
There are infinite ways you can automate your workflow, literally infinite. after all at the core of any service that automates stuff, is a simple script that has been iterated on for many many times until it became Fastlane for instance
So here is a list of our available and ready for use tools:
- Your terminal
Step 2: The when and the why this tool
- Your Terminal Why? You use it everyday, so why not extend it to be deployment tool? use it to install Fastlane and enjoy many many automations you can do (including ur own creativity)
When? When you're just starting out and checking what is CI/CD
- Fastlane Why? Fastlane is, by no far, at the core of each CI/CD service that provides automations for Apple Products, so you are talking about a platform that has saved people over millions of hours around the world
When? When, basically, you have no money or time to set up a CI/CD but you have a ready for use Fastfile (which is what Fastlane uses to work)
- Bitrise Why? Bitrise as you may know has become really really popular among the mobile developers' community, the reason for that is it has a really good User Interface and makes your life a true breeze, so if you are looking for a quick way to get into CI/CD, you know where to go 😉
When? When you have no money to support it and... you hate yourself
- CircleCI Why? CircleCI is more than perfect for backend development, but if you ask me, it's not really friendly for mobile developers, the reason for that is that it's not really that different from Jenkins nor Travis, and on top of it, its really expensive, so I don't see a why here unless you want to do some research or a blog post on what to pick
When? if you are a backend developer and money with no idea where to spend on it, that would make sense, if not, (which ig is not...), then ignore it
- Travis & Jenkins Why? Both are a pain in the a$$, so you might be well rounded with Fastlane as a mobile developer, BUT, if you want to have your own server, that is within your own company under your own hosting, those are the only tools to go for as of now
When? when you are too agnostic about security
- AppCenter Why? It's quick to set up, easy to manipulate, but it is the LEAST one with customization, so basically if you are just looking to deploy stuff, this is the one to go for
When? When you are looking for something free, and quick to setup
Step 3: Play
The key to any knowledge gaining, especially hands-on one, is to get your hands dirty, so now you know some tools out there that are popular, so why not try them? most of them support open source projects (aka public repositories on any Git service provider (GitHub, GitLab, and so on)
So go there and PLAY!