How We Used Gitlab Runner to Speed Up Delivery
Tech startups need to deliver and iterate on ideas quickly. Getting working code into the browsers of your customers is important and focusing on features — not infrastructure — is key to achieving that goal. That’s why when we began our software startup, we chose Gitlab as our platform for hosting code, tracking issues, creating sprints, and running our Continuous Integration and Continuous Delivery (CI/CD).
Other platforms, like Github, offer git hosting, issue tracking, and milestone management, but the integrated Gitlab Runner is what set Gitlab apart. The Gitlab Runner let us focus on writing features and leverage the CI/CD capabilities of Gitlab to deploy features quickly.
Continuous Integration
Continuous integration involves developers merging their changes back into the master branch quickly and often. We run a suite of unit and integration tests on these changes and in doing so, we create confidence in the build. Integrating as often as possible into master mitigates having long release cycles with huge change sets — which often ends in disaster as everyone scrambles to try to get their features integrated with everyone else’s.
Using a suite of tests to check the health of your system lets your developers develop new features with confidence. At Clarity Hub, we use a suite of features to confidently release new versions of our product:
- Lint tests – All code for the product is covered by lint tests. These tests are run on the CI, but are also run on each developer’s machine on git pre-commit and pre-push hooks.
- Unit tests – Code that is reused or code that is deemed very complex is unit tested with mocks if necessary. We run two types of unit tests: smoke tests and everything. Smoke unit tests are quick tests that run on mission critical code so make sure basic assumptions are kept. These run on pull requests and branches. On master, every single unit test is ran before the CD part of our pipeline is ran.
- Integration tests – These tests make sure that API calls return correct responses when a test database and test infrastructure is put in place. We run these right before deploying to the test environment.
- End to end tests — Once the new version is deployed, we use puppeteer and headless Chrome to click through mission critical sections of our application.
Continuous Delivery
Continuous delivery allows you to release new changes to your customers quickly in an automated way. Implementing an automated release process to deploy your application at anytime lets your team focus on feature writing and testing instead of deployment and release cycles.
Continuous deployment is an extension of continuous delivery: every change that passes your CI gets deployed to production. This helps accelerate the feedback loop you have with your customers and allows you to iterate on new ideas by focusing on features instead of release cycles.
At Clarity Hub, we automatically deploy to the staging environment with every pull request into master. That way we always know that staging will have the latest code. We are only one step away from Continuous Deployment, we use tags off of master to deploy to production. Anyone on the team can create a tag, and rolling production back is as simple as creating a new tag.
Using the Gitlab Runner
Gitlab gives you 2000 minutes of time to run your CI/CD pipeline a month. In most cases this is plenty of time to get your configuration set up and have your pipeline running smoothly.
However, when releasing to staging and production as much as we did, we quickly ran out of minutes and had to set up our own runner on AWS.
We used a variant of npalm/terraform-aws-gitlab-runner to get our Gitlab Runner to auto scale on AWS. It’s been working great and runs even faster than the Gitlab Digital Ocean instances that you get free minutes on.
Gitlab has been a great platform for the Clarity Hub team to use and deliver features on. I’d be interested in learning more about your experience with Gitlab and CI/CD tools. Please drop a comment below or connect with me on Twitter.
Ivan Montiel is the founder and CEO of Clarity Hub — a company that integrates with Intercom to give customer success teams real-time suggestions.