Skip to content

Commit

Permalink
Merge pull request #27 from GsLogiMaker/fix/windows-only-failed-tests
Browse files Browse the repository at this point in the history
Fix Windows only failing unittests
  • Loading branch information
GsLogiMaker authored Nov 25, 2024
2 parents 0e4e992 + 52eec13 commit 16f36de
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 98 deletions.
134 changes: 75 additions & 59 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
branches: [ "dev" ]
workflow_dispatch:

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "build"
cancel-in-progress: false

jobs:

data:
Expand Down Expand Up @@ -80,28 +86,28 @@ jobs:

- name: 🏔️ Define library cache key in env Linux
shell: bash
run: echo "bin_key=lib.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('addons/glecs/bin') }}" >> $GITHUB_ENV
run: echo "bin_key=lib.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('bin') }}" >> $GITHUB_ENV

- name: 🏔️ Define cpp cache key Linux
shell: bash
run: echo "cpp_key=cpp.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('addons/glecs/cpp/') }}" >> $GITHUB_ENV
run: echo "cpp_key=cpp.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('cpp/') }}" >> $GITHUB_ENV

- name: 🏔️ Define includes cache key Linux
shell: bash
run: echo "include_key=include.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('addons/glecs/cpp/include') }}.${{ hashFiles('addons/glecs/cpp/SConstruct') }}" >> $GITHUB_ENV
run: echo "include_key=include.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('cpp/include') }}.${{ hashFiles('cpp/SConstruct') }}" >> $GITHUB_ENV

# --- Restore caches ---

- name: 💾 Restore cached cpp files
uses: actions/cache/[email protected]
with:
path: addons/glecs/cpp
path: cpp
key: ${{ env.cpp_key }}

- name: 💾 Restore cached include files
uses: actions/cache/[email protected]
with:
path: addons/glecs/cpp/include
path: cpp/include
key: ${{ env.include_key }}

# --- Platform specific setup ---
Expand All @@ -124,9 +130,9 @@ jobs:
- name: 🛠️ Build C++ code
run: |
scons --directory=addons/glecs/cpp platform=${{ matrix.platform }} arch=${{ matrix.arch }}
printf *** ls addons/glecs/bin/ ***
ls addons/glecs/bin
scons --directory=./cpp platform=${{ matrix.platform }} arch=${{ matrix.arch }}
printf *** ls bin/ ***
ls bin
#target=template_release

# --- Define bin key ---
Expand All @@ -135,7 +141,7 @@ jobs:
shell: bash
run: |
printf "*** Setting key in env***"
echo "bin_key=bin.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('addons/glecs/bin') }}" >> $GITHUB_ENV
echo "bin_key=bin.${{ matrix.platform }}_${{ matrix.arch }}.${{ hashFiles('bin') }}" >> $GITHUB_ENV
- name: 🏔️ Define library cache key in output
id: set_cache_key
shell: bash
Expand All @@ -148,19 +154,19 @@ jobs:
- name: 💾 Cache cpp source build files
uses: actions/cache/save@v4
with:
path: addons/glecs/cpp
path: cpp
key: ${{ env.cpp_key }}

- name: 💾 Cache cpp include build files
uses: actions/cache/save@v4
with:
path: addons/glecs/cpp/include
path: cpp/include
key: ${{ env.include_key }}

- name: 💾 Cache bin
uses: actions/cache/save@v4.0.2
uses: actions/cache/save@v4
with:
path: ./addons/glecs/bin/${{ matrix.glecs_lib }}
path: ./bin/${{ matrix.glecs_lib }}
key: ${{ env.bin_key }}
enableCrossOsArchive: true

Expand All @@ -174,31 +180,49 @@ jobs:
bin_key: ${{ needs.compile_glecs.outputs.bin_key_linux_x86_64 }}
lib_debug: ${{ needs.data.outputs.lib_debug_linux_x86_64 }}
lib_release: ${{ needs.data.outputs.lib_release_linux_x86_64 }}
- os: macos-13
bin_key: ${{ needs.compile_glecs.outputs.bin_key_macos_x86_64 }}
lib_debug: ${{ needs.data.outputs.lib_debug_macos_x86_64 }}
lib_release: ${{ needs.data.outputs.lib_release_macos_x86_64 }}
- os: windows-latest
bin_key: ${{ needs.compile_glecs.outputs.bin_key_windows_x86_64 }}
lib_debug: ${{ needs.data.outputs.lib_debug_windows_x86_64 }}
lib_release: ${{ needs.data.outputs.lib_release_windows_x86_64 }}
# - os: macos-13
# bin_key: ${{ needs.compile_glecs.outputs.bin_key_macos_x86_64 }}
# lib_debug: ${{ needs.data.outputs.lib_debug_macos_x86_64 }}
# lib_release: ${{ needs.data.outputs.lib_release_macos_x86_64 }}
runs-on: ${{ matrix.os }}
steps:
- name: 🐙 Setup git environment
- name: 🐙 Setup git environment of plugin
uses: actions/checkout@v4

- name: 💾 Load cached library as debug
uses: actions/cache/restore@v4.0.2
uses: actions/cache/restore@v4
with:
path: ./addons/glecs/bin/${{ matrix.lib_debug }}
path: ./bin/${{ matrix.lib_debug }}
key: ${{ matrix.bin_key }}
enableCrossOsArchive: true
- name: 💾 Load cached library as release
uses: actions/cache/[email protected]
fail-on-cache-miss: true
# - name: 💾 Load cached library as release
# uses: actions/cache/restore@v4
# with:
# path: ./bin/${{ matrix.lib_release }}
# key: ${{ matrix.bin_key }}
# enableCrossOsArchive: true
# fail-on-cache-miss: true

- name: Copy plugin to temp folder
shell: bash
run: |
mkdir ../addons
cp -R ../glecs_godot_plugin/ ../addons/glecs/
- name: 🐙 Setup git environment of plugin
uses: actions/checkout@v4
with:
path: ./addons/glecs/bin/${{ matrix.lib_release }}
key: ${{ matrix.bin_key }}
enableCrossOsArchive: true
ref: "unittests-project"

- name: Add glecs plugin from temp to unittests project
shell: bash
run: |
cp -R ../addons/glecs addons/glecs
- name: 🤖 Setup Godot binary
uses: lihop/setup-godot@v2
Expand All @@ -211,10 +235,16 @@ jobs:
shell: bash
run: godot --headless --import

- name: Print Folder Tree
uses: jaywcjlove/github-action-folder-tree@main
with:
exclude: "addons/glecs/|addons/gut/|cpp|.godot|.git"
path: ./

- name: 📝 Run Glecs tests
id: run-godot-tests
shell: bash
run: godot --script unittests.gd --headless --verbose
run: godot --headless --verbose

- name: 📄 Debug print when tests error
shell: bash
Expand All @@ -228,14 +258,14 @@ jobs:
echo ""
echo "***"
echo "LS glecs/bin/"
echo "LS bin/"
echo "***"
ls addons/glecs/bin
ls bin
update_nightly:
if: ${{ github.event_name == 'push' || github.event_name == 'closed' }}
needs: ["compile_glecs", "run_test_suite"]
runs-on: windows-latest
if: ${{ (github.event_name == 'push' || github.event_name == 'closed') && github.base_ref == 'dev'}}
needs: ["data", "compile_glecs", "run_test_suite"]
runs-on: ubuntu-latest
steps:
- name: 🐙 Setup git environment
uses: actions/checkout@v4
Expand All @@ -244,46 +274,32 @@ jobs:
persist-credentials: false

- name: 🐧 Load compiled library, Linux x86_64
uses: actions/cache/restore@v4.0.2
uses: actions/cache/restore@v4
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/x86_64-unknown-linux-gnu/release/libglecs.so
path: ./bin/${{ needs.data.outputs.lib_debug_linux_x86_64 }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.bin_key_linux_x86_64 }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true

- name: 🍎 Load compiled library, Mac x86_64
uses: actions/cache/[email protected]
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/x86_64-apple-darwin/release/libglecs.dylib
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.bin_key_macos_x86_64 }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true

- name: 🪟 Load compiled library, Windows x86_64
uses: actions/cache/restore@v4.0.2
uses: actions/cache/restore@v4
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ./addons/glecs/bin/x86_64-pc-windows-gnu/release/glecs.dll
path: ./bin/${{ needs.data.outputs.lib_debug_windows_x86_64 }}
# An explicit key for restoring and saving the cache
key: ${{ needs.compile_glecs.outputs.bin_key_windows_x86_64 }}
# An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
enableCrossOsArchive: true

- name: 🐍 Setup Python
uses: actions/[email protected]
with:
python-version: 3.11.2
cache: pip

# - name: 🚣‍♂️ Convert dev plugin to nightly format
# run: |
# cd addons/glecs
# pip install regex
# python _build_for_nightly.py
# - name: 🍎 Load compiled library, Mac x86_64
# uses: actions/cache/restore@v4
# with:
# # A list of files, directories, and wildcard patterns to cache and restore
# path: ./bin/${{ needs.data.outputs.lib_debug_macos_x86_64 }}
# # An explicit key for restoring and saving the cache
# key: ${{ needs.compile_glecs.outputs.bin_key_macos_x86_64 }}
# # An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms
# enableCrossOsArchive: true

- name: 🌙 Clone nightly branch
run: |
Expand All @@ -294,7 +310,7 @@ jobs:
- name: 🖨️ Copy dev branch plugin to nightly
run: |
cp -r -force ./addons/glecs/* ../nightly/
cp --recursive --force ./* ../nightly/
- name: ➕ Add and commit to nightly
id: add-and-commit
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# Visual Studio
*/.vs

# Compiled binaries
bin/

Expand All @@ -8,3 +11,6 @@ cpp/.sconsign.dblite
cpp/compile_commands.json
cpp/src/doc_data.gen.h
*.os
# Windows
*.obj
*.obj.import
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
path = cpp/include/godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 4.3
[submodule "cpp/include/--force"]
path = cpp/include/--force
url = https://github.com/godotengine/godot-cpp
branch = 4.3
2 changes: 1 addition & 1 deletion cpp/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main():
env.Tool('compilation_db')
cdb = env.CompilationDatabase()
x = env.Alias('cdb', cdb)
if "cdb" in COMMAND_LINE_TARGETS:
if "cdb" in COMMAND_LINE_TARGETS and "-fno-gnu-unique" in env._dict["CXXFLAGS"]:
env._dict["CXXFLAGS"].remove("-fno-gnu-unique")

platform:str = env["platform"]
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ void GFWorld::init_gd_type_ptr(
switch (vari_type) {
case(Variant::Type::NIL): if (ecs_has(_raw, type, EcsStruct)) {init_component_ptr(ptr, type, Variant());}; break;
case(Variant::Type::BOOL): *static_cast<bool*>(ptr) = false; break;
case(Variant::Type::INT): *static_cast<int*>(ptr) = 0; break;
case(Variant::Type::INT): *static_cast<int64_t*>(ptr) = 0; break;
case(Variant::Type::FLOAT): *static_cast<float*>(ptr) = 0.0; break;
case(Variant::Type::STRING): new(ptr) String(); break;
case(Variant::Type::VECTOR2): new(ptr) Vector2(); break;
Expand Down
2 changes: 1 addition & 1 deletion unittests/scripts/a_component.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

extends GFComponent

const CONST:= preload("res://components/b_module.gd")
const CONST:= preload("./b_module.gd")
4 changes: 2 additions & 2 deletions unittests/scripts/a_module.gd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

extends GFModule

const DictionaryC:= preload("res://components/dictionary.gd")
const DictionaryC:= preload("./dictionary.gd")

class SubEntity extends GFRegisterableEntity: pass

const b_module:= preload("res://components/b_module.gd")
const b_module:= preload("./b_module.gd")
8 changes: 1 addition & 7 deletions unittests/test_events.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func test_on_add_event_with_objects():
.set_name("WithInts")
assert_eq(data.i, 1)
assert_eq(e.get_component(Textures).a, null)
assert_eq(e.get_component(Textures).b, null)

e.delete()

Expand All @@ -90,10 +89,9 @@ func test_on_add_event_with_objects():
data.i = 0
var e2:= GFEntity.spawn(world) \
.set_name("WithTextures")
e2.add_component(Textures, [load("res://icon.png"), load("res://icon.svg")])
e2.add_component(Textures, [load("res://icon.png")])
assert_eq(data.i, 1)
assert_eq(e2.get_component(Textures).a, load("res://icon.png"))
assert_eq(e2.get_component(Textures).b, load("res://icon.svg"))

e2.delete()

Expand All @@ -115,12 +113,8 @@ class Ints extends GFComponent:
class Textures extends GFComponent:
func _build(b:GFComponentBuilder) -> void:
b.add_member("a", TYPE_OBJECT)
b.add_member("b", TYPE_OBJECT)
var a:Texture2D:
get: return getm(&"a")
set(v): setm(&"a", v)
var b:Texture2D:
get: return getm(&"b")
set(v): setm(&"b", v)

#endregion
12 changes: 8 additions & 4 deletions unittests/test_registration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@tool
extends GutTest

const AModule = preload("./scripts/a_module.gd")
const AComponent = preload("./scripts/a_component.gd")
const AEntity = preload("./scripts/a_entity.gd")

var world:GFWorld

func before_all():
Expand All @@ -14,7 +18,7 @@ func after_all():

func test_auto_register_script():
GFEntity.spawn(world) \
.add_component(load("res://components/a_component.gd"))
.add_component(AComponent)

assert_ne(
world.lookup(
Expand All @@ -24,7 +28,7 @@ func test_auto_register_script():
)

func test_register_script_module():
world.register_script(load("res://components/a_module.gd"))
world.register_script(AModule)

assert_ne(
world.lookup(
Expand All @@ -46,7 +50,7 @@ func test_register_script_module():
)

func test_register_script_component_script():
world.register_script(load("res://components/a_component.gd"))
world.register_script(AComponent)

assert_ne(
world.lookup(
Expand All @@ -56,7 +60,7 @@ func test_register_script_component_script():
)

func test_register_script_entity_script():
world.register_script(load("res://components/a_entity.gd"))
world.register_script(AEntity)

assert_ne(
world.lookup(
Expand Down
Loading

0 comments on commit 16f36de

Please sign in to comment.