🎬 Godot Rust GitHub Actions #
In this Godot Rust CI post, we take a quick look at some GitHub action you might want to add to your project for linting GDScript and Rust code on each commit.
The config, below, is based on the Knights to See You game. I ran through that project and some resources for getting going with Godot Rust bindings in a recent post. You might want to start there if you are new to Rust in Godot.
GitHub actions let you run continuous integration processes on each commit, usually by adding a
YAML config file in a .github/workflows
directory for your project.
They can take a little trial-and-error to get right, but are worth the effort for keeping code consistent,
running unit tests, finding outdated packages and even spotting potential security vulnerabilities.
There is a link further down to the full project code.
🤖 GDScript Linting and Formatting #
The project uses a mix of Rust and GDScript, and for linting the GDScript code in GitHub actions, I use godot-gdscript-toolkit .
Setting default read-only permissions in a line 10
is a good idea,
to limit access actions have to your repo. You can override this for any actions which require repo
write access.
I use commit hashes to identify the exact action I want to run, though you can just use tag, instead.
The project is structured with godot
and rust
folders at the root level, and I set gdformat
and gdlint
only to run on the godot
directory. gdformat
provides opinionated GDScript formatting, while gdlint
includes
checks for unnecessary else statements, unused arguments and that your naming is consistent with the
GDScript style guide (snake case function names, Pascal Case classes etc) among other checks.
🦀 Rust Linting and Formatting #
Rust is well-known for having integrated formatting, linting, testing through cargo utilities, and you can set these up to run in GitHub actions by dtolnay :
You are probably already familiar with these tools, but let me know if the GitHub action side of things needs more explanation.
🧐 Other Handy Rust Actions #
Jon Gjengset has a fantastic video, in which he takes you through setting up CI on a Rust GitHub repo . You can clone his setup into any new Rust projects. Essentially, that is the process I followed for Knights to See You. Besides the Rust actions above, I have:
- msrv check - a check that the project successfully builds using the Minimum Supported Rust version I give in
Cargo.toml
. This is worth checking in CI, since locally you will, likely, be running a newer Rust version. - cargo deny check - this checks the licences of any crates you use in your project and dependencies of those crates. You create your own allow list of licences, and the tool highlights any projects without matching licences. This helps avoid surprises further down the line.
- audit-check - finds crates with security vulnerabilities.
Rust MSRV Check Action #
Cargo Deny Licence Check Action #
See cargo-deny-action repo for configuration details .
Rust Security Audit Action #
See audit-check repo for configuration details .
There are more checks you might want to include, depending on your project, and I have only highlighted a few here. See Jon Gjengset’s rust-ci-config repo for more.
🗳 Poll #
🙌🏽 Godot Rust CI: Wrapping Up #
In this Godot Rust CI, we took a quick look through some GitHub actions you might want to add to your Godot Rust game. In particular, we looked at:
- actions for linting and formatting GDScript;
- running familiar cargo tooling in GitHub actions; and
- also how to run security audit and licence checks on your Rust crates in CI.
I hope you found this useful. As promised, you can get the full project code on the Rodney Lab GitHub repo . I would love to hear from you, if you are also new to Godot video game development. Were there other resources you found useful? Also, let me know what kind of game you are working on!
🙏🏽 Godot Rust CI: Feedback #
If you have found this post useful, see links below for further related content on this site. Let me know if there are any ways I can improve on it. I hope you will use the code or starter in your own projects. Be sure to share your work on X, giving me a mention, so I can see what you did. Finally, be sure to let me know ideas for other short videos you would like to see. Read on to find ways to get in touch, further below. If you have found this post useful, even though you can only afford even a tiny contribution, please consider supporting me through Buy me a Coffee.
Just dropped a post on some GitHub Actions to add your Rust Godot project for linting and formatting.
— Rodney (@askRodney) August 7, 2024
Post covers GDScript and Rust code.
Hope you find it useful!
#askRodney #rustlang #gamedevhttps://t.co/mSKPyQEIQv
Finally, feel free to share the post on your social media accounts for all your followers who will find it useful. As well as leaving a comment below, you can get in touch via @askRodney on X (previously Twitter) and also, join the #rodney Element Matrix room. Also, see further ways to get in touch with Rodney Lab. I post regularly on Game Dev as well as Rust and C++ (among other topics). Also, subscribe to the newsletter to keep up-to-date with our latest projects.