diff --git a/.github/actions/download-godot/action.yml b/.github/actions/download-godot/action.yml index 9377d2e..615b49e 100644 --- a/.github/actions/download-godot/action.yml +++ b/.github/actions/download-godot/action.yml @@ -14,34 +14,58 @@ runs: - name: Linux File Pattern if: runner.os == 'Linux' shell: bash - run: echo "FILE=linux(\.x86_64|_headless\.64)" >> $GITHUB_ENV + run: | + echo "ASSET=linux(\.x86_64|_headless\.64)" >> $GITHUB_ENV + echo "FILE=linux(\.x86_64|_headless\.64)" >> $GITHUB_ENV - name: MacOS File Pattern if: runner.os == 'macOS' shell: bash - run: echo "FILE=(macos|osx)\.universal" >> $GITHUB_ENV + run: | + echo "ASSET=(macos|osx)\.universal" >> $GITHUB_ENV + echo "FILE=(macos|osx)\.universal" >> $GITHUB_ENV - name: Windows File Pattern if: runner.os == 'Windows' shell: bash - run: echo "FILE=win64.exe" >> $GITHUB_ENV + run: | + echo "ASSET=win64.exe" >> $GITHUB_ENV + echo "FILE=win64_console.exe" >> $GITHUB_ENV + + - name: Cache Godot + id: cache-godot + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/Godot*.x86_64 + ${{ github.workspace }}/Godot.app + ${{ github.workspace }}/Godot*_win64*.exe + templates/* + key: godot-${{ runner.os }}-${{ inputs.version }} - name: Download Godot + if: steps.cache-godot.outputs.cache-hit != 'true' uses: dsaltares/fetch-gh-release-asset@master with: repo: godotengine/godot version: tags/${{ inputs.version }} regex: true target: './' # Defaults to regex prepended to filename - file: ${{ env.FILE }} + file: ${{ inputs.version }}_(${{ env.ASSET }}|export_templates.tpz) - - name: Unzip Godot + - name: Extract Godot + if: steps.cache-godot.outputs.cache-hit != 'true' shell: bash run: | - zip_file=$( ls | grep -E '${{ env.FILE }}' | grep -v '_mono_' ) - unzip "$zip_file" - ls | grep -E '${{ env.FILE }}.*\.zip' | xargs rm - echo "EXECUTABLE=$( ls | grep -E '${{ env.FILE }}' )" >> $GITHUB_ENV + zip_editor=$( ls | grep -E '${{ env.ASSET }}' ) + unzip "$zip_editor" + zip_templates=$( ls | grep export_templates.tpz ) + unzip "$zip_templates" + rm "$zip_editor" "$zip_templates" + + - name: Generic Executable + shell: bash + run: echo "EXECUTABLE=$( ls | grep -E '${{ env.FILE }}' )" >> $GITHUB_ENV - name: MacOS Executable if: runner.os == 'macOS' @@ -52,4 +76,3 @@ runs: id: set-output shell: bash run: echo "executable=${{ env.EXECUTABLE }}" >> $GITHUB_OUTPUT - diff --git a/.github/actions/export-tests/action.yml b/.github/actions/export-tests/action.yml new file mode 100644 index 0000000..96f5dc9 --- /dev/null +++ b/.github/actions/export-tests/action.yml @@ -0,0 +1,50 @@ +name: Export Tests +description: Export and run test project +inputs: + executable: + description: The Godot executable in CWD + required: true + godot-major: + description: The major version of Godot being targeted used to configure export command + required: true +runs: + using: composite + steps: + - name: Linux Export Details + if: runner.os == 'Linux' + shell: bash + run: echo "EXTENSION=x86_64" >> $GITHUB_ENV + + - name: MacOS Export Details + if: runner.os == 'macOS' + shell: bash + run: echo "EXTENSION=app" >> $GITHUB_ENV + + - name: Windows Export Details + if: runner.os == 'Windows' + shell: bash + run: echo "EXTENSION=exe" >> $GITHUB_ENV + + - name: Generic Export Command + shell: bash + run: echo "EXPORT_CMD=--export-release ${{ runner.os }} ../../WasmTest.${{ env.EXTENSION }}" >> $GITHUB_ENV + + - name: Godot 3.x Export Command + if: inputs.godot-major == 3 + shell: bash + run: echo "EXPORT_CMD=--export ${{ runner.os }}" >> $GITHUB_ENV + + - name: Export + shell: bash + run: | + ./${{ inputs.executable }} --headless --no-window --path examples/wasm-test ${{ env.EXPORT_CMD }} + echo "EXECUTABLE=WasmTest.${{ env.EXTENSION }}" >> $GITHUB_ENV + + - name: MacOS Executable + if: runner.os == 'macOS' + shell: bash + run: echo "EXECUTABLE=WasmTest.app/Contents/MacOS/WasmTest" >> $GITHUB_ENV + + - name: Run Tests + shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} + run: ./${{ env.EXECUTABLE }} --headless --no-window -- --key=val diff --git a/.github/actions/godot-cpp/action.yml b/.github/actions/godot-cpp/action.yml index 03c15c3..59997b8 100644 --- a/.github/actions/godot-cpp/action.yml +++ b/.github/actions/godot-cpp/action.yml @@ -29,7 +29,7 @@ runs: ${{ github.workspace }}/godot-cpp/bin ${{ github.workspace }}/godot-cpp/include ${{ github.workspace }}/godot-cpp/gen - key: ${{ inputs.platform }}-${{ steps.submodule-hash.outputs.hash }} + key: godotcpp-${{ inputs.platform }}-${{ steps.submodule-hash.outputs.hash }} - name: Compile Godot Library if: steps.cache-godot-cpp.outputs.cache-hit != 'true' diff --git a/.github/actions/install-deps/action.yml b/.github/actions/install-deps/action.yml index 19decbd..f378e48 100644 --- a/.github/actions/install-deps/action.yml +++ b/.github/actions/install-deps/action.yml @@ -25,4 +25,3 @@ runs: if: runner.os == 'Windows' shell: bash run: python -m pip install pywin32 - diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml index a57cdcb..d60da96 100644 --- a/.github/actions/run-tests/action.yml +++ b/.github/actions/run-tests/action.yml @@ -8,5 +8,5 @@ runs: using: composite steps: - name: Run Tests - shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }} + shell: bash run: ./${{ inputs.executable }} --headless --no-window --debug --path examples/wasm-test -- --key=val diff --git a/.github/actions/scons-build/action.yml b/.github/actions/scons-build/action.yml index 7c136cf..e11bdbc 100644 --- a/.github/actions/scons-build/action.yml +++ b/.github/actions/scons-build/action.yml @@ -27,15 +27,15 @@ runs: shell: bash run: echo "name=${{ inputs.cache-prefix }}${{ inputs.platform }}-${{ inputs.godot-major }}-${{ github.workflow }}" >> $GITHUB_OUTPUT - - name: Load Cache + - name: Cache Scons uses: actions/cache@v3 with: path: ${{ inputs.scons-cache }} - key: ${{ steps.cache-name.outputs.name }}-${{ github.ref }}-${{ github.sha }} + key: scons-${{ steps.cache-name.outputs.name }}-${{ github.ref }}-${{ github.sha }} restore-keys: | - ${{ steps.cache-name.outputs.name }}-${{ github.ref }}-${{ github.sha }} - ${{ steps.cache-name.outputs.name }}-${{ github.ref }} - ${{ steps.cache-name.outputs.name }} + scons-${{ steps.cache-name.outputs.name }}-${{ github.ref }}-${{ github.sha }} + scons-${{ steps.cache-name.outputs.name }}-${{ github.ref }} + scons-${{ steps.cache-name.outputs.name }} - name: MSVC Developer Command Prompt if: runner.os == 'Windows' diff --git a/.github/workflows/addon.yml b/.github/workflows/addon.yml index e48b209..fc20eda 100644 --- a/.github/workflows/addon.yml +++ b/.github/workflows/addon.yml @@ -54,9 +54,9 @@ jobs: path: ${{ github.workspace }}/${{ env.LIBRARY_PATH }}/${{ matrix.platform }} if-no-files-found: error - test-addon: + test-editor: needs: build-addon - name: Test Addon + name: Test Addon Editor strategy: fail-fast: false matrix: @@ -69,6 +69,7 @@ jobs: - platform: windows os: windows-latest runs-on: ${{ matrix.os }} + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 @@ -89,3 +90,41 @@ jobs: uses: ./.github/actions/run-tests with: executable: ${{ steps.download-godot.outputs.executable }} + + test-export: + needs: build-addon + name: Test Addon Export + strategy: + fail-fast: false + matrix: + platform: [linux, macos, windows] + include: + - platform: linux + os: ubuntu-latest + - platform: macos + os: macos-11 + - platform: windows + os: windows-latest + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download Godot + id: download-godot + uses: ./.github/actions/download-godot + with: + version: ${{ env.GODOT_REF }} + + - name: Download Addon + uses: actions/download-artifact@v3 + with: + name: ${{ matrix.platform }} + path: ${{ github.workspace }}/${{ env.LIBRARY_PATH }}/${{ matrix.platform }} + + - name: Export Tests + uses: ./.github/actions/export-tests + with: + executable: ${{ steps.download-godot.outputs.executable }} + godot-major: ${{ env.GODOT_MAJOR }} diff --git a/.gitignore b/.gitignore index 0835ab1..46bc54a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ wasmer/ wasmtime/ addons.zip +templates/ *.os *.obj *.pdb diff --git a/examples/wasm-test/.gitignore b/examples/wasm-test/.gitignore index 13947ee..4aaf465 100644 --- a/examples/wasm-test/.gitignore +++ b/examples/wasm-test/.gitignore @@ -1,6 +1,7 @@ .DS_Store .import/ .godot/** +WasmTest.app *.import !.godot/extension_list.cfg !.godot/global_script_class_cache.cfg diff --git a/examples/wasm-test/export_presets.cfg b/examples/wasm-test/export_presets.cfg new file mode 100644 index 0000000..a6a1813 --- /dev/null +++ b/examples/wasm-test/export_presets.cfg @@ -0,0 +1,204 @@ +[preset.0] + +name="macOS" +platform="macOS" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="*.wasm" +exclude_filter="" +export_path="../../WasmTest.app" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.0.options] + +export/distribution_type=1 +binary_format/architecture="universal" +custom_template/debug="../../templates/macos.zip" +custom_template/release="../../templates/macos.zip" +debug/export_console_wrapper=1 +application/icon="" +application/icon_interpolation=4 +application/bundle_identifier="com.ashtonmeuser.wasm-test" +application/signature="" +application/app_category="Games" +application/short_version="1.0" +application/version="1.0" +application/copyright="" +application/copyright_localized={} +application/min_macos_version="10.12" +display/high_res=true +xcode/platform_build="14C18" +xcode/sdk_version="13.1" +xcode/sdk_build="22C55" +xcode/sdk_name="macosx13.1" +xcode/xcode_version="1420" +xcode/xcode_build="14C18" +codesign/codesign=3 +codesign/installer_identity="" +codesign/apple_team_id="" +codesign/identity="" +codesign/entitlements/custom_file="" +codesign/entitlements/allow_jit_code_execution=false +codesign/entitlements/allow_unsigned_executable_memory=false +codesign/entitlements/allow_dyld_environment_variables=false +codesign/entitlements/disable_library_validation=true +codesign/entitlements/audio_input=false +codesign/entitlements/camera=false +codesign/entitlements/location=false +codesign/entitlements/address_book=false +codesign/entitlements/calendars=false +codesign/entitlements/photos_library=false +codesign/entitlements/apple_events=false +codesign/entitlements/debugging=false +codesign/entitlements/app_sandbox/enabled=false +codesign/entitlements/app_sandbox/network_server=false +codesign/entitlements/app_sandbox/network_client=false +codesign/entitlements/app_sandbox/device_usb=false +codesign/entitlements/app_sandbox/device_bluetooth=false +codesign/entitlements/app_sandbox/files_downloads=0 +codesign/entitlements/app_sandbox/files_pictures=0 +codesign/entitlements/app_sandbox/files_music=0 +codesign/entitlements/app_sandbox/files_movies=0 +codesign/entitlements/app_sandbox/helper_executables=[] +codesign/custom_options=PackedStringArray() +notarization/notarization=0 +privacy/microphone_usage_description="" +privacy/microphone_usage_description_localized={} +privacy/camera_usage_description="" +privacy/camera_usage_description_localized={} +privacy/location_usage_description="" +privacy/location_usage_description_localized={} +privacy/address_book_usage_description="" +privacy/address_book_usage_description_localized={} +privacy/calendar_usage_description="" +privacy/calendar_usage_description_localized={} +privacy/photos_library_usage_description="" +privacy/photos_library_usage_description_localized={} +privacy/desktop_folder_usage_description="" +privacy/desktop_folder_usage_description_localized={} +privacy/documents_folder_usage_description="" +privacy/documents_folder_usage_description_localized={} +privacy/downloads_folder_usage_description="" +privacy/downloads_folder_usage_description_localized={} +privacy/network_volumes_usage_description="" +privacy/network_volumes_usage_description_localized={} +privacy/removable_volumes_usage_description="" +privacy/removable_volumes_usage_description_localized={} +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" + +[preset.1] + +name="Windows" +platform="Windows Desktop" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="*.wasm" +exclude_filter="" +export_path="../../WasmTest.exe" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.1.options] + +custom_template/debug="../../templates/windows_debug_x86_64.exe" +custom_template/release="../../templates/windows_release_x86_64.exe" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +binary_format/architecture="x86_64" +codesign/enable=false +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PackedStringArray() +application/modify_resources=false +application/icon="" +application/console_wrapper_icon="" +application/icon_interpolation=4 +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}' +$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}' +$trigger = New-ScheduledTaskTrigger -Once -At 00:00 +$settings = New-ScheduledTaskSettingsSet +$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings +Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true +Start-ScheduledTask -TaskName godot_remote_debug +while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 } +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue" +ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue +Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue +Remove-Item -Recurse -Force '{temp_dir}'" + +[preset.2] + +name="Linux" +platform="Linux/X11" +runnable=true +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="*.wasm" +exclude_filter="" +export_path="../../WasmTest.x86_64" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false + +[preset.2.options] + +custom_template/debug="../../templates/linux_debug.x86_64" +custom_template/release="../../templates/linux_release.x86_64" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/bptc=true +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/examples/wasm-test/project.godot b/examples/wasm-test/project.godot index f1137fb..8c943cc 100644 --- a/examples/wasm-test/project.godot +++ b/examples/wasm-test/project.godot @@ -10,7 +10,7 @@ config_version=5 [application] -config/name="Wasm Test" +config/name="WasmTest" run/main_scene="res://Main.tscn" config/features=PackedStringArray("4.1", "GL Compatibility") @@ -29,6 +29,10 @@ window/size/viewport_height=512 run/main_run_args="--keepalive=yes -- --key=val" +[filesystem] + +import/blender/enabled=false + [rendering] renderer/rendering_method="gl_compatibility" diff --git a/examples/wasm-test/utils/TestSuite.gd b/examples/wasm-test/utils/TestSuite.gd index d784351..97f5073 100644 --- a/examples/wasm-test/utils/TestSuite.gd +++ b/examples/wasm-test/utils/TestSuite.gd @@ -25,6 +25,9 @@ func run(f): # Test condition utils func expect_log(s: String): + if !OS.has_feature("editor"): # Log file is not live when exported + print("Export build skipping expect log: %s" % s) + return _log_file.seek(_log_file.get_position()) # HACK: Not sure why this works var line = _log_file.get_line() var regex: RegEx = RegEx.new() diff --git a/examples/wasm-test/utils/Utils.gd b/examples/wasm-test/utils/Utils.gd index 4a05545..85ed242 100644 --- a/examples/wasm-test/utils/Utils.gd +++ b/examples/wasm-test/utils/Utils.gd @@ -6,7 +6,8 @@ static func comparable(o): static func make_regex(pattern: String) -> RegEx: var regex = RegEx.new() - assert(regex.compile(pattern) == OK, "Invalid regex pattern: %s" % pattern) + var error = regex.compile(pattern) + assert(error == OK, "Invalid regex pattern: %s" % pattern) return regex static func file_length(f: FileAccess) -> int: