<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tehmur Khan on Medium]]></title>
        <description><![CDATA[Stories by Tehmur Khan on Medium]]></description>
        <link>https://medium.com/@tk07?source=rss-9aeab52879df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aOJnWU8K8-1AogjrMRuInA.png</url>
            <title>Stories by Tehmur Khan on Medium</title>
            <link>https://medium.com/@tk07?source=rss-9aeab52879df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:55:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tk07/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CI/CD at SwiftKey (Part 4)]]></title>
            <link>https://medium.com/microsoft-mobile-engineering/ci-cd-at-swiftkey-part-4-bfe10d7f9f03?source=rss-9aeab52879df------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfe10d7f9f03</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[swiftkey]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Tehmur Khan]]></dc:creator>
            <pubDate>Mon, 07 Jun 2021 09:08:27 GMT</pubDate>
            <atom:updated>2021-06-15T17:21:26.055Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In our final part of this series of articles (<a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-1-30e283f6068f">Part 1</a>, <a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-2-860768a6e871">Part 2</a>, <a href="https://medium.com/microsoft-mobile-engineering/ci-cd-at-swiftkey-part-3-7e27f4ebb4e">Part 3</a>) we will cover some of the issues we faced post migration, how we went about improving our infrastructure to address stability and scalability, and share some of our learnings and plans for the future.</blockquote><h3>Infrastructure improvements</h3><p>A few months after migrating our team’s CI/CD onto Azure DevOps (ADO) we faced some recurring issues. They mostly centred around the stability and scalability of both agents and emulators.</p><h4>Agent stability</h4><p>Our initial agents were stateful which meant we would create the agent once and then reuse the agents across multiple runs and different pipelines. This allowed us to benefit from incremental code checkout times but there were downsides. One major issue we faced was that the agent’s state would build up causing out of storage build failures. While we made attempts to clean up after each job, there was always some state left behind due to the impracticality of removing all new changes (e.g. reverting package updates). After such build failures we would need to manually redeploy the agents. Another issue caused by sharing state across runs was there would be build failures caused by unexpected side effects when one job updates a package, but a future run required an older package.</p><p>To resolve these issues, we moved over to using <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops#run-once">one-shot self-hosted agents</a>. These agents are configured to gracefully terminate after the completion of a single ADO job. This effectively ensures that the workspace remains clean between builds. Something to note is Microsoft-hosted agents automatically achieve this but depending on your needs, managing your own agents could offer more flexibility as discussed earlier.</p><p>With our new one-shot agent setup when the agent completes its job, it sends a signal to the container killing it. <a href="https://www.nomadproject.io/">Nomad</a> (a workload orchestrator to deploy and manage containers) then recreates it immediately due to the count constraints defined in the agent config, adding a fresh agent into the agent pool.</p><p>Due to the ephemeral nature of these agents, a full repository checkout is performed every time a job runs on these agents. This is a trade-off we felt was worth having to achieve better stability.</p><figure><img alt="How one-shot agents are assigned to jobs. 1. ADO submits job to a free agent. 2. A free agent in the agent pool runs the job. 3. Agent terminates after finishing the job execution. 4. Nomad deploys a new agent to the agent pool." src="https://cdn-images-1.medium.com/max/1024/1*xwlPSlAGHXb1Gil0dWQIcw.gif" /><figcaption>How one-shot agents are assigned to jobs</figcaption></figure><h4>Agent scalability</h4><p>Previously, we had all Android emulator setup for each API level installed on the agents. Whilst this allowed us to avoid downloading dependencies at runtime, saving job execution time, it resulted in longer agent deployment time.</p><p>It was also not scalable as having agents with high storage space requirements meant we would have fewer agents as we needed to stay within a cost constraint. Thus, a trade-off had to be made. We decided to slim down our agent size by taking out the emulator setup and doing this at runtime. This worked well for us as it was only our Android test run for all API levels that needed multiple emulator configurations. This ran nightly so its total duration was not as important compared with other CI jobs triggered during office hours e.g. test runs on PRs.</p><h4>Emulator stability</h4><p>In certain circumstances we observed that builds were not reproducible as one build may pass but subsequent runs fail, even when no code changes had been made. After digging into this we found this was an issue with updates occurring to the emulator package when redeploying agents. As new emulator versions are released, certain parameters may be deprecated or removed, resulting in the same command behaving differently across versions. In our case the emulator failed to start up.</p><p>The update in package version was because we used the following command:</p><pre>// Installs the latest release of the emulator tool​</pre><pre>run echo y | sdkmanager emulator</pre><p>This would install the latest version of the emulator package each time we build our agent image. Our solution was to manually setup these emulator packages to pin to specific versions using the direct url.</p><pre>// Pin a specific version of the emulator tool​</pre><pre>RUN wget &quot;https://dl.google.com/android/repository/emulator-linux-<strong>${EMULATOR_VERSION}.zip</strong>&quot; -O emulator.zip &amp;&amp; unzip emulator.zip -d ${ANDROID_HOME} &amp;&amp; rm emulator.zip​</pre><h4>Emulator scalability</h4><p>When we moved to creating Android Virtual Devices (AVDs) at runtime (as opposed to bundling them in the agent image as mentioned before) we faced issues where the VM hosting the agents would crash, bringing down all agents hosted on it. This was highly problematic as it caused downtime until those agents were brought back up by our Cloud Infrastructure (CLI) team.</p><p>We needed to support creating new emulators due to our nightly tests that required emulators for multiple API versions. An interesting thing we noticed was that Microsoft-hosted agents did not have this issue. We couldn’t get to the crux of the crash we faced as we were not provided with logs when this occurred. The solution we derived was a pseudo-caching mechanism where we built each API level emulator on Microsoft-hosted agents, packaged the system images and AVD files, and then published them to <a href="https://docs.microsoft.com/en-us/azure/devops/artifacts/concepts/feeds?view=azure-devops">Azure Artifacts Feeds</a>. We were then able to download these images on demand and use them anywhere we needed an emulator. This was a more complete solution which would also provide other benefits, such as using known emulator versions.</p><h3>Learnings and next steps</h3><p>To summarise, there were a few learnings we wanted to share from our experience.</p><p>Emulator problems are a perennial issue, and we still face adb connection failures and timeouts.</p><p>We also learnt that we need to phase our CI/CD migrations and updates carefully as it can have a wider impact if there are issues. You should take your time when rolling out new CI changes, by testing it over time in a development environment or with a small use case first before proceeding. If the issues occur in the production CI, then all developers could be affected.</p><p>CI infrastructure investment should be a continuous effort. Even if things are working smoothly there will always be ways to improve and optimise. Investing more time in this space can result in big gains for the whole team.</p><p>Within the SwiftKey Android team, some areas we would like to invest in include:</p><ul><li>Sharding our tests to allow Android tests to run in parallel on multiple emulators.</li><li>Automating more pre-release checks. Some parts of our release process still rely on manual checks, such as verifying various stability data and telemetry metrics. We are in the process of automating these checks via back-end queries integrated into our release pipeline, to ensure we have the core functionality working as expected before rolling out the release further.</li><li>Improving testing between development and production CI deployment. This will give us an opportunity to test changes in development before deploying them to production, avoiding the need to roll back if there are any issues.</li></ul><p>That’s all folks…for now. We hope you enjoyed this series and would love to hear your thoughts on it and how you use CI/CD for your apps.</p><ul><li><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-1-30e283f6068f">CI/CD at SwiftKey (Part 1)</a></li><li><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-2-860768a6e871">CI / CD at SwiftKey (Part 2)</a></li><li><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-at-swiftkey-part-3-7e27f4ebb4e">CI / CD at SwiftKey (Part 3)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfe10d7f9f03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-at-swiftkey-part-4-bfe10d7f9f03">CI/CD at SwiftKey (Part 4)</a> was originally published in <a href="https://medium.com/microsoft-mobile-engineering">Microsoft Mobile Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD at SwiftKey (Part 1)]]></title>
            <link>https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-1-30e283f6068f?source=rss-9aeab52879df------2</link>
            <guid isPermaLink="false">https://medium.com/p/30e283f6068f</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[swiftkey]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Tehmur Khan]]></dc:creator>
            <pubDate>Tue, 20 Apr 2021 11:57:01 GMT</pubDate>
            <atom:updated>2021-05-14T16:25:25.957Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><em>This is a four-part series of articles by </em><a href="https://medium.com/u/9aeab52879df"><em>Tehmur Khan</em></a><em> and </em><a href="https://medium.com/u/d72b82d89292"><em>Praveen Pendyala</em></a><em> providing an overview of how the SwiftKey Android team in Microsoft use Continuous Integration and Continuous Delivery (CI/CD), particularly around how we use Azure DevOps (ADO) following our migration from Jenkins. A special mention goes to </em><a href="https://medium.com/u/2a1274eb3c64"><em>Helalur Khan</em></a><em> who was instrumental in the Cloud Infrastructure efforts during this migration project.</em></p><p>We will first provide some context of SwiftKey and our needs before giving an overview of Azure DevOps (ADO), allowing those less familiar with ADO to still understand the rest of the content. We will explain how we used ADO to set up our CI/CD and how we leveraged Azure Pipeline features. After that we will explain some of the challenges we faced and how we went about resolving them, before summarising some learnings and our future CI/CD plans.</p><p>Firstly, what exactly is CI/CD?</p><blockquote><em>Continuous Integration (CI) is the practice used by development teams to automate the merging and testing of code. Implementing CI helps to catch bugs early in the development cycle, which makes them less expensive to fix. Automated tests execute as part of the CI process to ensure quality. Artifacts are produced from CI systems and fed to release processes to drive frequent deployments…</em></blockquote><blockquote><em>Continuous Delivery (CD) is a process by which code is built, tested, and deployed to one or more test and production environments. Deploying and testing in multiple environments drives quality. CI systems produce the deployable artifacts including infrastructure and apps. Automated release processes consume these artifacts to release new versions and fixes to existing systems. Monitoring and alerting systems run continually to drive visibility into the entire CD process…</em><a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/get-started/what-is-azure-pipelines?view=azure-devops"><em>¹</em></a></blockquote><h3>SwiftKey Background</h3><p>SwiftKey is a large-scale intelligent keyboard application leveraging machine learning and Artificial Intelligence. It has over 500 million downloads, including preinstallation on many different devices. We release to market at a regular cadence of every two weeks, and deliver the same application binary to both the Google Play Store and our OEM partners.</p><p>With great scale comes great responsibility! With a wide range of features and functionality offered by our keyboard we must ensure it maintains our high quality and stability bar. With so many use cases and potential edge cases the need for automation is imperative. One critical path is Android’s Direct Boot mode feature that allows data to be protected until the device has been fully unlocked. In this use case, if we are the only keyboard on the device and the user has chosen to use a password to unlock it, there is a potential to brick the device if the keyboard crashes. Clearly, we want to ensure this never happens and so we see how important an extensive and rigorous testing infrastructure is. We thus need to make sure our CI/CD setup caters to having such testing.</p><h3>SwiftKey CI/CD Needs</h3><p>There are three main requirements we need within SwiftKey for our CI/CD.</p><ol><li><strong>The Android build environment<br></strong>This is essential to building APKs and running unit tests.</li><li><strong>Android emulators<br></strong>Android emulators are used extensively throughout our CI/CD, including for running Android nightly tests for each API level and Android tests on pull requests.</li><li><strong>Physical devices<br></strong>We utilise physical devices for various custom test suites to identify memory leaks, keyboard performance regressions, end-to-end functionality regressions and Direct Boot mode regressions.</li></ol><h3>SwiftKey’s CI/CD Evolution</h3><p>Over time our CI/CD infrastructure has evolved. We had been using Jenkins for a long time, but cracks were starting to appear. We would continuously apply plasters to mask the issues we faced. It was clear it was an ageing system and so we began a migration project onto Azure DevOps (ADO) in line with many other Microsoft apps and services. By the end of 2019 we had fully migrated onto ADO.</p><p>We previously used Jenkins with a site-to-site VPN between our own server room and Amazon Web Services (AWS). We had our Jenkins master hosted in AWS that could communicate to the local build nodes in our server room. Our Cloud Infrastructure (CLI) team would own the node setup and the Android team would handle the creation and maintenance of the job configurations.</p><figure><img alt="SwiftKey Jenkins setup" src="https://cdn-images-1.medium.com/max/720/1*UGckRZ01GQmddH2hL0f2ug.png" /><figcaption>SwiftKey Jenkins setup</figcaption></figure><p>Some advantages of our Jenkins setup included ease of integration for custom webhooks, as well as being able to run on bare metal, which offered fast execution times. However, there were major inconveniences when needing to install new packages or perform maintenance work on Jenkins as they would require Jenkins to be rebooted causing downtime for our CI/CD. Also, when there were power cuts, Jenkins would go down causing issues across many nodes and builds.</p><p>Our lack of configuration management software on Jenkins meant changes to each node, such as when we needed to upgrade the Android tools, had to be done manually. With over 10 nodes this led to configuration drift on each node.</p><p>We also did not leverage new trends such as containerisation and relied on a few Jenkins specialists which would lead to situations where we were blocked on the infrastructure being fixed.</p><h3>Azure DevOps (ADO)</h3><p>So, what does ADO bring to the table? Our main requirement was reliability and scalability, and this is exactly what ADO was designed for. More specifically we replaced our Jenkins setup with Azure Pipelines.</p><blockquote><em>Azure Pipelines…is a cloud native continuous integration pipeline, providing the management of build and release pipelines and build agent virtual machines hosted in the cloud. In addition, Azure Pipelines supports a hybrid cloud and on-premises model…</em><a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/migrate/from-jenkins?view=azure-devops"><em>²</em></a></blockquote><figure><img alt="Creating and configuring pipelines in ADO. You define a build pipeline to build and test your code, and then to publish artifacts. You also define a release pipeline to consume and deploy those artifacts to deployment targets." src="https://cdn-images-1.medium.com/max/824/1*cpEaoeqpgbaiCTRTVWASnA.png" /><figcaption>Creating and configuring pipelines in ADO. You define a <em>build pipeline</em> to build and test your code, and then to publish artifacts. You also define a <em>release pipeline</em> to consume and deploy those artifacts to deployment targets.<a href="https://docs.microsoft.com/en-gb/azure/devops/pipelines/get-started/pipelines-get-started?view=azure-devops">³</a></figcaption></figure><p>Using ADO meant we could move away from more complex SSH and firewall setups we had on Jenkins and utilise the built-in ADO security mechanisms.</p><p>ADO also provides the flexibility to have self-hosted agents for more complex needs or utilise Microsoft-hosted agents. Microsoft-hosted agents are managed entirely by Microsoft, so software updates and maintenance are taken care of. Amongst other benefits, self-hosted agents provide more flexibility in terms of utilisation time but come at a greater cost of additional complexity and management.</p><p>With the agent abstraction provided by ADO, each engineering team can own their docker agent configuration (Infrastructure as Code). Within SwiftKey this creates a clear separation of concerns between the Cloud Infrastructure (CLI) team and other engineering teams. This allows our Android team to self-serve our infrastructure and resolve issues or update packages without relying on the CLI team. The CLI team owns the base platform that offers this self-serving functionality for various engineering teams.</p><p>Migrating to ADO would naturally bring some degree of complexity for all teams, as it was a new infrastructure where up-skilling was needed to learn how it works and how to manage our own agents. We felt however this was a great opportunity to utilise a platform that is constantly evolving and has great momentum and an ever-growing community behind it.</p><h3>Next Up</h3><p>In the next article in this series, we will dive into how we utilised Azure DevOps for our CI/CD. We will cover the building blocks of Azure Pipelines and how we set up our agents within the SwiftKey Android team.</p><p><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-2-860768a6e871">CI / CD at SwiftKey (Part 2)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30e283f6068f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/microsoft-mobile-engineering/ci-cd-in-swiftkey-part-1-30e283f6068f">CI/CD at SwiftKey (Part 1)</a> was originally published in <a href="https://medium.com/microsoft-mobile-engineering">Microsoft Mobile Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>