At Instabug we build an SDK for mobile apps. Building an SDK often means that most tools created for automating tasks around development and deployment of iOS apps don't work for us, so we usually need to develop our own bespoke solutions.
To increase our productivity and keep thing moving fast, we like to automate things. One crucial component of automating many parts of our workflow is continuous integration.
This post goes through what our workflow is and how we automate it using CircleCI.
With CircleCI 2.0, we can create multiple jobs under one workflow, with the ability to define dependencies between jobs and run some of them in parallel, which is great.
Our workflow has 4 jobs:
- Running unit tests, integration tests and Danger
- Running UI tests and static analyzer
- Generating binary
- Releasing the SDK
Let's go through each one in detail.
1. Running Unit Tests, Integration Tests and Danger
After running our unit tests, we run Danger, which is a great tool to automate some of the chores around code reviews. Here's what we use it for right now:
- Enforce having a description and a link to a Jira issue for all pull requests.
- Ensure that all pull requests that add new user-facing strings add localized versions of those strings.
- Run xcov to generate a report about our tests coverage, and post it as a comment on the pull request.
- Ensure that all pull requests that modify any UI file run UI tests before merging the pull request.
Last steps of this job is to run our integration tests, which is just a test target with a similar configuration to our unit test targets.
This job runs on every pull request, so we have to make sure it contains all the essential checks/tests, and that it also runs in a reasonable time. It currently runs in around 8 minutes, with the majority of the time going to making a clean build of the SDK for running tests.
2. Running UI Tests and Static Analyzer
This job only runs on master, and fix/release branches, so we're okay with it taking a bit longer to run. It currently finishes in around 40 minutes and runs in parallel with the first job. It can also be run on demand on any pull request regardless of its branch by mentioning a simple GitHub bot we wrote that uses the CircleCI API to trigger a specific job.
3. Generating Binary
After the first two jobs have finished, we can generate a binary of the SDK from any branch. This requires the approval of a hold from the CircleCI dashboard.
This job will install our code signing identity, which we share across the team using fastlane. It then generates both static and dynamic variants of our framework. For more on building binary framework, check our previous blog post.
It then bundles up both frameworks in a zip archive and stores it in the artifacts directory to be available for download.
4. Releasing the SDK
The last job releases the SDK to the public. It runs Unleash, our homegrown CLI app for releasing the SDK.
Unleash does the following:
- Create and push a new tag to our private repository.
- Push the updated framework to https://github.com/Instabug/Instabug-iOS/ and create a GitHub release.
- Publish framework to CocoaPods.
- Update our Carthage JSON file.
- Upload the release to our own API for consumption on the Instabug dashboard and website.
We're pretty happy with the workflow we have so far. Having a reliable CI process makes us ship with confidence, and automating our release process saves a ton of time since we release once a week.
CircleCI has been a great tool to use for our continuous integration, especially with CircleCI 2.0.