My obession with automation

Anything I can automate, I automate. I have an obsession with testing code. I love seeing all the little ticks come up, writing test after test, and seeing a million little green lines of happiness. So it makes sense to take what I’ve learned in my work, and apply it to my game dev as well. Now I haven’t quite gotten on to testing with Unity because I want to tackle the UI first, but I did want to start automating what I could. So automated builds seemed like a good place to start.

GitHub offers this wonderful thing called actions. You write a bit of code, and it triggers when you want, and does a thing. Great, let’s do it. They even give you 2000 free minutes on their runners to do the automation. Everything is coming up Milhouse. So I put an action in to build the game for Mac and Windows (my current 2 platforms) and went to work. Within 3 pull requests and code changes, they were failing. Why? Because GitHub, one of the biggest websites in the world which owned by Microsoft, one of the biggest cloud providers in the world, gives you a measly 500mb of storage. I had MP3 players 15 years ago that could store more! Memory sticks given out at conventions hold 5x that amount! Game builds are not small so that 500mb gets eaten up quicker than a pizza surrounded by starving CS grads. They do offer a great loophole though. Self hosted runners.

Now, in my mind, I had a spare Raspberry Pi and a need for a cheap machine to run infrequent tasks. Best friends, right? Good god I was so wrong. You see, a Raspberry Pi is a genius solution to a simple runner for a node app, or a .NET service, something nice and lightweight. I am not building a node app. I'm building a game in Unity, an engine that is pretty heavy just on its own. Fortunately, someone's done a lot of the hard work for me, in the form of GameCI. They produce workflows for building Unity projects in the common CI environments. Beautiful. So I put the lovely Github workflow together, ran it on Github hosted agents at first and that was all fine, so time to migrate to a self hosted runner. This is where fuckup number 1 occurs. The builder for the Unity project provided by GameCI builds and runs on a Docker image. Makes sense, there's no reason not to, and containers are a great way of guaranteeing environments. Then it happened. 9.71gb image, being pulled and built on a Pi 4 with 2gb RAM... I made a boo-boo. It was SLOW, and the temperature of the Pi was screaming as all 4 of its tiny ARM cores cried in pain. I realised that this task may have been like trying to get a slug to run a marathon, and not even providing it the running shoes it needed, but also had the thought that, once the image is pulled and built, it's cached, so this will only happen once. The image wasn't frequently updated, so no issue right? I patiently waited, and it built. Then it tried to run, and something I feared would happen, happened.

exec /bin/bash: exec format error

Motherfucker. Now I had the thought that it was because it was running on Raspbian, which is a form of Debian, so I thought "Ok, I'll throw Ubuntu Server on there, a Pi 4 can handle that". Went through installation of everything, resetting the github runner, adding it again, and waited. But there it remained. This wonderful image that GameCI's community have laboured over doesn't seem to support ARM architectures. Fuck, well there goes that idea... or does it? So there are 3 separate approaches to this problem.

  1. Write my own image that supports ARM. This seems like a really nice way to get involved with the open source, and maybe I'll consider this as a future project. With that being said, I don't have the time, knowledge, or patience for this as the moment.
  2. Find a Docker image of a github runner, and use that as the runner rather than running it directly on the Raspberry Pi. This could be good, but does run the risk of containers within containers. Nested containers seems like a nightmare waiting to happen. Putting the process in a box, then putting that box in a bigger box, then throwing it into a Raspberry Pi. What a nightmare.
  3. I already rent 2 separate Linux servers running container services for web hosting. Just use that. They aren't ARM based, so we solve the problem.

Well, option 3 is a pretty much guaranteed fix, but I don't want to chuck unneccesary load at things I use for web hosting. So let's try option 2 first. What could go wrong. Well, exactly the same thing that went wrong before. Our old friend exec format error is back again. I think this might be my cue to retire the Pi for a while, and see what other genius ideas I have for it... Homeassistant, it'll be Homeassistant.

Onto my second choice, it's time to throw a new container at my beloved Docker script. This time I'll be using (this repository here)[https://github.com/tcardonne/docker-github-runner]. Except I won't. Because once again, the same error occurred on a dedicated Linux box that's happily running a web server. What? HOW? WHY? Well, as it turns out, that image hasn't been updated in about 2 years. So after some faffing, searching, and digging, I found (this image)[https://github.com/myoung34/docker-github-actions-runner] instead that was last updated 2 weeks ago. After a bit more fiddling with environment variables, a container was finally up and running. Quick pull request to test it and boom, we have automation. So now I get this lovely pretty green tick for my personal work as well. Isn't that nice? But then I had a thought. If this image now worked on a server, would it work on the Pi? No, no it wouldn't. Put the Pi down, back away from the Pi, and let it live a nice quiet life tending to some other menial task.

But what it's really about is perpetual positive reinforcement. Unit tests, integration tests, passing builds, all of these things tell you you're doing good work. It's not based on someone's opinion, or an abitrary metric, it's 100% written in front of you. Here's what you've done. That positive feedback is important.

Screenshot%202023-01-14%20at%2016.56.12

So now we get pretty badges on my Github repo which, at some point, I intend to migrate to the site as well, and figure out creating releases, unit tests, and all the fun bits. However, this is where I discover that artifacts are uploaded to Github anyway, so the storage space limitation still applies. Excuse me while I scream into the ethereal plane...

I know GameCI (again, massive shout out to them, fuck knows how I'd have done any of this without the community work done there) have an automated system for publish to steam, as well as iOS and Android builds. I'm hoping at some point that all of those features will get some use as they get filed under the million things to do. Next target is some UI and usability improvements, as well as improvements to the Happiness metric and scoring system. Currently it's really challenging to get and maintain positive happiness in your city, so some work may be required. Hoping January hasn't kicked your ass too badly, and that if it has, you get the chance to kick it right back. Much love, all!

Next Post Previous Post