Skip to content

Commit d6d5669

Browse files
authored
GD-295: Add CI-PR workflow to run on pull requests (#296)
* GD-295: Add `CI-PR` workflow run on each PR - create ci-pr workflow - using a matrix to iterate over supported Godot versions - split existing jobs into separate actions - include subproject gdunit examples - use a hard kill to finish the update project script and let handle as success (needs deeper investigation why scene.quit(0) is not working)
1 parent 8124767 commit d6d5669

File tree

13 files changed

+213
-23
lines changed

13 files changed

+213
-23
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: install-godot-image
2+
description: "Installs the Godot image"
3+
4+
inputs:
5+
godot-version:
6+
description: "The Godot Engine version to run"
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Install Godot ${{ inputs.godot-version }}
13+
id : install
14+
continue-on-error: false
15+
env:
16+
GODOT_BIN: /usr/local/bin/godot/Godot.app/Contents/MacOS/Godot
17+
shell: bash
18+
run: |
19+
mkdir /usr/local/bin/godot
20+
wget https://downloads.tuxfamily.org/godotengine/${{ inputs.godot-version }}/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip -P /usr/local/bin/godot
21+
unzip /usr/local/bin/godot/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip -d /usr/local/bin/godot/
22+
rm /usr/local/bin/godot/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip
23+
ls -lsR /usr/local/bin/godot
24+
chmod 770 /usr/local/bin/godot/Godot.app/Contents/MacOS/Godot

.github/actions/publish-test-report/action.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ runs:
1212
- name: Publish Test Results
1313
uses: dorny/test-reporter@v1
1414
with:
15-
name: ${{ inputs.report-name }}
15+
name: test_report_${{ inputs.report-name }}
1616
path: 'reports/**/results.xml'
1717
reporter: java-junit
18+
fail-on-error: 'false'

.github/actions/unit-test/action.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: unit-test
2+
description: "Run unit tests for GdUnit3 API"
3+
4+
inputs:
5+
test-includes:
6+
description: "Paths to include for test run"
7+
required: true
8+
godot-bin:
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: "Unit Test"
15+
env:
16+
GODOT_BIN: ${{ inputs.godot-bin }}
17+
shell: bash
18+
run: ./runtest.sh --add ${{ inputs.test-includes }} --continue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: upload-test-report
2+
description: "Uploads the GdUnit test reports"
3+
4+
inputs:
5+
report-name:
6+
description: "Name of the report to be upload."
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Collect Test Artifacts
13+
uses: actions/upload-artifact@v2
14+
with:
15+
name: test_report_${{ inputs.report-name }}
16+
path: reports/**

.github/workflows/ci-pr.yml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: ci-pr
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.jpg'
7+
- '**.png'
8+
- '**.md'
9+
pull_request_target:
10+
paths-ignore:
11+
- '**.jpg'
12+
- '**.png'
13+
- '**.md'
14+
workflow_dispatch:
15+
16+
env:
17+
GODOT_BIN: "/usr/local/bin/godot"
18+
19+
concurrency:
20+
group: ci-pr-${{ github.event.number }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
25+
unit-test:
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
godot-version: [3.4.1, 3.4.2, 3.4.4, mono-3.4.1, mono-3.4.2, mono-3.4.4]
30+
31+
name: "CI Godot ${{ matrix.godot-version }}"
32+
runs-on: ubuntu-latest
33+
timeout-minutes: 15
34+
continue-on-error: false
35+
container:
36+
image: barichello/godot-ci:${{ matrix.godot-version }}
37+
outputs:
38+
godot-version: ${{ matrix.godot-version }}
39+
40+
steps:
41+
- name: "Checkout Repository"
42+
uses: actions/checkout@v3
43+
with:
44+
lfs: true
45+
submodules: 'recursive'
46+
47+
- name: "Update Project"
48+
if: ${{ !cancelled() }}
49+
timeout-minutes: 1
50+
continue-on-error: true # we still ignore the timeout, the script is not quit and we run into a timeout
51+
run: |
52+
${{ env.GODOT_BIN }} -e --path . -s res://addons/gdUnit3/scan_project.gd --no-window
53+
54+
- name: "Setup .NET"
55+
if: ${{ startsWith( matrix.godot-version, 'mono') }} # we only setup .Net for mono versions
56+
uses: actions/setup-dotnet@v1
57+
with:
58+
dotnet-version: 6.0.x
59+
60+
- name: "Compile C#"
61+
if: ${{ startsWith( matrix.godot-version, 'mono') }} # we only compile .Net for mono versions
62+
run: |
63+
dotnet restore gdUnit3.csproj
64+
mkdir -p .mono/assemblies/Debug
65+
cp /usr/local/bin/GodotSharp/Api/Release/* .mono/assemblies/Debug
66+
dotnet build -verbosity:m
67+
68+
- name: "Run Unit Test"
69+
if: ${{ !cancelled() }}
70+
timeout-minutes: 10
71+
uses: ./.github/actions/unit-test
72+
with:
73+
godot-bin: ${{ env.GODOT_BIN }}
74+
test-includes: "res://addons/gdUnit3/test/"
75+
76+
- name: "Run Unit Test Examples"
77+
if: ${{ !cancelled() }}
78+
timeout-minutes: 1
79+
uses: ./.github/actions/unit-test
80+
with:
81+
godot-bin: ${{ env.GODOT_BIN }}
82+
test-includes: "res://gdUnit3-examples"
83+
84+
- name: "Publish Unit Test Reports"
85+
if: ${{ !cancelled() }}
86+
uses: ./.github/actions/publish-test-report
87+
with:
88+
report-name: ${{ matrix.godot-version }}
89+
90+
- name: "Upload Unit Test Reports"
91+
if: ${{ !cancelled() }}
92+
uses: ./.github/actions/upload-test-report
93+
with:
94+
report-name: ${{ matrix.godot-version }}

addons/gdUnit3/bin/GdUnitCmdTool.gd

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ class CLIRunner extends Node:
2727
var _console := CmdConsole.new()
2828
var _cs_executor
2929
var _rtf :RichTextLabelExt
30-
3130
var _cmd_options: = CmdOptions.new([
3231
CmdOption.new("-a, --add", "-a <directory|path of testsuite>", "Adds the given test suite or directory to the execution pipeline.", TYPE_STRING),
3332
CmdOption.new("-i, --ignore", "-i <testsuite_name|testsuite_name:test-name>", "Adds the given test suite or test case to the ignore list.", TYPE_STRING),
3433
CmdOption.new("-c, --continue", "", "By default GdUnit will abort on first test failure to be fail fast, instead of stop after first failure you can use this option to run the complete test set."),
3534
CmdOption.new("-conf, --config", "-conf [testconfiguration.cfg]", "Run all tests by given test configuration. Default is 'GdUnitRunner.cfg'", TYPE_STRING, true),
35+
CmdOption.new("-help", "", "Shows this help message."),
36+
CmdOption.new("--help-advanced", "", "Shows advanced options.")
3637
], [
3738
# advanced options
3839
CmdOption.new("-rd, --report-directory", "-rd <directory>", "Specifies the output directory in which the reports are to be written. The default is res://reports/.", TYPE_STRING, true),

addons/gdUnit3/scan_project.gd

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env -S godot -s
2+
tool
3+
extends SceneTree
4+
5+
enum {
6+
INIT,
7+
SCAN,
8+
QUIT
9+
}
10+
11+
var _counter = 0
12+
var WAIT_TIME_IN_MS = 5.000
13+
var _state = INIT
14+
15+
func _init():
16+
disable_gdUnit()
17+
print("Scan for project changes ...")
18+
_state = SCAN
19+
20+
func _idle(delta):
21+
if _state != SCAN:
22+
return
23+
_counter += delta
24+
#prints("scanning", _counter, OS.get_time(), OS.get_process_id())
25+
yield(root.get_tree(), "idle_frame")
26+
if _counter >= WAIT_TIME_IN_MS:
27+
prints("Scan for project changes done")
28+
_state = QUIT
29+
#finish()
30+
rescan()
31+
#Engine.get_main_loop().finish()
32+
OS.kill(OS.get_process_id())
33+
34+
35+
func rescan(update_scripts :bool = false) -> void:
36+
yield(root.get_tree(), "idle_frame")
37+
var plugin := EditorPlugin.new()
38+
var fs := plugin.get_editor_interface().get_resource_filesystem()
39+
fs.scan_sources()
40+
while fs.is_scanning():
41+
yield(root.get_tree().create_timer(1), "timeout")
42+
if update_scripts:
43+
plugin.get_editor_interface().get_resource_filesystem().update_script_classes()
44+
plugin.free()
45+
46+
47+
static func disable_gdUnit() -> void:
48+
prints("disable_gdUnit")
49+
var plugin := EditorPlugin.new()
50+
plugin.get_editor_interface().set_plugin_enabled("gdUnit3", false)
51+
plugin.free()

addons/gdUnit3/src/cmd/CmdOptions.gd

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ class_name CmdOptions
22
extends Reference
33

44

5-
var OPTION_HELP = CmdOption.new("-help", "", "Shows this help message.")
6-
var OPTION_ADVANCES_HELP = CmdOption.new("--help-advanced", "", "Shows advanced options.")
75
var _default_options :Array
86
var _advanced_options :Array
97

108

119
func _init(options :Array = Array(), advanced_options :Array = Array()):
1210
# default help options
13-
_default_options = [OPTION_HELP, OPTION_ADVANCES_HELP] + options
11+
_default_options = options
1412
_advanced_options = advanced_options
1513

1614
func default_options() -> Array:
@@ -27,6 +25,3 @@ func get_option(cmd :String) -> CmdOption:
2725
if Array(option.commands()).has(cmd):
2826
return option
2927
return null
30-
31-
func is_help(option :CmdOption) -> bool:
32-
return option == OPTION_HELP or option == OPTION_ADVANCES_HELP

addons/gdUnit3/src/ui/parts/InspectorToolBar.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ signal run_pressed
55
signal stop_pressed
66

77

8-
onready var debug_icon_image :StreamTexture = load("res://addons/gdUnit3/src/ui/assets/PlayDebug.svg")
8+
onready var debug_icon_image :Texture = load("res://addons/gdUnit3/src/ui/assets/PlayDebug.svg")
99
onready var _version_label := $Tools/CenterContainer/version
1010
onready var _button_wiki := $Tools/help
1111
onready var _tool_button := $Tools/tool

addons/gdUnit3/test/cmd/CmdOptionsTest.gd

-11
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,9 @@ func test_get_option():
3535
# for not existsing command
3636
assert_object(_cmd_options.get_option("-z")).is_null()
3737

38-
func test_is_help():
39-
assert_bool(_cmd_options.is_help(option_a)).is_false()
40-
assert_bool(_cmd_options.is_help(option_b)).is_false()
41-
assert_bool(_cmd_options.is_help(option_f)).is_false()
42-
assert_bool(_cmd_options.is_help(option_x)).is_false()
43-
assert_bool(_cmd_options.is_help(_cmd_options.OPTION_HELP)).is_true()
44-
assert_bool(_cmd_options.is_help(_cmd_options.OPTION_ADVANCES_HELP)).is_true()
4538

4639
func test_default_options():
4740
assert_array(_cmd_options.default_options()).contains_exactly([
48-
_cmd_options.OPTION_HELP,
49-
_cmd_options.OPTION_ADVANCES_HELP,
5041
option_a,
5142
option_f,
5243
option_b])
@@ -56,8 +47,6 @@ func test_advanced_options():
5647

5748
func test_options():
5849
assert_array(_cmd_options.options()).contains_exactly([
59-
_cmd_options.OPTION_HELP,
60-
_cmd_options.OPTION_ADVANCES_HELP,
6150
option_a,
6251
option_f,
6352
option_b,

default_env.tres

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
[sub_resource type="ProceduralSky" id=1]
44

55
[resource]
6-
background_mode = 2
76
background_sky = SubResource( 1 )

runtest.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ if [ -z "$GODOT_BIN" ]; then
66
exit 1
77
fi
88

9-
$GODOT_BIN --no-window -s -d ./addons/gdUnit3/bin/GdUnitCmdTool.gd $*
9+
# we not use no-window because of issue https://github.com/godotengine/godot/issues/55379
10+
#$GODOT_BIN --no-window -s -d ./addons/gdUnit3/bin/GdUnitCmdTool.gd $*
11+
$GODOT_BIN -s -d ./addons/gdUnit3/bin/GdUnitCmdTool.gd $*
1012
exit_code=$?
1113
$GODOT_BIN --no-window --quiet -s -d ./addons/gdUnit3/bin/GdUnitCopyLog.gd $* > /dev/null
1214
exit $exit_code

0 commit comments

Comments
 (0)