The GitHub iOS team adopted Apple Silicon-powered macOS runners to reduce the time required to build and test their app using GitHub Actions. In the process, they also refactored the app to better leverage GitHub Actions parallelism.
Apple Silicon runners bring several advantages, explain GitHub engineers Stephen Glass and Eli Perkins:
Apple Silicon improves build performance, increases reliability, and lets iOS teams test natively for all Apple platforms throughout the software development lifecycle. They can avoid problems from cross-compilation or emulation and use the latest simulators on our GitHub Actions runner image.
In addition, using Apple Silicon runners helps ensure the code is compatible with the latest releases of iOS, iPadOS, watchOS, and tvOS, says GitHub.
The GitHub team took the chance of this migration to carry through a few other optimizations to their workflow.
When they started the migration to Apple Silicon runners, recount Glass and Perkins, they were using a single build-test workflow that took 38 minutes to complete on Intel-based runners.
The first step they took was splitting the test suite into separate jobs to take advantage of the fact that the app included about 60 first-party modules, most of which could be built and tested on their own. This change alone was responsible for a great improvement in PR turnaround time, say Glass and Perkins, since some modules could be built and tested in just 2-3 minutes on Apple Silicon to provide almost immediate feedback to developers.
Another noteworthy improvement was separating the build step from the testing step using xcodebuild’s build-without-testing and test-without-building, which made it possible for the team to identify unit tests that ran for a long time and further optimize them.
Overall, moving from a single workflow to a per-module build and testing workflow on Apple Silicon made it possible to reduce build times from 38 to 15 minutes.
While in beta, Apple Silicon runners have some known limitations. In particular, not every community-provided action may be compatible with the arm64 architecture. Furthermore, some advanced features like nested virtualization and Metal performance shaders (MPS) are not available due to the limitations of Apple's Virtualization Framework.
GitHub Actions may use up to 50 concurrent runners for enterprise accounts, and five for GitHub Free and Team plans. Public repos can use M1 processors, while more powerful hardware is available at a premium.