From ff95b60a56b2fcc40233d0777c3374d04d463523 Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Sat, 30 Mar 2024 15:24:32 +1300 Subject: [PATCH] feat(web): re-enable web exports --- .github/workflows/main.yml | 41 +- .gitignore | 2 +- Justfile | 5 + addons/godot_xterm/native/docker-compose.yml | 5 +- .../native/godot-xterm.gdextension | 2 + docs/index.md | 2 +- docs/introduction.md | 8 +- docs/setup/building_from_source.md | 4 +- examples/menu/menu.gd | 12 +- examples/web_console/web_console.gd | 20 +- examples/web_console/web_console.tscn | 6 +- export_presets.cfg | 22 +- .../baseline/smoke_test.cy-menu.png | Bin 25746 -> 0 bytes test/html5/cypress.config.js | 10 - test/html5/cypress/e2e/smoke_test.cy.js | 23 - test/html5/cypress/support/commands.js | 2 - test/html5/cypress/support/e2e.js | 1 - test/html5/package-lock.json | 4764 ----------------- test/html5/package.json | 11 - test/html5/shell.nix | 14 - test/{html5 => web}/.gdignore | 0 test/{html5 => web}/.gitignore | 0 test/web/package-lock.json | 788 +++ test/web/package.json | 9 + test/web/shell.nix | 11 + test/web/smoke_test.js | 65 + 26 files changed, 940 insertions(+), 4887 deletions(-) delete mode 100755 test/html5/cypress-visual-screenshots/baseline/smoke_test.cy-menu.png delete mode 100644 test/html5/cypress.config.js delete mode 100644 test/html5/cypress/e2e/smoke_test.cy.js delete mode 100644 test/html5/cypress/support/commands.js delete mode 100644 test/html5/cypress/support/e2e.js delete mode 100644 test/html5/package-lock.json delete mode 100644 test/html5/package.json delete mode 100644 test/html5/shell.nix rename test/{html5 => web}/.gdignore (100%) rename test/{html5 => web}/.gitignore (100%) create mode 100644 test/web/package-lock.json create mode 100644 test/web/package.json create mode 100644 test/web/shell.nix create mode 100644 test/web/smoke_test.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98986a7..d1effca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -173,16 +173,20 @@ jobs: addons/godot_xterm/native/bin/*.xcframework addons/godot_xterm/native/bin/*.dll - html5-export: - name: "HTML5 Export" - needs: [check-archive, check-pre-commit] + web-export: + name: "Web Export" runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - id: install-chrome + uses: browser-actions/setup-chrome@v1 + with: + chrome-version: 121 - name: Setup Godot uses: lihop/setup-godot@v2 with: version: "4.2.1-stable" + export-templates: true - name: Import assets run: godot --editor --headless --quit-after 100 || true - name: Wait for build @@ -196,41 +200,28 @@ jobs: with: path: addons/godot_xterm/native/bin merge-multiple: true - # Some remaining steps temporarily disabled. - - name: Export HTML5 - if: false + - name: Export for web uses: nick-fields/retry@v3 with: - command: godot --no-window --export HTML5 + command: godot --no-window --export-release Web retry_on: error timeout_minutes: 5 max_attempts: 6 - name: NPM cache uses: c-hive/gha-npm-cache@v1 with: - directory: test/html5 - - name: Smoke test HTML5 export - if: false + directory: test/web + - name: Smoke test Web export shell: bash - working-directory: test/html5 + working-directory: test/web run: | + export GODOT_XTERM_CHROME_PATH=${{ steps.install-chrome.outputs.chrome-path }} npm ci - npx serve ../../docs/demo -p 3000 & - npx cypress run - - name: Upload cypress artifacts (on failure) - uses: actions/upload-artifact@v4 - if: false - #if: ${{ failure() }} - with: - name: cypress-artifacts - path: |- - test/html5/cypress/screenshots - test/html5/cypress/videos + npm test - name: Upload export - if: false uses: actions/upload-artifact@v4 with: - name: html5-demo + name: web-demo path: docs/demo test: @@ -316,7 +307,7 @@ jobs: merge-artifacts: name: Merge Artifacts runs-on: ubuntu-latest - needs: [build-linux, build-other-platforms, test, html5-export] + needs: [build-linux, build-other-platforms, test, web-export] strategy: matrix: target: [release, debug] diff --git a/.gitignore b/.gitignore index b5dd769..2cb4eb2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ export.cfg export/ export_presets.cfg -# Dummy HTML5 export presets file for continuous integration +# Dummy Web export presets file for continuous integration !.github/dist/export_presets.cfg # Mono-specific ignores diff --git a/Justfile b/Justfile index d0ccc79..d21252f 100644 --- a/Justfile +++ b/Justfile @@ -8,6 +8,11 @@ godot := `echo "${GODOT:-godot} --rendering-driver ${RENDERING_DRIVER:-vulkan}"` build: cd addons/godot_xterm/native && scons debug_symbols=yes +build-javascript: + UID_GID="$(id -u):$(id -g)" docker-compose -f addons/godot_xterm/native/docker-compose.yml run --rm javascript + +build-all: build build-javascript + install: {{godot}} --headless -s plug.gd install diff --git a/addons/godot_xterm/native/docker-compose.yml b/addons/godot_xterm/native/docker-compose.yml index 81f0b1a..f57175c 100644 --- a/addons/godot_xterm/native/docker-compose.yml +++ b/addons/godot_xterm/native/docker-compose.yml @@ -11,10 +11,7 @@ services: - /bin/bash - -c - | - cd /src/thirdparty/godot-cpp - scons platform=javascript target=$${TARGET:-debug} -j$$(nproc) - cd /src - scons platform=javascript target=$${TARGET:-debug} -j$$(nproc) + scons platform=web target=$${TARGET:-template_debug} -j$$(nproc) libuv-linux: user: ${UID_GID} build: diff --git a/addons/godot_xterm/native/godot-xterm.gdextension b/addons/godot_xterm/native/godot-xterm.gdextension index 6809c91..ee8affc 100644 --- a/addons/godot_xterm/native/godot-xterm.gdextension +++ b/addons/godot_xterm/native/godot-xterm.gdextension @@ -9,6 +9,8 @@ linux.debug.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.t linux.release.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_release.x86_64.so" linux.debug.x86_32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_debug.x86_32.so" linux.release.x86_32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.linux.template_release.x86_32.so" +web.debug.wasm32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.web.template_debug.wasm32.wasm" +web.release.wasm32 = "res://addons/godot_xterm/native/bin/libgodot-xterm.web.template_release.wasm32.wasm" macos.debug = "res://addons/godot_xterm/native/bin/libgodot-xterm.macos.template_debug.framework" macos.release = "res://addons/godot_xterm/native/bin/libgodot-xterm.macos.template_release.framework" windows.debug.x86_64 = "res://addons/godot_xterm/native/bin/libgodot-xterm.windows.template_debug.x86_64.dll" diff --git a/docs/index.md b/docs/index.md index 06041b9..7c18661 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ GDNative terminal for Godot. Built using [libtsm](https://www.freedesktop.org/wiki/Software/libtsm/), [libuv](https://github.com/libuv/libuv), and [node-pty](https://github.com/microsoft/node-pty). -Primarily developed and tested on Linux, it also supports macOS with partial support for Windows and HTML5. See the [Features section](introduction.md#features) for more detail. +Primarily developed and tested on Linux, it also supports macOS with partial support for Windows and Web. See the [Features section](introduction.md#features) for more detail.