Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nullpointer authored and MikeSchulze committed Feb 4, 2024
0 parents commit 452fed9
Show file tree
Hide file tree
Showing 28 changed files with 1,442 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .gdunit4_action/check-coredump/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: check-coredump
description: "Checks for created coredumps"

inputs:
artifact-name:
description: "Name of artifact to upload."
required: true

runs:
using: composite
steps:

- name: "Check for existing coredumps"
shell: bash
if: always()
id: collectlogs
# we have actual no debug infos and coredumpctl gdb will fail, we just ignore for this for the moment
continue-on-error: true
run: |
# wait for in progress coredumps
sleep 10
if coredumpctl list; then
echo "coredumps=true" >>$GITHUB_OUTPUT
sudo coredumpctl gdb <<<"
set verbose on
set trace-commands on
show debug-file-directory
printf "'"'"query = '%s'\n\n"'"'", debug_query_string
frame function ExceptionalCondition
printf "'"'"condition = '%s'\n"'"'", conditionName
up 1
l
info args
info locals
bt full
" 2>&1 | tee stacktrace.log
fi
true
- name: "Upload Coredumps"
if: always() && steps.collectlogs.outputs.coredumps == 'true'
uses: actions/upload-artifact@v4
with:
name: Coredump_${{ inputs.artifact-name }}
path: /var/lib/systemd/coredump

- name: "Cleanup Coredumps"
shell: bash
if: always() && steps.collectlogs.outputs.coredumps == 'true'
run: |
sudo journalctl --rotate
sudo journalctl --vacuum-time=5s
sudo rm -rf /var/lib/systemd/coredump/*
67 changes: 67 additions & 0 deletions .gdunit4_action/godot-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: install-godot-binary
description: "Installs the Godot Runtime"

inputs:
godot-version:
description: "The Godot engine version"
type: string
required: true
godot-status-version:
description: "The Godot engine status version"
type: string
required: true
godot-net:
required: false
type: boolean
default: false
install-path:
type: string
required: true

runs:
using: composite
steps:

- name: "Download and Install Godot ${{ inputs.godot-version }}-${{ inputs.godot-status-version }}"
if: steps.godot-cache-binary.outputs.cache-hit != 'true'
continue-on-error: false
shell: bash
run: |
mkdir -p ${{ inputs.install-path }}
chmod 770 ${{ inputs.install-path }}
DIR="$HOME/.config/godot"
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR"
chmod 770 "$DIR"
fi
DOWNLOAD_URL=https://github.com/godotengine/godot-builds/releases/download/${{ inputs.godot-version }}-${{ inputs.godot-status-version }}
GODOT_BIN=Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}_linux.x86_64
if ${{inputs.godot-net == 'true'}}; then
GODOT_BIN=Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}_mono_linux_x86_64
fi
GODOT_PACKAGE=$GODOT_BIN.zip
wget --progress=bar:force:noscroll $DOWNLOAD_URL/$GODOT_PACKAGE -P ${{ inputs.install-path }}
unzip ${{ inputs.install-path }}/$GODOT_PACKAGE -d ${{ inputs.install-path }}
rm -rf ${{ inputs.install-path }}/$GODOT_PACKAGE
if ${{runner.OS == 'Linux'}}; then
echo "Run linux part"
if ${{inputs.godot-net == 'true'}}; then
mv ${{ inputs.install-path }}/$GODOT_BIN/* ${{ inputs.install-path }}
rmdir ${{ inputs.install-path }}/$GODOT_BIN/
fi
mv ${{ inputs.install-path }}/Godot_v* ${{ inputs.install-path }}/godot
chmod u+x ${{ inputs.install-path }}/godot
echo "${{ inputs.install-path }}/godot"
else
echo "Run windows part"
pwd
mv ${{ inputs.install-path }}/$GODOT_BIN ${{ inputs.install-path }}/godot.exe
chmod u+x ${{ inputs.install-path }}/godot.exe
${{ inputs.install-path }}/godot.exe --version
echo "${{ inputs.install-path }}/godot.exe"
fi
19 changes: 19 additions & 0 deletions .gdunit4_action/publish-test-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: publish-test-report
description: 'Publishes the GdUnit test results'

inputs:
report-name:
description: 'Name of the check run which will be created.'
required: true

runs:
using: composite
steps:

- name: 'Publish Test Results'
uses: dorny/[email protected]
with:
name: ${{ inputs.report-name }}
path: 'reports/**/results.xml'
reporter: java-junit
fail-on-error: 'false'
99 changes: 99 additions & 0 deletions .gdunit4_action/scripts/build_project.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env -S godot -s
@tool
extends SceneTree

const GDActionConsole = preload("res://.gdunit4_action/scripts/console.gd")


func _initialize():
set_auto_accept_quit(false)
var scanner := SourceScanner.new(self)
root.add_child(scanner)


# gdlint: disable=trailing-whitespace
class SourceScanner extends Node:

enum {
INIT,
STARTUP,
SCAN,
QUIT,
DONE
}

var _state = INIT
var _console := GDActionConsole.new()
var _elapsed_time := 0.0
var _plugin: EditorPlugin
var _fs: EditorFileSystem
var _scene: SceneTree


func _init(scene :SceneTree) -> void:
_scene = scene
_console.prints_color("""
========================================================================
Running project scan:""".dedent(),
Color.CORNFLOWER_BLUE
)
_state = INIT


func _process(delta :float) -> void:
_elapsed_time += delta
set_process(false)
await_inital_scan()
await scan_project()
set_process(true)


# !! don't use any await in this phase otherwise the editor will be instable !!
func await_inital_scan() -> void:
if _state == INIT:
_console.prints_color("Wait initial scanning ...", Color.DARK_GREEN)
_plugin = EditorPlugin.new()
_fs = _plugin.get_editor_interface().get_resource_filesystem()
_plugin.get_editor_interface().set_plugin_enabled("gdUnit4", false)
_state = STARTUP

if _state == STARTUP:
if _fs.is_scanning():
_console.progressBar(_fs.get_scanning_progress() * 100 as int)
# we wait 10s in addition to be on the save site the scanning is done
if _elapsed_time > 10.0:
_console.progressBar(100)
_console.new_line()
_console.prints_color("initial scanning ... done", Color.DARK_GREEN)
_state = SCAN


func scan_project() -> void:
if _state != SCAN:
return
_console.prints_color("Scan project: ", Color.SANDY_BROWN)
await get_tree().process_frame
_fs.scan_sources()
await get_tree().create_timer(5).timeout
_console.prints_color("Scan: ", Color.SANDY_BROWN)
_console.progressBar(0)
await get_tree().process_frame
_fs.scan()
while _fs.is_scanning():
await get_tree().process_frame
_console.progressBar(_fs.get_scanning_progress() * 100 as int)
await get_tree().create_timer(10).timeout
_console.progressBar(100)
_console.new_line()
_plugin.free()
_console.prints_color("""
Scan project done.
========================================================================""".dedent(),
Color.CORNFLOWER_BLUE
)
await get_tree().process_frame
await get_tree().physics_frame
queue_free()
# force quit editor
_state = DONE
_scene.quit(0)
146 changes: 146 additions & 0 deletions .gdunit4_action/scripts/console.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# prototype of console with CSI support
# https://notes.burke.libbey.me/ansi-escape-codes/
class_name GDActionConsole
extends RefCounted

const BOLD = 0x1
const ITALIC = 0x2
const UNDERLINE = 0x4

const __CSI_BOLD = ""
const __CSI_ITALIC = ""
const __CSI_UNDERLINE = ""

enum {
COLOR_TABLE,
COLOR_RGB
}

# Control Sequence Introducer
#var csi := PackedByteArray([0x1b]).get_string_from_ascii()
var _debug_show_color_codes := false
var _color_mode = COLOR_TABLE


func color(p_color :Color) -> GDActionConsole:
# using color table 16 - 231 a 6 x 6 x 6 RGB color cube (16 + R * 36 + G * 6 + B)
if _color_mode == COLOR_TABLE:
@warning_ignore("integer_division")
var c2 = 16 + (int(p_color.r8/42) * 36) + (int(p_color.g8/42) * 6) + int(p_color.b8/42)
if _debug_show_color_codes:
printraw("%6d" % [c2])
printraw("[38;5;%dm" % c2 )
else:
printraw("[38;2;%d;%d;%dm" % [p_color.r8, p_color.g8, p_color.b8] )
return self


func save_cursor() -> GDActionConsole:
printraw("")
return self


func restore_cursor() -> GDActionConsole:
printraw("")
return self


func end_color() -> GDActionConsole:
printraw("")
return self


func row_pos(row :int) -> GDActionConsole:
printraw("[%d;0H" % row )
return self


func scrollArea(from :int, to :int ) -> GDActionConsole:
printraw("[%d;%dr" % [from ,to])
return self


func progressBar(p_progress :int, p_color :Color = Color.POWDER_BLUE) -> GDActionConsole:
if p_progress < 0:
p_progress = 0
if p_progress > 100:
p_progress = 100
color(p_color)
printraw("[%-50s] %-3d%%\r" % ["".lpad(int(p_progress/2.0), "■").rpad(50, "-"), p_progress])
end_color()
return self


func printl(value :String) -> GDActionConsole:
printraw(value)
return self


func new_line() -> GDActionConsole:
prints()
return self


func reset() -> GDActionConsole:
return self


func bold(enable :bool) -> GDActionConsole:
if enable:
printraw(__CSI_BOLD)
return self


func italic(enable :bool) -> GDActionConsole:
if enable:
printraw(__CSI_ITALIC)
return self


func underline(enable :bool) -> GDActionConsole:
if enable:
printraw(__CSI_UNDERLINE)
return self


func prints_error(message :String) -> GDActionConsole:
return color(Color.CRIMSON).printl(message).end_color().new_line()


func prints_warning(message :String) -> GDActionConsole:
return color(Color.GOLDENROD).printl(message).end_color().new_line()


func prints_color(p_message :String, p_color :Color, p_flags := 0) -> GDActionConsole:
return print_color(p_message, p_color, p_flags).new_line()


func print_color(p_message :String, p_color :Color, p_flags := 0) -> GDActionConsole:
return color(p_color)\
.bold(p_flags&BOLD == BOLD)\
.italic(p_flags&ITALIC == ITALIC)\
.underline(p_flags&UNDERLINE == UNDERLINE)\
.printl(p_message)\
.end_color()


func print_color_table():
prints_color("Color Table 6x6x6", Color.ANTIQUE_WHITE)
_debug_show_color_codes = true
for green in range(0, 6):
for red in range(0, 6):
for blue in range(0, 6):
print_color("████████ ", Color8(red*42, green*42, blue*42))
new_line()
new_line()

prints_color("Color Table RGB", Color.ANTIQUE_WHITE)
_color_mode = COLOR_RGB
for green in range(0, 6):
for red in range(0, 6):
for blue in range(0, 6):
print_color("████████ ", Color8(red*42, green*42, blue*42))
new_line()
new_line()
_color_mode = COLOR_TABLE
_debug_show_color_codes = false
Loading

0 comments on commit 452fed9

Please sign in to comment.