Run automated tests for your Godot game on CI

Automated testing in gamedev

Nowadays, most people agree that automated testing is absolutely crucial for all software development. Not so much when it comes to games development though. I still believe that the games industry would be able to iterate and ship faster by introducing unit and integration testing in the right places.

Godot and Gut

Butch Wesley appears to be onboard, considering he created Gut, an automated testing framework for the Godot Game Engine. Gut provides you with a collection of utilities to write and run tests for your game. Out of the box you get basic assertions, test doubles and even full node tree simulation. Tests are run either from the Godot Editor or the command line using the godot executable itelf.

However, what good are automated tests if we exclusively rely on developers running them locally? The answer is: not very good at all.

Dead simple Godot CI pipeline

That is why I experimented with running GDScript tests on a Continuous Integration pipeline using the headless Godot runtime. I created a repo godot-ci-example you can copy to use on your own projects. Here is how it works.

Firstly, create a Godot project, install Gut from the Asset Library and enable it. This is the same as what is explained in Gut’s Install and Command Line wiki pages.

install-gut

Create a trivial test in res://test/unit/test_example.gd.

extends "res://addons/gut/test.gd"

func test_assert_true_with_true():
	assert_true(true, "Should pass, true is true")

You can now run these tests from the command line.

godot -d -s --path ./project addons/gut/gut_cmdln.gd -gdir=res://test -ginclude_subdirs -gexit

Where godot is your Godot binary and project is the folder where your game lives.

Alright, we now have a basic test setup we can run locally. Let’s move onto the meaty part of the article, continuous integration. I’ll be using Travis CI because it’s easy and free for open source projects hosted on Github, but knock yourself out with your CI system of choice.

Travis looks for a .travis.yml file in the root of your repo. This file tells Travis how to build the project and run tests. I recommend you take a quick look at the docs.

The .travis.yml file is trivial.

language: minimal
script: ./run_tests.sh

The run_tests.sh script will download the headless Godot runtime and run the command we showed above. Make sure run_tests.sh has executable permissions.

GODOT_VERSION=3.0.6
GODOT_BIN=Godot_v${GODOT_VERSION}-stable_linux_headless.64
GODOT_ZIP=${GODOT_BIN}.zip
GODOT_URL=https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/${GODOT_ZIP}

curl ${GODOT_URL} --output ${GODOT_ZIP}
unzip ${GODOT_ZIP}
chmod +x ${GODOT_BIN}
./${GODOT_BIN} -d -s --path ./project addons/gut/gut_cmdln.gd -gdir=res://test -ginclude_subdirs -gexit

As you can see, it’s also pretty easy to parameterize which Godot version you want to use.

And that’s it! You can get a cool “Build passing” badge for your repo. Here’s what a typical build would look like.

/-----------------------------------------
Running Script res://test/unit/test_example.gd
-----------------------------------------/
* test_assert_true_with_true
*****************
Run Summary
*****************
***  Totals  ***
  scripts:          1
  tests:            1
  passing asserts:  1
  failing asserts:  0
  pending:          0
+++ 1 passed 0 failed.  Tests finished in:  0.0 +++

Happy testing!

Load test your backend services with locust.io at Pycon ES 2017

PyCon ES 2017 was an absolute blast!

The talks were very interesting and they’re all freely available on their Youtube channel.

Celebrating PyCon ES 2017 in Caceres, located in southern Spain, was a great choice. Beautiful medieval city center where some scenes in Game of Thrones were filmed, plus cheap and delicious food.

The conference itself was hosted at an old monastery, repurposed for these kind of events. I honestly have never been to a conference with such a cool venue!

My colleague Andy and I gave a presentation titled “Load test your backend services with locust.io”, watch it!

Finally, take a look at some of my favorite talks in the conference, (most of them in Spanish):

Come to PyCon ES 2017!

pycon-es-2017

PyCon ES 2017, which will be running from September 22nd to September 24th in Cáceres, Spain. I’ll be attending alongside some Bloomberg colleagues as we are one of the main sponsors of the event. If you have tickets, definitely come say hi!

I’ll be helping out at a couple of presentations:

For those not coming, I’m pretty sure all the talks will be recorded and made publicly available.

JSConf EU 2017 - Recommended talks

jsconf-eu-2017

JSConf EU is one of the biggest JS conferences in Europe and I was lucky enough to attend its 2017 edition earlier this month. This year the event took place in Arena Berlin, a place by the river, typically dedicated to concerts in the east side of the German capital.

Overall, it was a pretty awesome weekend and although I wish there were more talks on advanced technical topics, I understand the event is more focused on community and diversity. It was flawlessly organised, special kudos for the attention to disabilities, the timeliness, quality of the food and free beer!

Below are my favorite talks.

Some of the others are still yet to be made available on the JSConf Youtube channel.

Ludum Dare 38 - Theme ideas

ludum-dare-logo

Ludum Dare 38 starts in a couple of hours. This one is special as it marks the 15th anniversary of the biggest weekend game development friendly competition in the world!

If you don’t know about Ludum Dare and are interested, check the documentary they just released.

I was thinking of participating using Godot Engine. I have a couple of social compromises this weekend and, honestly, I am a bit scared of failing miserably, so I’m not too sure how far I’ll take this one.

Theme

The initial theme voting stages have taken place throughout the week and now it’s down to the final round. The final theme will be announced right when the competition starts.

16 themes made it into the final round, I picked my top 5 and came up with quick pitches for each one of them. I know, some call this cheating but chances of success and for any of these themes to win are rather slim anyway!

Parallel Dimensions

Split-screen platformer where you control the same character in two parallel universes. Simple but slightly different levels. The goal is to reach the end, however hazards may be placed in different locations and both characters need to make it alive.

Inspiration: Ninja Twins

Pausing has Consequences

Rogue-like that becomes increasingly harder the longer you take to find the exit to each level. Enemies keep respawning.

Inspiration: Heroes of Loot and Left 4 Dead.

Two Colors

Visceral top-down action game where everything is grayscale except for blood.

Inspiration: Hotline Miami meets Sin City.

Island

You’re a castaway who must survive in a procedurally generated island. Find food, shelter, craft tools and keep threats off.

Inspiration: Stranded Deep and Castaway

Everything has a Cost

Strategy card game where you’re a stock broker. Climb up the ladder, make money or get fired. Stay honest or rot in jail!

Inspiration: Reigns

Good luck everybody!