Left Arrow News

Making Game Devs Sane Again with CI/CD

6 Apr 2023

Written by: Mina Pêcheux

 

The world of game development is a tough one. Working late nights to release on time, crunching to ship critical bug fixes afterward, and dealing with the resulting burnout are the usual suspects in a game dev’s career. It doesn’t matter if it’s indie development or a studio working on AAA titles — the flow is usually the same.

However, some solutions and best practices have been invented to help developers overcome these challenges. You’ve surely heard about Agile and DevOps, but more often than not, these terms are used only by management and sound like buzzwords. They aren’t perceived as something that’s there to help simplify a game dev’s life.

However, if implemented correctly, these can indeed be helpful for developers — not to squeeze the most out of them but rather to help them avoid unnecessary work. Agile ensures precious sprints aren’t wasted developing something that won’t be used, while DevOps helps reduce the number of manual tasks and distractions so that developers can focus on more meaningful work.

For example, DevOps relies heavily on automation. Instead of manually testing every single thing, you can automate a huge part of the tests. This allows you to run them more frequently, spot errors earlier, and keep QA in the loop. Why build your game manually when you can automate the building process and outsource it to a remote computer so that you don’t need to wait while it builds? Why bother with manual publishing to App Store, Google Play, Steam, or any other store when you can automate that as well and instead focus on development?

There are tools that allow you to automate all of the above. They are omnipresent when it comes to web services development, but some are more specific to game development. However, in game dev, they are far from being widely used. These tools are called CI/CD (continuous integration and continuous delivery) and are a pillar of DevOps. And we’re going to talk about them here.

In this article, we will examine how to use CI/CD to improve the pipeline for testing, building, and deploying a Unity game. We’ll discuss the following topics:

 

How CI/CD can Benefit a Game Dev Team

By having scripts that take care of tasks such as testing, building, and deploying, you ensure that they are run frequently, consistently, and on all the targeted platforms. No more “last day production build gone wrong”: Thanks to the automation, you get regular feedback, up-to-date QA, and therefore better-informed iterative development.

It can also help improve cross-team collaboration and eliminate some bottlenecks. Because you get constant rebuilds of the latest version of the game, all team members, from the concept artists to the beta testers, know where they stand and what they need to focus on. When combined with some standardized asset nomenclature in the pipeline, automation can also proceed to direct validations that allow you to avoid the usual back-and-forth movement of assets from one department to another and further smoothen the creation flow.

CI/CD is also about delivering updates in small batches, which is an efficient technique for avoiding long reviews and reducing the number of unfinished projects: Each task is better scoped and can thus be tackled entirely before moving on to the next one. Since those updates are labeled with version numbers, you also have an easy-to-browse history of your features and bug fixes to quickly narrow down any bug to a particular part of the development.

And, of course, automation is a great stepping stone for scaling up the team. Since you remove manual steps, you’re not subjected to the “more tasks require more manpower” rule anymore! Having a sound CI/CD system in place ensures that your newest team members won’t have to spend time moving files around or clicking on the build button for each platform. Instead, they can focus on more interesting tasks, like actual game design and development.

The Challenges of CI/CD

This might all sound too good to be true. Indeed, there may be a few drawbacks to this approach.

While CI/CD is almost omnipresent in the world of app and web development, this is far from the case in the world of game dev. But this difference in culture is obviously not the only reason game makers don’t usually use automation. Putting this kind of pipeline in place can be hard, especially when another workflow already exists. Whereas brand-new teams can go straight for a version-controlled codebase and clean asset naming, teams with a legacy system can’t just switch to this new state of mind instantly. Successful CI/CD depends on, among other things, how proficient the team is at reviewing the delivered chunks, analyzing incidents, and adapting for upcoming builds.

Setting up a CI/CD pipeline for a project or company requires certain resources like servers to run the tests and build scripts on. If you intend to make games for multiple platforms, you’ll also have to make sure that your servers have diverse matching OSes, especially if you’re building for Mac or iOS.

Additionally, even though automation lightens developers’ load once in place, it does take a lot of time to initially set up and then maintain. It also requires your team to have the skills to properly design and implement the CI/CD pipeline.

Another complex aspect of CI/CD is actually designing it: To fully automate a workflow and eliminate the manual communication of intermediary artifacts inside it, you need a solid understanding of it, the actors it implies, and all the interfaces between the different departments. This demands a bird’s-eye view of the entire process and knowledge of all the potential hiccups along the line.

The good news, however, is that this all-encompassing CI/CD system can be a future milestone, and just starting small could still benefit your team in several ways. You can start automating your pipeline bit by bit to slowly remove burdens without changing everything at once.

And there’s even better news. Unity actually has some automation tools readily available for us! So let’s have a look at those CI/CD helpers, along with their advantages and shortcomings.

 

Unity’s Automation Tools… and their Limitations

Using Unity via the CLI

One of Unity’s lesser-known but great features is that, parallel to its “normal” execution in a GUI editor window, it can also be [run via the command line](https://docs.unity3d.com/Manual/CommandLineArguments.html). This is essential to automating our Unity builds and deployments since the tasks we usually perform manually we now need to perform with scripts.

In fact, these CLI tools are very much focused on this final packaging and sharing phase. Although you can technically run any script you want in the command line by calling up a precise function in a project file, the most commonly used commands are for building the project for various platforms.

By passing in some simple command-line arguments, you can spin up a Unity executable to build your project for a given OS using a basic C# script. The drawback is that the machine you use your CI/CD on has to have Unity installed, usually a version that matches your project’s.

Still, this means that you can, for example, easily write up a CI configuration on your favorite Git provider to auto-build the project.

However, there are two major issues with this technique: one, it requires you to know a bit about DevOps and be familiar with these CLI options; two, you’ll run into the problem of Unity licenses.

Unity licenses: The thorn in DevOps’ side

As we’ve seen up until now, the whole point of automating the pipeline is to eliminate intermediary steps that consist of simple tasks like clicking on a button or submitting some form. In that regard, the most annoying step for making a Unity CI/CD is probably handling licenses.

Basically, Unity Editor requires a registered license to build a game through the command line. This means that, at one point, you need to sign in with a Unity ID email and password (if you’re on a Pro or a Plus account) or provide a license file (if you’re using a Free account). Moreover, the license has two key restrictions that further complicate the automation:

  • You can only use a license on a maximum of two machines
  • When activated, a license can only run one Unity instance at once

So, if you want to use online CI services like GitHub Actions or Gitlab CI, which randomly assign you a build machine for each build, you’ll need to activate and deactivate the license every time. This also means that you can’t run parallel builds or use features like autoscale, and as your team grows, it may become more and more difficult to organize the CI.

To sidestep this license management issue, there is another Unity tool you can take a look at: Unity Build Server.

Unity Build Server

Since 2020, Unity has offered an interesting automation tool: the Unity Build Server. In a nutshell, the idea here is to keep the builds on-premises (i.e., on your machines) but use floating licenses provided by the online Unity Build Server so as to not be faced with the limited seats issue. These licenses are also cheaper than their Pro and Plus counterparts. Thus, they can be a great way to automate your CI.

However, despite these nice features, the Unity Build Server tool also comes with some disadvantages:

  • You need a dedicated local server to take care of your builds: The tool runs on both Linux and Windows, but it needs a consistent hostname, MAC address, and number of CPUs to function. The server is mainly intended for private networks, but you can always expose it with SSH tunnels.
  • The Unity Build Server only works for Unity 2019.4.3 LTS and later, and it is a CLI-only tool. (It isn’t available in the GUI editor.)
  • You have to have a Unity Pro or Enterprise license plan.

Because you host the server yourself on-premises, you still have full control with no limits in terms of project size whatsoever, and you can build for any platform.

The price of the service depends on how many floating licenses you purchase: One new Unity Pro Build Server license costs $600 per license, and a bundle of five new Unity Enterprise Build Server licenses costs $400 per license.

The Unity Build Server is, therefore, a valuable automation solution for any game dev team, even a small one, although it asks for some preparation and customization. If you’d prefer an even more out-of-the-box tool, you can also consider the Unity Cloud Build tool.

Unity Cloud Build

Following the growing trend of cloud-based DevOps, Unity now offers an online tool called Unity Cloud Build that allows us to easily run Unity builds on remote machines that are hosted and managed by Unity itself.

Cloud Build’s pricing is based on build minutes. The advantage is that by outsourcing the CI, you ensure your on-premises resources are free to tackle more interesting phases of the game creation and your IT team doesn’t have to waste hours setting up licenses and maintaining servers.

On the other hand, because Unity provides you with the machines, you naturally have some limitations in terms of available storage and computing power. (Currently, a repo cannot exceed 40 GB, and you cannot have more than eight concurrent builds.)

More importantly, at the time of writing this article, the available build target platforms are limited to Linux, Windows, and iOS.

So, while Unity Cloud Build is a beginner-friendly solution that can help you quickly set up CI/CD for your team, it does trade ease of use for a slight lack of features. In addition to the previous points, it’s also worth noting that:

  • You can’t automate distribution to the popular stores like Google Play, the App Store, Steam, itch.io, etc. In other words, the Unity Cloud Build tool focuses on the CI part to make it easier for you to get your multiplatform downloads, but it doesn’t handle the whole chain up to the delivery.
  • The builds are fairly slow, and you don’t have much control over the build environment. You can’t provide your own VM base images, and you don’t have many options to specialize or speed up the build machine, which can sometimes lack necessary features such as the latest Xcode versions.
  • Debugging the inevitable issues can be tricky because you don’t have direct access to the build machine and VM instances. This means that the only possible channel for debugging is the forums for support, which don’t often offer the most immediate response.
  • Unity Cloud Build is all visual and doesn’t involve any coding, which can be good for initial setup and overall ease of use but becomes a drawback when trying to scale your development, for example, by creating a pipeline for another game.

So, all in all, you can use these various Unity automation tools as a starting point, but they can quickly become limiting if you plan on developing a full-fledged CI/CD for your Unity projects.

There are also other alternatives that have not been built by Unity itself but can still be used (and some even specifically tailored) as a CI/CD platform for Unity developers.

 

What a Good CI/CD Platform Should Provide

To sum up, our quick overview of these various automation solutions shows us that a good CI/CD platform for Unity should provide us with the following:

  • A wide variety of OSes to handle builds for all possible platforms
  • An easy-to-configure but well-featured toolbox so that, after getting an initial grasp on the tool, we aren’t limited by the technology in our endeavors
  • A complete set of solutions to automate both the CI and CD stages

Various companies try to fill this gap. Among them is a particularly interesting online tool called Codemagic.

 

Discovering Codemagic

To put it simply, Codemagic allows you to quickly set up CI/CD by simply connecting your Git repositories and completing a few configuration steps. It also offers access to various build machines with diverse hardware and OSes: With Codemagic, you can easily build your game for Mac, iOS, Windows, Android, etc. The service also scales well in terms of price and makes it simple to publish your project to Steam, the App Store, or Google Play. Additionally, it has certain versions of Unity preinstalled and the option to quickly install others.

If you’re just starting to take an interest in the field of DevOps, you can benefit from the free 500 minutes per month to automate the release of your Unity project to an indie platform like itch.io. If you’re part of a larger company, you can take advantage of Codemagic’s fast build machines, use your own custom base images, or even set up dedicated machines to fully control your build environment.

If at any point you want to examine what happened during the build, your dashboard will directly prompt you with the credentials to SSH into the build machine and take a peek. Moreover, Codemagic has extensive documentation and a quick support team to help you with your automation issues.

Codemagic may not be ideally suited for AAA projects, as it takes time to get all the dozens or hundreds of gigabytes of data from the remote repo to the platform, but it’s a good fit for smaller projects. So if you’re looking for a powerful but accessible CI/CD solution for your next Unity project, Codemagic is a great choice.

 

Conclusion

With the ever-growing size of game projects and teams, learning to improve your pipeline’s efficiency has become critical to keeping the adventure sane and robust. Rather than crunching until the last minute and doing just one production-ready build after months of development, we should embrace the DevOps mentality and tools and start to incorporate them into the game dev community.

Although implementing a full CI/CD workflow for Unity projects comes with many challenges, more and more people are looking for solutions. So whether you’d prefer to stick with Unity’s official tools or go into the wild and discover solutions like Codemagic, you now have plenty of tools for automating your pipeline.

Hopefully, you now also have a better grasp of what CI/CD is and why it could be a great addition to today’s game development systems.

Utah Game Developers Choice Awards 2024 Results

50+ Utah game developers and enthusiasts filled the hall...

Utah - Salt Lake City

8 Dec 2024
Chapter Elections

It’s time for our yearly chapter board member elections....

North Carolina - Triangle

3 Dec 2024
Salón del Ocio y la Fantasía (SOFA 2024)

Ven a corferias y visitanos en el pabellón 18....

Colombia

10 Oct 2024