Opens an external site in a new window
Pride Month Hold my hand 🫱🏾‍🫲🏼
RODNEY LAB
  • Home
  • Plus +
  • Newsletter
  • Links
  • Profile
RODNEY LAB
  • Home
  • Plus +
  • Newsletter
  • Links

Godot Rust CI: Handy GDScript & Rust GitHub Actions 🎬 # Godot Rust CI: Handy GDScript & Rust GitHub Actions 🎬 #

blurry low resolution placeholder image Godot Rust Game Dev
  1. Home Rodney Lab Home
  2. Blog Posts Rodney Lab Blog Posts
  3. Gaming Gaming Blog Posts
<PREVIOUS POST
NEXT POST >
LATEST POST >>

Godot Rust CI: Handy GDScript & Rust GitHub Actions 🎬 #

Updated 5 months ago
5 minute read
Gunning Fog Index: 5.3
Content by Rodney
blurry low resolution placeholder image Author Image: Rodney from Rodney Lab
SHARE:

🎬 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 .

.github/workflows/general.yml
yaml
    
1 name: Rust
2 on:
3 push:
4 branches:
5 - main
6 pull_request:
7 types: [opened, synchronize, reopened]
8 branches:
9 - main
10 permissions: read-all
11 # TRUNCATED...
12 static-checks:
13 name: 'GDScript Static checks'
14 runs-on: ubuntu-latest
15 steps:
16 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
17 - uses: Scony/godot-gdscript-toolkit@792ec443ed90a82fdff02465edefa128174b0107 # 4.3.1
18
19 - run: gdformat --check godot/
20 - run: gdlint godot/

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.

blurry low resolution placeholder image Godot Rust C I: screen capture show log from Git Hub action running godot-g d script-toolkit.  g d format output reads 4 files would be left unchanged and g d lint output reads Success: no problems found.
Godot Rust CI: godot-gdscript-toolkit GitHub Action run log

🦀 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 :

.github/workflows/general.yml
yaml
    
1 name: Rust
2 on:
3 push:
4 branches:
5 - main
6 pull_request:
7 types: [opened, synchronize, reopened]
8 branches:
9 - main
10 permissions: read-all
11 env:
12 CARGO_TERM_COLOR: always
13 RUSTFLAGS: "-Dwarnings -Cinstrument-coverage"
14 LLVM_PROFILE_FILE: "project-%p-%m.profraw"
15 jobs:
16 test:
17 name: Test
18 runs-on: ubuntu-latest
19 steps:
20 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
21 - uses: dtolnay/rust-toolchain@4f366e621dc8fa63f557ca04b8f4361824a35a45 # stable
22 - name: Run tests
23 run: cargo test
24 fmt:
25 name: Rustfmt
26 runs-on: ubuntu-latest
27 steps:
28 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
29 - uses: dtolnay/rust-toolchain@4f366e621dc8fa63f557ca04b8f4361824a35a45 # stable
30 with:
31 components: rustfmt
32 - name: Enforce formatting
33 run: cargo fmt --check
34 clippy:
35 name: Clippy
36 runs-on: ubuntu-latest
37 steps:
38 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
39 - uses: dtolnay/rust-toolchain@4f366e621dc8fa63f557ca04b8f4361824a35a45 # stable
40 with:
41 components: clippy
42 - name: Linting
43 run: cargo clippy -- -D warnings

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 #

.github/workflows/general.yml
yaml
    
1 name: Rust
2 on:
3 push:
4 branches:
5 - main
6 pull_request:
7 types: [opened, synchronize, reopened]
8 branches:
9 - main
10 permissions: read-all
11 # TRUNCATED...
12 msrv:
13 runs-on: ubuntu-latest
14 strategy:
15 matrix:
16 msrv: ["1.80.0"]
17 name: ubuntu / ${{ matrix.msrv }}
18 steps:
19 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
20 - name: Install Linux Dependencies
21 run: sudo apt-get update
22 - name: Install ${{ matrix.msrv }}
23 uses: dtolnay/rust-toolchain@4f366e621dc8fa63f557ca04b8f4361824a35a45 # stable
24 with:
25 toolchain: ${{ matrix.msrv }}
26 - name: cargo +${{ matrix.msrv }} check
27 run: cargo check

Cargo Deny Licence Check Action #

.github/workflows/validate-licences.yml
yaml
    
1 name: Cargo Deny
2 on: [push, pull_request]
3 permissions:
4 contents: read
5 jobs:
6 cargo-deny:
7 runs-on: ubuntu-22.04
8 strategy:
9 matrix:
10 checks:
11 - advisories
12 - bans licenses sources
13 # Prevent sudden announcement of a new advisory from failing ci:
14 continue-on-error: ${{ matrix.checks == 'advisories' }}
15 steps:
16 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
17 - uses: EmbarkStudios/cargo-deny-action@8371184bd11e21dcf8ac82ebf8c9c9f74ebf7268 # v2.0.1
18 with:
19 command: check ${{ matrix.checks }}

See cargo-deny-action repo for configuration details .

Rust Security Audit Action #

.github/workflows/audit-on-push.yml
yaml
    
1 name: Security audit
2 permissions:
3 contents: read
4 on:
5 push:
6 paths:
7 - 'Cargo.toml'
8 - 'Cargo.lock'
9 jobs:
10 security_audit:
11 runs-on: ubuntu-latest
12 steps:
13 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14 - uses: rustsec/audit-check@dd51754d4e59da7395a4cd9b593f0ff2d61a9b95 # v1.4.1
15 with:
16 token: ${{ secrets.GITHUB_TOKEN }}

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 #

Which version control provider do you use for Godot games?
Voting reveals latest results.

🙌🏽 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.

blurry low resolution placeholder image ask Rodney X (formerly Twitter) avatar

Rodney

@askRodney

Just dropped a post on some GitHub Actions to add your Rust Godot project for linting and formatting.

Post covers GDScript and Rust code.

Hope you find it useful!

#askRodney #rustlang #gamedevhttps://t.co/mSKPyQEIQv

— Rodney (@askRodney) August 7, 2024

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.

Thanks for reading this post. I hope you found it valuable. Please get in touch with your feedback and suggestions for posts you would like to see. Read more about me …

blurry low resolution placeholder image Rodney from Rodney Lab
TAGS:
RUSTGAMING

Reposts:

Reposts

  • Gaming Feed profile avatar

Likes:

Likes

  • Nicole Marie T profile avatar
  • Omstero profile avatar
Reposts & likes provided by Mastodon & X via Webmentions.

Related Posts

blurry low resolution placeholder image Godot Rust CI: Handy GDScript & Rust GitHub Actions 🎬

Godot Rust CI: Handy GDScript & Rust GitHub Actions 🎬

rust
gaming
<PREVIOUS POST
NEXT POST >
LATEST POST >>

Leave a comment …

Your information will be handled in line with our Privacy Policy .

Ask for more

1 Nov 2022 — Astro Server-Side Rendering: Edge Search Site
3 Oct 2022 — Svelte eCommerce Site: SvelteKit Snipcart Storefront
1 Sept 2022 — Get Started with SvelteKit Headless WordPress

Copyright © 2020 – 2025 Rodney Johnson. All Rights Reserved. Please read important copyright and intellectual property information.

  • Home
  • Profile
  • Plus +
  • Newsletter
  • Contact
  • Links
  • Terms of Use
  • Privacy Policy
We use cookies  to enhance visitors’ experience. Please click the “Options” button to make your choice.  Learn more here.