Skip to content

Commit b99a502

Browse files
authored
ci: GUT Test GitHub Action (#360)
* test: ✅ initial test environment * test: ✅ initial test environment * ci: 🚧 WIP: GitHub Actions * ci: 🚧 WIP: Adding GitHub Action for Tests * refactor: ♻️ ignore `.import` * ci: ✨ Working Test Action * fix: 🐛 fixed missing default * ci: ♻️ run action on push and pr * fix: 🐛 fixed indentation * fix: 🐛 added missing `shell` prop * fix: 🐛 fixed `godot-bin` input * ci: ♻️ moved test run script into `.sh` file * fix: 🐛 fix `Permission denied` fix: 🐛 fix `Permission denied` fix: 🐛 fix `Permission denied` fix: 🐛 fix `Permission denied` fix: 🐛 fix `Permission denied` * ci: ♻️ added GUT download step * test: ♻️ removed GUT * test: 🙈 ignore all addons * ci: 🐛 fixed gut download cache * test: 🔥 only run `gut_cmdln.gd` gut returns exit code 1 if a test fails * test: 🔥 removed root dir gut files * fix: 🐛 fixed typo * fix: 🐛 fix godot bin cache
1 parent a84128a commit b99a502

File tree

26 files changed

+756
-1
lines changed

26 files changed

+756
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Inspired by https://github.com/bitbrain/beehave/blob/godot-4.x/.github/actions/godot-install/action.yml
2+
3+
name: install-godot-binary
4+
description: "Installs the Godot Runtime"
5+
6+
inputs:
7+
godot-version:
8+
description: "The Godot engine version"
9+
type: string
10+
required: true
11+
godot-status-version:
12+
description: "The Godot engine status version"
13+
type: string
14+
required: true
15+
godot-bin-name:
16+
type: string
17+
required: true
18+
godot-cache-path:
19+
type: string
20+
required: true
21+
22+
23+
runs:
24+
using: composite
25+
steps:
26+
27+
- name: "Set Cache Name"
28+
shell: bash
29+
run: |
30+
echo "CACHE_NAME=${{ runner.OS }}-Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}" >> "$GITHUB_ENV"
31+
32+
- name: "Godot Cache Restore"
33+
uses: actions/cache/restore@v3
34+
id: godot-restore-cache
35+
with:
36+
path: ${{ inputs.godot-cache-path }}
37+
key: ${{ env.CACHE_NAME }}
38+
39+
- name: "Download and Install Godot ${{ inputs.godot-version }}"
40+
if: steps.godot-restore-cache.outputs.cache-hit != 'true'
41+
continue-on-error: false
42+
shell: bash
43+
run: |
44+
mkdir -p ${{ inputs.godot-cache-path }}
45+
chmod 770 ${{ inputs.godot-cache-path }}
46+
DIR="$HOME/.config/godot"
47+
if [ ! -d "$DIR" ]; then
48+
mkdir -p "$DIR"
49+
chmod 770 "$DIR"
50+
fi
51+
52+
DOWNLOAD_URL=https://github.com/godotengine/godot/releases/download/${{ inputs.godot-version }}-${{ inputs.godot-status-version }}
53+
GODOT_BIN=Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}_${{ inputs.godot-bin-name }}
54+
55+
GODOT_PACKAGE=$GODOT_BIN.zip
56+
wget $DOWNLOAD_URL/$GODOT_PACKAGE -P ${{ inputs.godot-cache-path }}
57+
unzip ${{ inputs.godot-cache-path }}/$GODOT_PACKAGE -d ${{ inputs.godot-cache-path }}
58+
59+
mv ${{ inputs.godot-cache-path }}/$GODOT_BIN ${{ inputs.godot-cache-path }}/godot
60+
61+
chmod u+x ${{ inputs.godot-cache-path }}/godot
62+
echo "${{ inputs.godot-cache-path }}/godot"
63+
64+
- name: "Godot Cache Save"
65+
if: steps.godot-restore-cache.outputs.cache-hit != 'true'
66+
uses: actions/cache/save@v3
67+
with:
68+
path: ${{ inputs.godot-cache-path }}
69+
key: ${{ steps.godot-restore-cache.outputs.cache-primary-key }}

.github/actions/test/action.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Inspired by https://github.com/utopia-rise/fmod-gdextension/blob/godot-3.x/demo/run_tests.sh
2+
3+
name: test
4+
description: "Runs the tests via GUT CLI"
5+
6+
inputs:
7+
gut-download-path:
8+
required: true
9+
default: ~/gut_download
10+
gut-addons-path:
11+
required: true
12+
default: ${{ github.workspace }}/test/addons/gut
13+
godot-test-project:
14+
required: true
15+
default: ${{ github.workspace }}/test
16+
17+
runs:
18+
using: composite
19+
20+
steps:
21+
22+
- name: "Set Cache Name"
23+
shell: bash
24+
run: |
25+
echo "CACHE_NAME_GUT=GUT_v7.4.1" >> "$GITHUB_ENV"
26+
27+
- name: "GUT Cache Restore"
28+
uses: actions/cache/restore@v3
29+
id: gut-restore-cache
30+
with:
31+
path: ${{ inputs.gut-download-path }}
32+
key: ${{ runner.os }}-${{ env.CACHE_NAME_GUT }}
33+
34+
- name: "Download GUT"
35+
if: steps.gut-restore-cache.outputs.cache-hit != 'true'
36+
continue-on-error: false
37+
shell: bash
38+
run: |
39+
mkdir -p ${{ inputs.gut-download-path }}
40+
chmod 770 ${{ inputs.gut-download-path }}
41+
42+
wget https://github.com/bitwes/Gut/archive/refs/tags/v7.4.1.zip -P ${{ inputs.gut-download-path }}
43+
unzip ${{ inputs.gut-download-path }}/v7.4.1.zip -d ${{ inputs.gut-download-path }}/unzip
44+
45+
- name: "GUT Cache Save"
46+
if: steps.gut-restore-cache.outputs.cache-hit != 'true'
47+
uses: actions/cache/save@v3
48+
with:
49+
path: ${{ inputs.gut-download-path }}
50+
key: ${{ steps.gut-restore-cache.outputs.cache-primary-key }}
51+
52+
- name: "Create addons Directory"
53+
if: ${{ !cancelled() }}
54+
shell: bash
55+
run: mkdir -p ${{ github.workspace }}/test/addons
56+
57+
- name: "⚔ Link GUT"
58+
if: ${{ !cancelled() }}
59+
shell: bash
60+
run: ln -s ${{ inputs.gut-download-path }}/unzip/Gut-7.4.1/addons/gut ${{ github.workspace }}/test/addons/gut
61+
62+
- name: "⚔ Link Mod Loader"
63+
if: ${{ !cancelled() }}
64+
shell: bash
65+
run: ln -s ${{ github.workspace }}/addons/mod_loader ${{ github.workspace }}/test/addons/mod_loader
66+
67+
- name: "⚔ Link JSON_Schema_Validator"
68+
if: ${{ !cancelled() }}
69+
shell: bash
70+
run: ln -s ${{ github.workspace }}/addons/JSON_Schema_Validator ${{ github.workspace }}/test/addons/JSON_Schema_Validator
71+
72+
- name: "Run Tests"
73+
if: ${{ runner.OS == 'Linux'}} && ${{ !cancelled() }}
74+
env:
75+
TEST_PROJECT: ${{ inputs.godot-test-project }}
76+
shell: bash
77+
run: |
78+
cd "${TEST_PROJECT}"
79+
chmod +x run_tests.sh
80+
./run_tests.sh "$HOME/godot-linux/godot"

.github/workflows/main.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
on: [pull_request]
1+
# Inspired by https://github.com/bitbrain/beehave/blob/godot-4.x/.github/workflows/beehave-ci.yml
2+
3+
name: Mod Loader CI
4+
5+
on:
6+
push:
7+
paths-ignore:
8+
- '**.jpg'
9+
- '**.png'
10+
- '**.svg'
11+
- '**.md'
12+
- '**plugin.cfg'
13+
pull_request:
14+
paths-ignore:
15+
- '**.jpg'
16+
- '**.png'
17+
- '**.svg'
18+
- '**.md'
19+
- '**plugin.cfg'
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
225
jobs:
326
check_dependencies:
427
runs-on: ubuntu-latest
@@ -7,3 +30,8 @@ jobs:
730
- uses: gregsdennis/dependencies-action@main
831
env:
932
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
tests:
34+
name: "Running GUT tests on Godot 3.5.3"
35+
uses: ./.github/workflows/tests.yml
36+
with:
37+
godot-version: '3.5.3'

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Inspired by https://github.com/bitbrain/beehave/blob/godot-4.x/.github/workflows/unit-tests.yml
2+
3+
name: tests
4+
run-name: ${{ github.head_ref || github.ref_name }}-tests
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
os:
10+
required: false
11+
type: string
12+
default: 'ubuntu-22.04'
13+
godot-version:
14+
required: true
15+
type: string
16+
default: '3.5.3'
17+
18+
workflow_dispatch:
19+
inputs:
20+
os:
21+
required: false
22+
type: string
23+
default: 'ubuntu-22.04'
24+
godot-version:
25+
required: true
26+
type: string
27+
28+
concurrency:
29+
group: tests-${{ github.head_ref || github.ref_name }}-${{ inputs.godot-version }}
30+
cancel-in-progress: true
31+
32+
jobs:
33+
test:
34+
name: "Tests"
35+
runs-on: ${{ inputs.os }}
36+
timeout-minutes: 15
37+
38+
steps:
39+
- name: "📦 Checkout Mod Loader Repository"
40+
uses: actions/checkout@v4
41+
with:
42+
lfs: true
43+
submodules: 'recursive'
44+
45+
- name: "🤖 Install Godot ${{ inputs.godot-version }}"
46+
uses: ./.github/actions/godot-install
47+
with:
48+
godot-version: ${{ inputs.godot-version }}
49+
godot-status-version: 'stable'
50+
godot-bin-name: 'linux_headless.64'
51+
godot-cache-path: '~/godot-linux'
52+
53+
- name: "🧪 Run Tests"
54+
if: ${{ !cancelled() }}
55+
timeout-minutes: 4
56+
uses: ./.github/actions/test
57+
with:
58+
godot-test-project: ${{ github.workspace }}/test

test/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.import/
2+
*.import
3+
addons/
4+
5+
# Gut stuff in root dir
6+
asset_lib_icon.png
7+
gut_panel.png
8+
.gut_editor_shortcuts.cfg
9+
BigFont.tres
10+
BigFontTheme.tres

test/.gutconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"dirs":["res://Unit/"],
3+
"double_strategy":"partial",
4+
"ignore_pause":false,
5+
"include_subdirs":true,
6+
"inner_class":"",
7+
"log_level":3,
8+
"opacity":100,
9+
"prefix":"test_",
10+
"selected":"",
11+
"should_exit":true,
12+
"should_maximize":true,
13+
"suffix":".gd",
14+
"tests":[],
15+
"unit_test_name":""
16+
}

test/TestRunner.tscn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://addons/gut/plugin_control.gd" type="Script" id=1]
4+
5+
[node name="TestRunner" type="Control"]
6+
margin_right = 740.0
7+
margin_bottom = 250.0
8+
rect_min_size = Vector2( 740, 250 )
9+
script = ExtResource( 1 )
10+
_directory1 = "res://Unit"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extends GutTest
2+
3+
4+
#var order_before_357_correct := [
5+
# "res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_b.gd",
6+
# "res://mods-unpacked/test-mod2/extensions/script_extension_sorting/script_c.gd",
7+
# "res://mods-unpacked/test-mod1/extensions/script_extension_sorting/script_c.gd",
8+
# "res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_d.gd"
9+
#]
10+
11+
var order_after_357_correct := [
12+
"res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_b.gd",
13+
"res://mods-unpacked/test-mod1/extensions/script_extension_sorting/script_c.gd",
14+
"res://mods-unpacked/test-mod2/extensions/script_extension_sorting/script_c.gd",
15+
"res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_d.gd"
16+
]
17+
18+
19+
func test_handle_script_extensions():
20+
var extension_paths := [
21+
"res://mods-unpacked/test-mod1/extensions/script_extension_sorting/script_c.gd",
22+
"res://mods-unpacked/test-mod2/extensions/script_extension_sorting/script_c.gd",
23+
"res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_b.gd",
24+
"res://mods-unpacked/test-mod3/extensions/script_extension_sorting/script_d.gd"
25+
]
26+
27+
extension_paths.sort_custom(_ModLoaderScriptExtension.InheritanceSorting.new(), "_check_inheritances")
28+
29+
assert_true(extension_paths == order_after_357_correct, "Expected %s but was %s instead" % [JSON.print(order_after_357_correct, "\t"), JSON.print(extension_paths, "\t")])

test/default_env.tres

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_resource type="Environment" load_steps=2 format=2]
2+
3+
[sub_resource type="ProceduralSky" id=1]
4+
5+
[resource]
6+
background_mode = 2
7+
background_sky = SubResource( 1 )

test/icon.png

3.23 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends "res://script_extension_sorting/script_c.gd"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "mod1",
3+
"namespace": "test",
4+
"version_number": "0.0.1",
5+
"description": "Description of your mod...",
6+
"website_url": "https://github.com/exampleauthor/examplemod",
7+
"dependencies": [
8+
9+
],
10+
"extra": {
11+
"godot": {
12+
"authors": [
13+
"AuthorName"
14+
],
15+
"optional_dependencies": [
16+
17+
],
18+
"compatible_game_version": [
19+
"0.0.1"
20+
],
21+
"compatible_mod_loader_version": [
22+
"6.1.0"
23+
],
24+
"incompatibilities": [
25+
26+
],
27+
"load_before": [
28+
29+
],
30+
"tags": [
31+
32+
],
33+
"config_schema": {
34+
35+
},
36+
"description_rich": "",
37+
"image": null
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)