MikeSchulze / gdUnit4

A Godot Unit Test Framework. Support for GDScript and C# unit testing
MIT License
490 stars 28 forks source link

GD-487: Encountering an error when loading Godot project on CI after last update #487

Closed Minimata closed 1 month ago

Minimata commented 1 month ago

The used GdUnit4 version

4.3.0 (Pre Release/Master branch)

The used Godot version

v4.2.2

Operating System

Ubuntu container from the nektos/act runner handled by Gitea

Describe the bug

Hi, I opened Godot today after a 3-days hiatus to see that GdUnit suggested an update (with a new logo, yay!) I installed the update and restarted Godot, no issues. I immediately pushed the update on my repo where the Gitea Action CI took over and this is where trouble begins.

The step that triggers the issue is as follows:

      - name: Import resources and build solution
        run: |
          godot --headless --build-solutions --quit --import --path $PWD

So it simply launches godot to import all the necessary stuff before actually running the tests.

With the new version of GdUnit, this step now triggers the following error:

Loading GdUnit4 Plugin success
GdUnit4: Test server successfully started checked port: 31002
ERROR: Parent node is busy adding/removing children, `remove_child()` can't be called at this time. Consider using `remove_child.call_deferred(child)` instead.
   at: remove_child (scene/main/node.cpp:1449)
ERROR: Parent node is busy adding/removing children, `remove_child()` can't be called at this time. Consider using `remove_child.call_deferred(child)` instead.
   at: remove_child (scene/main/node.cpp:1449)
ERROR: Condition "data.parent" is true.
   at: ~Node (scene/main/node.cpp:[35](https://git.game-dev.space/minimata/Godot-CICDTests/actions/runs/72/jobs/1#jobstep-4-35)83)
Unload GdUnit4 Plugin success
Segmentation fault (core dumped)

My CI pipeline therefore stops right there and returns an error.

I have a few SCRIPT ERRORs beforehand regarding some missing png file and other UI stuff, I think it doesn't impact the actual issue so I won't add the whole logs to keep it as concise as possible but know that this is not the complete log. Also,--verbose doesn't add anything to these errors.

I tried to simply disable the plugin which actually solves this error but then another error appears when I try to export my game for Windows with the following command:

      - name: Windows Build
        run: |
          mkdir -v -p build/windows
          godot --headless --verbose --build-solutions --import --export-release "Windows Desktop" build/windows/Windows.exe

This now triggers the following error (again not the whole logs but the useful information should live in here):

WARNING: Project export for preset "Windows Desktop" completed with warnings.
     at: _fs_changed (editor/editor_node.cpp:999)
reimport: end
ERROR: Attempt to disconnect a nonexistent connection from '<RefCounted#-9223370350828391021>'. Signal: 'gdunit_event', callable: 'Control(GdUnitConsole.gd)::_on_gdunit_event'.
   at: _disconnect (core/object/object.cpp:1420)
ERROR: Attempt to disconnect a nonexistent connection from '<RefCounted#-9223370350828391021>'. Signal: 'gdunit_message', callable: 'Control(GdUnitConsole.gd)::_on_gdunit_message'.
   at: _disconnect (core/object/object.cpp:1416)
ERROR: Attempt to disconnect a nonexistent connection from '<RefCounted#-9223370350828391021>'. Signal: 'gdunit_client_connected', callable: 'Control(GdUnitConsole.gd)::_on_gdunit_client_connected'.
   at: _disconnect (core/object/object.cpp:1420)
ERROR: Attempt to disconnect a nonexistent connection from '<RefCounted#-9223370350828391021>'. Signal: 'gdunit_client_disconnected', callable: 'Control(GdUnitConsole.gd)::_on_gdunit_client_disconnected'.
   at: _disconnect (core/object/object.cpp:1420)
EditorSettings: Save OK!
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.2.stable.official (15073afe3856abd2aa1622492fe50026c7d63dc1)
Dumping the backtrace. 
ERROR: FATAL: Index p_index = 1 is out of bounds (size() = 0).
   at: get (./core/templates/cowdata.h:158)
Illegal instruction (core dumped)

So I'm quite stuck because with plugin enabled I can't import my project correctly and with the plugin disabled I can't export my project at all.

My workaround as of now would be to manually install a previous version of GdUnit by going into the commit history of this repo (I haven't found a more straightforward way to install v4.2.5 or older but I might have missed it, I'm quite new to Godot). When I do this next week and when I find the most recent working version, I'll make sure to update this issue with the commit SHA or something. I hope this would help.

Thanks a lot for the plugin and for your help!

Steps to Reproduce

  1. Be on Godot 4.2.2 with Mono support
  2. Install GdUnit4 through the AssetLib tab
  3. Restart Godot
  4. Accept and install the latest update
  5. Commit and push the changed to a Gitea repository with actions enabled.
  6. Actions take over by importing and building the project
  7. Running the tests
  8. Exporting a release

Issue happens at step 7 or 8 depending on plugin enabled or disabled respectively.

Below is the simplified yaml code for the gitea action:

jobs:
  ExportWindows:
    runs-on: ubuntu-latest
    container:
      image: barichello/godot-ci:4.2.2
    steps:
      - name: Cloning the repo
        uses: actions/checkout@v4
        with:
          lfs: true
      - name: Import resources and build solution
        run: |
          godot --headless --build-solutions --quit --import --path $PWD
      - name: Run tests
        run: |
          godot --headless --path "$PWD" -s -d addons/gdUnit4/bin/GdUnitCmdTool.gd -a ./test -rd ./test/reports --ignoreHeadlessMode
      - name: Windows Build
        run: |
          mkdir -v -p build/windows
          godot --headless --verbose --build-solutions --import --export-release "Windows Desktop" build/windows/Windows.exe

Minimal reproduction project

Difficult to provide a project given that it works fine on my machine but fails on the CI container.

MikeSchulze commented 1 month ago

It's already fixed in master, I will provide a new release today https://github.com/MikeSchulze/gdUnit4/issues/483

MikeSchulze commented 1 month ago

@Minimata version v4.3.1 is out, you can update

Minimata commented 1 month ago

You're the best, thank you so much. Will update ASAP.

Minimata commented 1 month ago

I just tried it but had the same issue. I'll completely uninstall and reinstall the plugin tomorrow with a clear head to see if it persists. If it does, I will fallback to manually downloading the repo's commit history until I find the most recent working version and share it with you.

MikeSchulze commented 1 month ago

@Minimata are you familiar with the gdunit4 action? https://github.com/MikeSchulze/gdUnit4-action

Minimata commented 1 month ago

I am a bit, but it doesn't fit in my process. In the action, there are steps to install godot, install the plugin, etc. which doesn't fit into my pipeline at all. In my actions I'm using a container that already has Godot installed and the plugin is simply versioned with the rest of the source code. This makes my actions run a lot faster which is important to me since these steps will be ran on every commit pushed to the repo.

I tried just adapting the steps of the action where the actual tests are ran but it didn't work either, can't really remember why, something about the reports I believe. I really didn't get more into it because it used to work well by simply running the GdUnitCmdTool.gd so I focused on that.

Minimata commented 1 month ago

Ok so I completely uninstalled the plugin, reinstalled it from the AssetLib and enabled it (restarting Godot between every step), I'm on version 4.3.1 according to the plugin settings image And I still have the same error on project import.

I went dichotomy into the commit history and found out the last working commit is the following one:

0db9e5bd2cc2438e466749237f6081ebd44ee243 Bump MikeSchulze/gdUnit4-action from 1.0.8 to 1.1.1

Which means the "remove_child" error is probably triggered by something somewhere in this commit:

0736ca3036dfab3ea0a3c0bb036e16c9cedd6cce GD-322: Complete revision of the GdUnit inspector and addition of test discovery

It is interesting to note that the last working commit for the "remove_child" error is not the same as the last working commit for the "disconnect a non-existant connection" error.

The last working commit for the "disconnect" error (and my whole CI) is this one:

caa7eadd5ec643fece0e21f6c1938694d64717ed Bump dorny/test-reporter from 1.9.0 to 1.9.1

which means the issue for this one lives in the following commit:

049424f59114ca82ff3f845a855aa94375b3c7d0 GD-443: Fix errors when dock undock the gdunit inspector

I know close to nothing on godot-specific dev and plugins so I don't really know where to look in these two commits pinpoint the actual issue but I will try.

MikeSchulze commented 1 month ago

In my actions I'm using a container that already has Godot installed and the plugin is simply versioned with the rest of the source code. This makes my actions run a lot faster which is important to me since these steps will be ran on every commit pushed to the repo.

Just for your info the gdunit4 action uses a cache for the Godot installation, so it is very performant ;) But feel free to use your customized action with the cmd tool ;)

The version v4.3.1 should include the fix of remove_child on plugin.gd

    if is_instance_valid(_server_node):
        Engine.get_main_loop().root.remove_child.call_deferred(_server_node)

And the fix for the signal disconnect too in ScriptEditorContextMenuHandler and EditorFileSystemContextMenuHandler by do is_connected before try to disconnect

Can you provide me the full steps to reproduce

And for rebuilding the Godot cache you should add a timeout to prevent to exit to early.

- name: Import resources and build solution
        run: |
          godot --headless --build-solutions --quit-after 2000 --import --path $PWD
Minimata commented 1 month ago

Alright, thanks for the info, I'll try to make your action work if the current issue is unsolveable.

Regarding the timeout, the --import godot argument is actually meant to do just that: prevent early exits but in a more straightforward way than the hardcoded timeout. Maybe it's buggy or doesn't take addons into account though, it was planned for 4.3 and cherry picked into 4.2.2 I believe, I'm going to try with a regular --quit-after.

Also, I'll try to setup a minimal reproduction example and come back to your right after.

Thanks for your help!

EDIT: quit-after 2000 yields the same result as --quit --import. I'll set up a minimal repro project.