Skip to content

Commit

Permalink
wild swing at per-microgame PR builds
Browse files Browse the repository at this point in the history
  • Loading branch information
iznaut committed Sep 25, 2023
1 parent c6c1eb4 commit aceb67d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ jobs:
const path = require('path');
const script = require(path.resolve('.github/workflows/update-credits.js'));
await script(github, context)
- name: Setup Godot
uses: lihop/setup-godot@v2
- name: Override config to launch specific microgame
shell: bash
run: godot -s .github/workflows/get_mg_scene_from_dir.gd --no-window "pixelart"
- name: export with Godot Engine
uses: firebelley/[email protected]
with:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/get_mg_scene_from_dir.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extends SceneTree


func _init():
var mg_dir : String = OS.get_cmdline_args()[2]
var def : MicrogameDefinition = Utility.find_microgame_definitions_in_dir(
"res://microgames/" + mg_dir
)[0]
var mg_scene_path : String

for filepath in Utility.list_all_files(def.resource_path.get_base_dir(), "tscn"):
var scene_node = load(filepath).instance()
var is_microgame_scene : bool = scene_node.get_class() == "Microgame"
scene_node.free()

if is_microgame_scene:
mg_scene_path = filepath
break

var override_filepath := "override.cfg"

ProjectSettings.set_setting("application/run/main_scene", mg_scene_path)
ProjectSettings.save_custom(override_filepath)

quit()
4 changes: 4 additions & 0 deletions core/microgame/microgame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var is_timer_running : bool = false
var is_success : bool = false


func get_class() -> String:
return "Microgame"


func _ready() -> void:
# set default success state
is_success = win_by_default
Expand Down
7 changes: 5 additions & 2 deletions core/utility.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ static func find_microgame_definitions_in_dir(directory_to_search : String = "re
return microgame_defs


static func get_definition_from_microgame_scene(scene_path) -> MicrogameDefinition:
return find_microgame_definitions_in_dir(scene_path.get_base_dir())[0]
static func get_definition_from_microgame_scene(scene_path : String) -> MicrogameDefinition:
var defs = find_microgame_definitions_in_dir(
scene_path.get_base_dir()
)
return defs[0] if defs.size() > 0 else null


static func list_all_files(path: String, extension: String = "") -> Array:
Expand Down

0 comments on commit aceb67d

Please sign in to comment.