godot-xterm/.github/workflows/main.yml
Leroy Hopson fae6317eb7
Use default export templates for HTML5
Changes Emscripten SDK version to match that used to compile the default export
templates used by Godot 3.5 (in this case 3.1.14 as can be seen here:
https://github.com/godotengine/build-containers/blob/3.5/Dockerfile.javascript).

This means we no longer need to compile custom export templates when
exporting HTML5 for Godot 3.5. Exports from other Godot versions may
requiring compiling the GDNative library with a different version of the
Emscripten SDK.

- Changes renderer from GLES3 -> GLES2 and reduces MSAA level to better
  support HTML5 export.
- Updates GitHub Action to export HTML5 and upload as a build artifact.
- Adds Cypress test to smoke test HTML5 export.
2024-03-29 19:36:44 +13:00

309 lines
11 KiB
YAML

name: 'Build and Test'
on:
push:
schedule: # Build and test daily.
- cron: 0 11 * * *
env:
# Caches should be automatically invalidated when versions change,
# but invalidation can be forced by incrementing these numbers.
EMSCRIPTEN_CACHE_VERSION: 1
EXPORT_TEMPLATE_CACHE_VERSION: 1
GODOT_CACHE_VERSION: 1
jobs:
build_docker:
name: 'Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [ release, debug ]
bits: [ 64, 32 ]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache submodules
uses: ./.github/actions/cache-submodules
id: cache-submodules
with:
platform: linux
target: ${{ matrix.target }}
bits: ${{ matrix.bits }}
- name: Pull docker images
run: docker-compose pull
working-directory: addons/godot_xterm/native
- name: Cache docker image layers
uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
- name: Build godot-cpp bindings
if: steps.cache-submodules.outputs.cache-hit != 'true'
working-directory: addons/godot_xterm/native
run: |
docker-compose build godot-cpp-linux
UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} godot-cpp-linux
- name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true'
working-directory: addons/godot_xterm/native
run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} libuv-linux
- name: Build libgodot-xterm
working-directory: addons/godot_xterm/native
run: UID_GID="$(id -u):$(id -g)" docker-compose run -e TARGET=${{ matrix.target }} -e BITS=${{ matrix.bits }} libgodot-xterm-linux
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: libgodot-xterm-${{ matrix.target }}
path: |
addons/godot_xterm/native/bin/*.so
build_native:
name: 'Build Native'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ javascript, osx, windows ]
target: [ release, debug ]
bits: [ 64, 32 ]
include:
- platform: javascript
os: ubuntu-latest
- platform: osx
os: macos-latest
- platform: windows
os: windows-latest
exclude:
- platform: javascript
bits: 64 # Currently only wasm32 is supported.
- platform: osx
bits: 32 # Only 64-bit supported on macOS.
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache submodules
uses: ./.github/actions/cache-submodules
id: cache-submodules
with:
platform: ${{ matrix.platform }}
target: ${{ matrix.target }}
bits: ${{ matrix.bits }}
- name: Cache emscripten
if: ${{ matrix.platform == 'javascript' }}
uses: actions/cache@v2
env:
cache-name: cache-emscripten
with:
path: addons/godot_xterm/native/.emcache
key: emsdk-cache-${{ matrix.target }}-v${{ env.EMSCRIPTEN_CACHE_VERSION }}
- name: Install javascript build dependencies
if: ${{ matrix.platform == 'javascript' }}
uses: mymindstorm/setup-emsdk@v11
with:
version: 3.1.14
actions-cache-folder: emsdk-cache-${{ matrix.target }}
- name: Install additional javascript build dependencies
if: ${{ matrix.platform == 'javascript' }}
run: sudo apt-get update && sudo apt-get install -y scons gcc-multilib g++-multilib
- name: Install additional macos build dependencies
if: ${{ matrix.os == 'macos-latest' }}
run: brew install scons
- name: Install additional windows build dependencies
if: ${{ matrix.os == 'windows-latest' }}
run: python -m pip install scons
- name: Setup MSVC command prompt
uses: ilammy/msvc-dev-cmd@v1.9.0
if: ${{ matrix.os == 'windows-latest' }}
with:
arch: win${{ matrix.bits }}
- name: Build godot-cpp bindings
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: |
cd addons/godot_xterm/native/thirdparty/godot-cpp
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} generate_bindings=yes -j2
- name: Setup cmake
if: steps.cache-submodules.outputs.cache-hit != 'true'
uses: jwlawson/actions-setup-cmake@v1.9
with:
cmake-version: '3.23.2'
use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-latest' }}
- name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true'
shell: bash
env:
TARGET: ${{ matrix.target }}
BITS: ${{ matrix.bits }}
OS: ${{ matrix.os }}
run: |
cd addons/godot_xterm/native/thirdparty/libuv
args="-DCMAKE_BUILD_TYPE=$TARGET -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"
if [ "$TARGET" == "release" ]; then
args="$args -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL"
else
args="$args -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL"
fi
if [ "$BITS" -eq 32 -a "$OS" == "windows-latest" ]; then
cmake -G "Visual Studio 17 2022" -A Win32 -S $(pwd) -B "build" $args
else
mkdir build || true
cd build
if [ "$BITS" -eq 32 ]; then args="$args -DCMAKE_SYSTEM_PROCESSOR=i686 -DCMAKE_C_FLAGS=-m32"; fi
cmake .. $args
cd ..
fi
cmake --build build --config $TARGET
- name: Build libgodot-xterm
run: |
cd addons/godot_xterm/native
scons platform=${{ matrix.platform }} target=${{ matrix.target }} bits=${{ matrix.bits }} -j2
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: libgodot-xterm-${{ matrix.target }}
path: |
addons/godot_xterm/native/bin/*.wasm
addons/godot_xterm/native/bin/*.dylib
addons/godot_xterm/native/bin/*.dll
html5_export:
name: 'HTML5 Export'
needs: [ build_docker, build_native ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Godot
uses: lihop/setup-godot@v2
with:
export-templates: true
- name: Install binary build artifacts
uses: actions/download-artifact@v2
with:
name: libgodot-xterm-release
path: addons/godot_xterm/native/bin
- name: Import assets
shell: bash
# The GodotXterm plugin will be disabled the first time we run the editor as resources that it depends
# (e.g. icons) will not have been imported yet so the plugin will fail to load. Without the plugin
# enabled resources imported by GodotXterm import plugins (e.g. .cast) will not be imported. Therefore,
# we need to re-enable the plugin by checking out project.godot and running the editor again.
run: godot --editor .github/import_assets.tscn && git checkout project.godot && godot --editor .github/import_assets.tscn
- name: Export HTML5
run: godot --no-window --export HTML5
- name: NPM cache
uses: c-hive/gha-npm-cache@v1
with:
directory: test/html5
- name: Smoke test HTML5 export
shell: bash
working-directory: test/html5
run: |
npm ci
npx serve ../../docs/demo -p 3000 &
npx cypress run
- name: Upload cypress artifacts (on failure)
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: cypress-artifacts
path: |-
test/html5/cypress/screenshots
test/html5/cypress/videos
- name: Upload export
uses: actions/upload-artifact@v2
with:
name: html5-demo
path: docs/demo
test:
name: 'Test'
needs: [ build_docker, build_native ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
bits: [ 64, 32 ]
godot_version: [ 'v3.4.5-stable', 'v3.5-stable' ]
exclude:
- os: macos-latest
bits: 32
steps:
- uses: actions/checkout@v2
- name: Setup Godot
uses: lihop/setup-godot@v2
with:
version: ${{ matrix.godot_version }}
bits: ${{ matrix.bits }}
- name: Install binary build artifacts
uses: actions/download-artifact@v2
with:
name: libgodot-xterm-release
path: addons/godot_xterm/native/bin
- name: Run tests
uses: nick-fields/retry@v2
with:
shell: bash
command: godot --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.ci.json
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: Run unix tests
if: ${{ matrix.os != 'windows-latest' }}
uses: nick-fields/retry@v2
with:
command: godot --no-window -s addons/gut/gut_cmdln.gd -gconfig=test/.gutconfig.unix.json
retry_on: error
timeout_minutes: 5
max_attempts: 6
# Git archive should only include addons/godot_xterm directory.
check-archive:
name: 'Check Archive'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Create git archive
run: git archive -o archive.zip HEAD
- name: Extract archive
run: mkdir -p /tmp/unzipped && unzip archive.zip -d /tmp/unzipped
- name: Check that archive only contains addons directory
run: |
shopt -s nullglob dotglob
ls -lR /tmp/unzipped
files=(/tmp/unzipped/*)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in archive (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons" ]; then
echo "Expected directory (addons) not found."
exit 1
fi
files=(/tmp/unzipped/addons)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in addons directory (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons/godot_xterm" ]; then
echo "Expected directory (addons/godot_xterm) not found."
exit 1
fi
check-code-format:
name: 'Check Code Format'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: GDFormat Check
run: |
python -m pip install -r requirements.txt
gdformat -c .