Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scalable Continuous Integration for iOS

Scalable Continuous Integration for iOS

Swift Heroes 2024 talk.

https://swiftheroes.com/2024/speakers/

Alberto De Bortoli

December 03, 2024
Tweet

More Decks by Alberto De Bortoli

Other Decks in Programming

Transcript

  1. 🙋 Alberto De Bortoli 🇮🇹 Italian DNA 🇬🇧 Living in

    London 👨💻 IC at JET 9+ years 📱 iOS ♾ DevOps 🍕 JustEatTakeaway.com About me
  2. What’s this about? 🧑💻 Let’s implement a Continuous Integration infrastructure

    in-house! 🤓 using cool tech ⬆ to scale 🏎 for performance 🤩 for fun 📚 to learn
  3. Agenda 🤌 What is a Continuous Integration & Delivery system?

    🛍 Existing CI/CD solutions 😏 Focus on a setup using AWS EC2 + GitHub Actions 🤖 Implementation using DevOps tools 🤔 Final considerations
  4. CI/CD system A system that executes tasks on your code

    to allow integration and deployment of software… …continuously (if you’re lucky)
  5. CI/CD system 🚢 Continuous Delivery Deploy the software so it

    can be used (internally and/or publicly) • Build • Archive • Upload to QA/staging/ production distribution channels 🤖 Continuous Integration Make sure the changes proposed are safe to merge into the default branch • Run validations • Run tests • Generate artifacts
  6. • Ready out-of-the-box • Workers are virtualized • Can take

    time to update to new Xcode versions • Xcode Cloud special snow fl ake • Appropriate for small-mid apps CI/CD solutions Server + Workers
  7. CI/CD solutions Server only • Powerful and fl exible build

    systems • Usually require a high degree of customisation facebook/buck
  8. Workers solutions On premise 👷 • Painful • Cannot replicate

    environments • Manual software updates • Hosting • Power supply • Connectivity
  9. Workers solutions Cloud ☁ • The only cloud player offering

    bare metal Apple hardware • Offer Intel, M1, M2, M2 Pro mac minis
  10. 👍 IaC Infrastructure as Code • Predictable • Reviewable •

    Auditable • Point&Click in the UI • Error-prone • Intuitive 👎 ClickOps
  11. AMI creation in Packer AWS credential required export AWS_ACCESS_KEY_ID=“your_access_key"
 export

    AWS_SECRET_ACCESS_KEY=“your_secret_key" Or set them in ~/.aws/credentials
  12. 🔌 Connect to GitHub Actions… need a join token 🤫

    Secrets are best saved in Secrets Manager 🕵 Set up permissions to access Secrets Manager via IAM 🏁 Pass the secret ID (ARN) via user data when creating the EC2 instance 🍏 Use AWS ec2-macos-init to handle user data for startup operations
  13. Recap Dedicated host EC2 AMI (image) EC2 instance EC2 AMI

    (image) EC2 instance Dedicated host
  14. Console in GHA The operations we want to automate: 1.

    The creation of the AMI 2. The deployment and decommission of the infrastructure 3. The allocation/release of the dedicated hosts
  15. Console in GHA The operations we want to automate: 1.

    The creation of the AMI 2. The deployment and decommission of the infrastructure 3. The allocation/release of the dedicated hosts
  16. Console in GHA The operations we want to automate: 1.

    The creation of the AMI 2. The deployment and decommission of the infrastructure 3. The allocation/release of the dedicated hosts
  17. Console in GHA The operations we want to automate: 1.

    The creation of the AMI 2. The deployment and decommission of the infrastructure 3. The allocation/release of the dedicated hosts
  18. Taking it further 🤔 • Automate scaling • CloudWatch monitoring

    • IaC all the things • Optimise your pipelines 🫵
  19. Virtualization 🤹 • Leveraging the Apple Virtualization.framework • Max 2

    VMs per host • Solutions • Tart.run • Anka on AWS • Lower performance
  20. Virtualization 🤹 • Don’t be fooled by virtualization • One

    team at JET moved from VMs to bare metal cutting PR times from 34 minutes down to 9 minutes. • E.g. 1 machine, 5 devs, 10 PRs per day on average • VMs: ~3h • Bare metal: 1h 30m • The impact is real, run your numbers! • Big app? Not gonna cut it.
  21. Costs 💸 • Comparing pricing across solutions is dif fi

    cult • The more you scale the more you save • Prices vary per AWS region • Smart scaling mac2.metal
 (M1) mac2-m2.metal (M2) mac2- m2pro.metal (M2 Pro) us-east-1 (N. Virginia) $0.65 $0.878 $1.56 eu-west-1 (Ireland) $0.716
  22. Costs 💸 • Back-of-the-envelope calculations Orka on AWS Anka on

    AWS In-house infra In-house infra w/ smart scaling Mac minis on premise 5 instances per month $3,995 $3,348 $2,340 $1,632 🤯 Maintenance pain Virtually none Moderate Initial setup pain,
 joy and satisfaction thereafter High
  23. • Company size, team size, codebase size… • Pull requests

    and CD jobs per hour • Existence of a DevOps team or in-house knowledge • Any desire to skill up? • No solution fi ts all, things evolve over time. Buy vs. Build? 🛠