Automating your dev-to-tester workflow

Let’s see how we can use automation tools to share our builds to QAs and stakeholders!

This article was originally published on Codemagic’s blog.

When you start to work on larger projects, and probably in a larger team, you’ll soon discover that – in addition to creating assets, developing features or fixing bugs – you also need all your releases to actually work! This means that you’ll need somebody to test your builds on a regular basis.

This type of role in a team is often called “QA”, which stands for “Quality Assurance”. The testers are tasked with trying out the new releases and asserting that a series of tests check out (it’s a bit like unit testing, except those people can evaluate more complex situations). Of course, your stakeholders might also want to have a look at your app’s evolutions regularly to give feedback.

Ok, the app needs to be delivered to both the QA team and the stakeholders on a regular basis. Doing that manually (sending every build along with release notes to some channel in Slack or something like that) is an option – but not the most convenient one, as you need to remember to do that and dedicate your time to this task. And of course, it breaks the flow.

So, how can we create some robust and easy-to-use automated pipelines to send our app’s builds to all those people? We can use a CI/CD platform such as Codemagic for that.

In this article, we are going to:

  • Quickly introduce our sample Unity project, and set up a simple build workflow on Codemagic
  • Discover how we can share our build artifacts (and optionally release notes) thanks to Codemagic’s built-in “build dashboards” feature
  • Go one step further and learn how to automatically publish the releases on a dedicated Discord channel using a Codemagic CI/CD pipeline!

Note: if you’re already familiar with how to configure a Unity project and the associated Codemagic app for Windows build, feel free to skip to the second section.

Preparing our Unity project and Codemagic app

For this tutorial, I’m going to be working with a very basic Unity app: it’s a simple screen with a “Click me!” button to change the background colour, and a “Quit” button to exit the application. You can find the full sample projet on Gitlab over here 🚀

Overall, the setup step is the same as what I’ve discussed in previous Codemagic tutorials – except that, this time, I’m going to be building on a Windows Codemagic machine. Windows is still, to this today, the most common OS for games and gamers, and we are a bit lacking in Codemagic workflow examples with Unity Windows projects, so I’d wager it is a win-win 🙂

Anyway – in the Build Settings, I’ll select the “Windows” export:

And I’ll add a Windows-dedicated build script to my project (in an Assets/Editor/Build.cs script):

Now, all that’s left to do is add my codemagic.yaml config file to trigger the right workflow. As shown in one of the Codemagic’s sample projects, we should activate the Unity license and build the project at the same time, and then compress the result as a .zip archive:

Then, I’ll go to Codemagic, create a new Unity app and link it to my GitLab repository. Of course, since we’ll want to authenticate to the Unity ID database to build, we’ll need the same Unity-related environment variables as usual: the UNITY_SERIAL, the UNITY_USERNAME and the UNITY_PASSWORD; let’s go ahead and add them in the “Environment variables” tab of the app:

All that workflow is explained in Codemagic docs, and so far we’re only following them.

At that point, we’ve setup a basic Codemagic workflow to build our Unity project on a Windows instance – if you run a first build, you’ll see that we get a release.zip artifact that contains our Windows application:

That’s great, but there we hit the problem we’ve discussed earlier: actually accessing this artifact to try out the new version of our app requires you to go to Codemagic, navigate to the builds list and find the right one…

… which is clearly not ideal for our QA team!

So now that we’ve implemented our base workflow, let’s see how we can share our artifacts more easily with our kind testers 🙂

Sharing some builds with Codemagic dashboards!

If you’re in a Codemagic team, then one interesting tool at your disposal are the builds dashboards. They allow you to share public links to easily pass on your build artifacts and release notes, if any, to whoever you want.

Dashboards are made exactly for that purpose – they are a quick way to distribute an updated version of your apps to your QAs, or your stakeholders.

To enable build dashboards in your team, go to your Codemagic team’s settings, and open the “Build dashboards” section. Here, you’ll see an “Enable” button that you can click:

As soon as you’ve turned the feature on, you’ll get a new link in the same location to create your first build dashboard:

Once you click on it, you’ll be redirected to a list of your builds with two important buttons in the top-right corner: a “Filters” button to choose which builds to show in the dashboard, and a “Share dashboard” button to get its public link.

The filters make it easy to cherry-pick just the build(s) you want to share; for example, to only list the ones that succeeded for my “Codemagic Dev Tester Collab” app, I can change some of the defaults like this:

Once you’ve properly set up your dashboard, click on the “Share dashboard” button to open a small popup with the public link:

Now, you can just copy the link and share it with whomever you want to take a look at these builds’s results!

Codemagic’s Discord integration

Using Codemagic build dashboard is cool because it gives you a quick overview of a selected list of builds – and they are a good way to share workflow artifacts to a selected few.

But it still requires the users to leave whatever they were using and go visit the dashboard. What if you could have the builds come to you, instead of going to them? That’s also possible: Codemagic offers integrations with email and also messengers, such as Slack or Discord.

In this article, we’ll be looking at getting build notifications in Discord (we’ve already discussed Slack in another one). Nowadays, Discord is one of the most-used discussion app for all that’s game-related (be it actually playing, or developing games and communities around them). It’s usually the go-to for open-source and/or community-based game projects – and it often also contains some info about the code source in the private channels of the creators, like the last commits, or the current branches.

Codemagic offers an easy-to-setup Discord integration to directly send the result of our workflow (with info and artifacts) to a Discord channel whenever our pipeline completes!

The idea is to create a webhook in Discord on a specific channel and then post data to it in the Publishing step of our Codemagic workflow – let’s see how to do that in detail 🙂

Setting up the Discord channel

I’m going to assume that you don’t yet have any Discord server or channel to receive the Codemagic notifications; so, first, in your Discord, you’ll need to create a new server:

In the server creation popup, you can just leave the defaults on the various screens. You basically just need to pick a specific name for your server at the end (this could be the name of your game, or your engine, or your project for example):

Then, in this server, create a new channel dedicated to your build notifications:

Make sure that it’s a “Text” channel, and pick a clear name:

Once it’s created, click the settings icon to edit it:

Navigate to the “Integrations” section and click the “Create Webhook” button:

Finally, give your webhook a name (this will be the name of the bot that “posts” notifications on the channel), and click the button at the bottom to copy the webhook URL:

We’re now ready on the Discord side – time to go back to our Codemagic app and set it up properly to interact with our new webhook!

Configuring our Codemagic app for Discord integration

First of all, let’s go back to our environment variables and add a new one called DISCORD_WEBHOOK_URL with the URL we just copied from Discord – we’ll put it in a new “discord” env var group (distinct from the “unity” group we had before):

Then, we’ll simply update our codemagic.yaml config file to use the current workflow data to post a new message on our Discord channel.

Since we’re building on a Windows machine, we’re going to use the Microsoft Powershell terminal language to parse, re-format and push the data to the webhook URL (if you’re not too familiar with that language, take a look at this really nice tutorial on how to use a Discord webhook with Powershell):

And now, if you re-run the workflow, you’ll get a new Discord notification at the end – and the message in the channel will contain all the info about the build, including commit message and a direct link to the artifacts. All that’s needed to easily transfer this data to your testers or stakeholders 😉

Actually, you can set up different workflows in Codemagic which would be triggered by different events, and add different integrations to them. For example, every time you build after merging something to a dev branch, you can use Codemagic to automate sending the message to a Discord channel with your testers. And on builds triggered by merging something to the production branch, the release notes and the artifacts can be sent to a Slack channel where you have your investors or other stakeholders. It’s pretty flexible, and it’s up to you how to set it up.

Conclusion

Today, we saw how we can tune Codemagic workflows to share our builds and make dev-to-tester collaboration seamless. We learned about the Codemagic’s build dashboards, and also about Discord integration – you now have several tricks up your sleeve to send your build’s artifacts to your QA team or your stakeholders! If you need any help reproducing this tutorial, you can always find help on Codemagic Slack.

I hope you enjoyed this tutorial — and of course, don’t hesitate to share your ideas for other Codemagic/DevOps topics you’d like me to make tutorials on! You can find me on Medium, or on Twitter.

You can find the sample project for this tutorial along with the codemagic.yaml file on Gitlab over here 🚀

Leave a Reply

Your email address will not be published.