diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 4aca02c..b8e6101 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -8,7 +8,11 @@ on: # Global Settings env: - SCONSFLAGS: strict_checks=yes debug_symbols=no module_text_server_fb_enabled=yes + SCONSFLAGS: >- + strict_checks=yes + debug_symbols=no + module_text_server_fb_enabled=yes + swappy=yes # We only build template release - most developers will use a desktop device for editor jobs: @@ -24,14 +28,20 @@ jobs: cache-name: android-template-release-v8 target: template_release tests: false - sconsflags: arch=arm64 swappy=yes deprecated=no ndk_platform=android-24 generate_apk=yes + sconsflags: >- + arch=arm64 + deprecated=no + ndk_platform=android-24 + generate_apk=yes cache-limit: 1 - name: Template (target=template_release, arch=arm64, qjs_ng) cache-name: android-template-release-qjs-ng target: template_release tests: false - sconsflags: arch=arm64 swappy=yes use_quickjs_ng=yes + sconsflags: >- + arch=arm64 + use_quickjs_ng=yes cache-limit: 1 steps: diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 3bd805e..138f797 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -8,7 +8,10 @@ on: # Global Settings env: - SCONSFLAGS: debug_symbols=no module_text_server_fb_enabled=yes + SCONSFLAGS: >- + strict_checks=yes + debug_symbols=no + module_text_server_fb_enabled=yes jobs: ios-template: diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index 2f2a6b1..73e714a 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -5,10 +5,15 @@ on: version: required: true type: string + tests: + type: boolean + default: true # Global Settings env: - SCONSFLAGS: module_text_server_fb_enabled=yes strict_checks=yes + SCONSFLAGS: >- + module_text_server_fb_enabled=yes + strict_checks=yes TSAN_OPTIONS: suppressions=misc/error_suppressions/tsan.txt UBSAN_OPTIONS: suppressions=misc/error_suppressions/ubsan.txt @@ -37,7 +42,6 @@ jobs: cache-name: linux-template-debug-v8 sconsflags: debug_symbols=no target: template_debug - bin: ./bin/godot.linuxbsd.template_debug.x86_64.v8 cache-limit: 1 - name: Editor (target=editor, qjs_ng) @@ -114,6 +118,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} platform: linuxbsd target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} @@ -132,3 +137,12 @@ jobs: uses: ./.github/actions/upload-artifact with: name: ${{ matrix.cache-name }} + + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.linuxbsd.editor.x86_64 + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors \ No newline at end of file diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index f7a8c74..79719e9 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -5,10 +5,15 @@ on: version: required: true type: string + tests: + type: boolean + default: true # Global Settings env: - SCONSFLAGS: module_text_server_fb_enabled=yes strict_checks=yes + SCONSFLAGS: >- + module_text_server_fb_enabled=yes + strict_checks=yes jobs: build-macos: @@ -103,6 +108,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} arch=arm64 platform: macos target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} - name: Save Godot build cache @@ -128,6 +134,15 @@ jobs: with: name: ${{ matrix.cache-name }} + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.macos.editor.universal + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors + build-macos-apps: needs: - build-macos diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml index 3e9462e..64be155 100644 --- a/.github/workflows/runner.yml +++ b/.github/workflows/runner.yml @@ -41,7 +41,7 @@ jobs: mkdir -p "${{github.workspace}}/modules/GodotJS/" mv "/tmp/$V8/v8" "${{github.workspace}}/modules/GodotJS/v8" ls "${{github.workspace}}/modules/GodotJS/v8" - + - name: ⬆️ Upload artifact uses: actions/upload-artifact@v4 @@ -70,6 +70,7 @@ jobs: needs: environment with: version: ${{ needs.environment.outputs.version }} + tests: ${{ github.event_name != 'release' }} macos-build: name: 🍎 macOS @@ -77,6 +78,7 @@ jobs: needs: environment with: version: ${{ needs.environment.outputs.version }} + tests: ${{ github.event_name != 'release' }} windows-build: name: 🏁 Windows @@ -84,6 +86,7 @@ jobs: needs: environment with: version: ${{ needs.environment.outputs.version }} + tests: ${{ github.event_name != 'release' }} web-build: name: 🌐 Web diff --git a/.github/workflows/web_builds.yml b/.github/workflows/web_builds.yml index dfa07de..f7f0fae 100644 --- a/.github/workflows/web_builds.yml +++ b/.github/workflows/web_builds.yml @@ -8,7 +8,14 @@ on: # Global Settings env: - SCONSFLAGS: debug_symbols=no use_closure_compiler=yes strict_checks=yes deprecated=no lto=none use_assertions=no use_safe_heap=yes + SCONSFLAGS: >- + debug_symbols=no + use_closure_compiler=yes + strict_checks=yes + deprecated=no + lto=none + use_assertions=no + use_safe_heap=yes EM_VERSION: 3.1.64 jobs: diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index b1e8f6e..02c599e 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -5,11 +5,18 @@ on: version: required: true type: string + tests: + type: boolean + default: true # Global Settings # SCONS_CACHE for windows must be set in the build environment env: - SCONSFLAGS: module_text_server_fb_enabled=yes d3d12=yes strict_checks=yes "angle_libs=${{ github.workspace }}/" + SCONSFLAGS: >- + module_text_server_fb_enabled=yes + d3d12=yes + strict_checks=yes + "angle_libs=${{ github.workspace }}/" SCONS_CACHE_MSVC_CONFIG: true jobs: @@ -26,7 +33,11 @@ jobs: cache-name: windows-editor-v8 target: editor # Skip debug symbols, they're way too big with MSVC. - sconsflags: debug_symbols=no vsproj=yes vsproj_gen_only=no windows_subsystem=console + sconsflags: >- + debug_symbols=no + vsproj=yes + vsproj_gen_only=no + windows_subsystem=console cache-limit: 2 - name: Template (target=template_debug, v8) @@ -45,7 +56,12 @@ jobs: cache-name: windows-editor-qjs-ng target: editor # Skip debug symbols, they're way too big with MSVC. - sconsflags: debug_symbols=no vsproj=yes vsproj_gen_only=no windows_subsystem=console use_quickjs_ng=yes + sconsflags: >- + debug_symbols=no + vsproj=yes + vsproj_gen_only=no + windows_subsystem=console + use_quickjs_ng=yes cache-limit: 2 engine: qjs_ng @@ -114,6 +130,7 @@ jobs: sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }} platform: windows target: ${{ matrix.target }} + tests: ${{ inputs.tests && matrix.target == 'editor' }} scons-cache-limit: ${{ matrix.cache-limit }} - name: Save Godot build cache @@ -130,3 +147,12 @@ jobs: uses: ./.github/actions/upload-artifact with: name: ${{ matrix.cache-name }} + + - name: Unit tests + if: ${{ inputs.tests && matrix.target == 'editor' }} + env: + BIN: ./bin/godot.windows.editor.x86_64.exe + run: | + ${{ env.BIN }} --version + ${{ env.BIN }} --help + ${{ env.BIN }} --headless --test --test-case="[jsb]*" --force-colors \ No newline at end of file diff --git a/tests/jsb_test_helpers.h b/tests/jsb_test_helpers.h index 203a4f9..f93a003 100644 --- a/tests/jsb_test_helpers.h +++ b/tests/jsb_test_helpers.h @@ -4,6 +4,9 @@ #include "../weaver/jsb_script_language.h" #include "tests/test_macros.h" +#include +#include + #define JSB_TESTS_EXECUTION_SCOPE(env) const jsb::tests::V8ContextScope JSB_CONCAT(unique_, __COUNTER__)(env) namespace jsb::tests @@ -110,7 +113,9 @@ namespace jsb::tests CHECK(FileAccess::exists("project.godot")); // MESSAGE("init GodotJSScriptLanguage on thread ", Thread::get_caller_id()); - install_npm(); + install_npm(); + // Wait for 1 second until ./node_modules has been created + std::this_thread::sleep_for(std::chrono::seconds(1)); compile_scripts(); ignore_directories(); GodotJSScriptLanguage::get_singleton()->init(); @@ -143,6 +148,8 @@ namespace jsb::tests const String exe_path = OS::get_singleton()->get_name() != "Windows" ? "node" : "node.exe"; const Error err = OS::get_singleton()->create_process(exe_path, args); CHECK(err == OK); + // Wait for 1 second until ./.godot has been created + std::this_thread::sleep_for(std::chrono::seconds(1)); CHECK(FileAccess::exists("./.godot/GodotJS/test_01.js")); } diff --git a/tests/test_jsb_any_runtime.h b/tests/test_jsb_any_runtime.h index ce596f6..73ea607 100644 --- a/tests/test_jsb_any_runtime.h +++ b/tests/test_jsb_any_runtime.h @@ -418,7 +418,7 @@ console.assert(!gd.is_instance_valid(node)); Error err; GodotJSScriptLanguage::get_singleton()->eval_source(R"--( let gd = require("godot"); -let mod = require("test_01"); +let mod = require(".godot/GodotJS/test_01"); console.assert(typeof mod === "object"); console.assert(mod.call_me() == 123); console.assert(typeof mod.default === "function");