godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.22k stars 20.23k forks source link

Exports from CLI return exit code 0 when failed to build project. #94957

Open franciscod opened 1 month ago

franciscod commented 1 month ago

Tested versions

System information

Tested on Linux and macOS

Issue description

Godot returns exit code 0 when the build fails.

Errors when exporting a project should be communicated via the process exit code, so that build systems can pick up the failure instead of continuing.

A workaround is to grep for error strings (either known strings that can false-negative when a new error happens, or broad generic strings that can false-positive with minor errors, from Godot or the project itself).

Related issues:

Steps to reproduce

Create a new project, add C# script with a syntax error, and export to Linux (any other platform should behave the same way) with:

$ godot --headless --export-release Linux output

The exit code (you can check it with echo $?) should not be 0 since there was a failure during the export. It is 0.

(see run_export.sh on the linked repo or zip below)

Minimal reproduction project (MRP)

https://github.com/franciscod/godot-exit godot-exit.zip

Calinou commented 1 month ago

A workaround is to grep for error strings (either known strings that can false-negative when a new error happens, or broad generic strings that can false-positive with minor errors, from Godot or the project itself).

The workaround is described here: https://github.com/godotengine/godot/issues/83042#issuecomment-1949445714

franciscod commented 1 month ago

Yes. However with that workaround any logged message containing the string ERROR: would also consider the Godot build as failed. I've seen other "benign" error messages that maybe shouldn't stop the build process (and not make Godot exit with != 0).

Another workaround (for C# projects) is to do a dotnet build or similar, and only call the godot export if that succeeds. This is limited to C# compile errors and might not detect other build errors (such as errors on the gradle phase of an android build).

franciscod commented 1 month ago