godot-xterm/.github/workflows/main.yml

370 lines
13 KiB
YAML
Raw Normal View History

name: "Build and Test"
on:
push:
2021-12-17 09:45:06 +01:00
schedule: # Build and test daily.
- cron: 0 11 * * *
jobs:
2024-02-13 09:23:22 +01:00
build-linux:
name: Build (linux, ${{ matrix.arch }}, ${{ matrix.target }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch: [x86_64, x86_32]
target: [release, debug]
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache submodules
uses: ./.github/actions/cache-submodules
id: cache-submodules
with:
platform: linux
arch: ${{ matrix.arch }}
2024-02-13 03:22:16 +01:00
target: ${{ matrix.target }}
- name: Pull docker images
run: docker-compose pull
working-directory: addons/godot_xterm/native
- name: Cache docker image layers
uses: jpribyl/action-docker-layer-caching@v0.1.1
continue-on-error: true
- name: Ensure scons cache exists
run: mkdir -p ${{github.workspace}}/.scons-cache
- 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 ARCH=${{ matrix.arch }} -v ${{github.workspace}}/.scons-cache:/scons-cache 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 ARCH=${{ matrix.arch }} -v ${{github.workspace}}/.scons-cache:/scons-cache libgodot-xterm-linux
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: libgodot-xterm-linux-${{ matrix.arch }}-${{ matrix.target }}
path: addons/godot_xterm/native/bin/*.so
2024-02-13 09:23:22 +01:00
build-other-platforms:
name: Build (${{ matrix.platform }}, ${{ matrix.arch }}, ${{ matrix.target}})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
2024-02-13 03:22:16 +01:00
platform: [web, macos, windows]
target: [release, debug]
2024-02-25 00:24:59 +01:00
arch: [wasm32, universal, x86_64, x86_32]
include:
2024-02-13 03:22:16 +01:00
- platform: web
os: ubuntu-22.04
2024-02-13 03:22:16 +01:00
- platform: macos
os: macos-12
- platform: windows
os: windows-2022
2024-02-25 00:24:59 +01:00
exclude:
2024-02-13 03:22:16 +01:00
- platform: web
2024-02-25 00:24:59 +01:00
arch: x86_64
- platform: web
arch: x86_32
- platform: web
arch: universal
- platform: macos
2024-02-13 03:22:16 +01:00
arch: wasm32
- platform: macos
arch: x86_64
2024-02-25 00:24:59 +01:00
- platform: macos
2024-02-13 03:22:16 +01:00
arch: x86_32
2024-02-25 00:24:59 +01:00
- platform: windows
arch: wasm32
- platform: windows
arch: universal
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache submodules
uses: ./.github/actions/cache-submodules
id: cache-submodules
with:
platform: ${{ matrix.platform }}
target: ${{ matrix.target }}
2024-02-13 03:22:16 +01:00
arch: ${{ matrix.arch }}
2021-06-07 08:53:43 +02:00
- name: Cache emscripten
2024-02-13 03:22:16 +01:00
if: ${{ matrix.platform == 'web' }}
uses: actions/cache@v4
2021-06-07 08:53:43 +02:00
env:
cache-name: cache-emscripten
with:
path: addons/godot_xterm/native/.emcache
key: emsdk-cache-${{ matrix.target }}-${{ hashFiles('**/*.c*', '**/*.h*') }}
restore-keys: |
emsdk-cache-${{ matrix.target }}-
2024-02-13 03:22:16 +01:00
- name: Install web build dependencies
if: ${{ matrix.platform == 'web' }}
uses: mymindstorm/setup-emsdk@v11
2021-06-07 08:53:43 +02:00
with:
version: 3.1.14
2021-06-07 08:53:43 +02:00
actions-cache-folder: emsdk-cache-${{ matrix.target }}
2024-02-13 03:22:16 +01:00
- name: Install additional web build dependencies
if: ${{ matrix.platform == 'web' }}
run: sudo apt-get update && sudo apt-get install -y scons gcc-multilib g++-multilib
- name: Install additional macos build dependencies
if: ${{ matrix.platform == 'macos' }}
run: brew install scons
- name: Install additional windows build dependencies
if: ${{ matrix.platform == 'windows' }}
run: python -m pip install scons
- name: Setup MSVC command prompt
uses: ilammy/msvc-dev-cmd@v1
if: ${{ matrix.platform == 'windows' }}
2021-07-03 10:15:01 +02:00
with:
2024-02-25 00:24:59 +01:00
arch: win${{ matrix.arch == 'x86_64' && '64' || '32' }}
- name: Setup cmake
if: steps.cache-submodules.outputs.cache-hit != 'true'
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: "3.23.2"
2024-02-25 00:24:59 +01:00
use-32bit: ${{ matrix.arch == 'x86_32' && matrix.platform == 'windows' }}
- name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true'
shell: bash
env:
PLATFORM: ${{ matrix.platform }}
TARGET: ${{ matrix.target }}
2024-02-25 00:24:59 +01:00
BITS: ${{ matrix.arch == 'x86_64' && 64 || 32 }}
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 "$PLATFORM" == "windows" ]; 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
2024-02-13 03:22:16 +01:00
- name: Ensure scons cache exists
run: mkdir -p ${{github.workspace}}/.scons-cache
shell: bash
- name: Build libgodot-xterm
2024-02-13 03:22:16 +01:00
env:
SCONS_CACHE: ${{github.workspace}}/.scons-cache
run: |
cd addons/godot_xterm/native
scons platform=${{ matrix.platform }} target=template_${{ matrix.target }} arch=${{ matrix.arch }} debug_symbols=${{ matrix.platform != 'windows' && matrix.target == 'debug' && 'yes' || 'no' }} -j2
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: libgodot-xterm-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}
path: |
addons/godot_xterm/native/bin/*.so
2021-06-07 08:53:43 +02:00
addons/godot_xterm/native/bin/*.wasm
addons/godot_xterm/native/bin/*.framework
2024-02-24 07:47:12 +01:00
addons/godot_xterm/native/bin/spawn-helper
addons/godot_xterm/native/bin/*.xcframework
addons/godot_xterm/native/bin/*.dll
2024-02-13 09:23:22 +01:00
html5-export:
name: "HTML5 Export"
needs: [check-archive, check-pre-commit]
runs-on: ubuntu-22.04
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
- name: Setup Godot
2024-02-12 23:14:52 +01:00
uses: lihop/setup-godot@v2
with:
version: "4.2.1-stable"
2024-02-24 03:48:48 +01:00
- name: Import assets
run: godot --editor --headless --quit-after 100 || true
- name: Wait for build
uses: fountainhead/action-wait-for-check@v1.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Build (web, wasm32, release)
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Install binary build artifacts
uses: actions/download-artifact@v4
with:
path: addons/godot_xterm/native/bin
2024-02-24 04:24:54 +01:00
merge-multiple: true
# Some remaining steps temporarily disabled.
- name: Export HTML5
if: false
uses: nick-fields/retry@v3
with:
command: godot --no-window --export HTML5
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
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@v4
if: false
#if: ${{ failure() }}
with:
name: cypress-artifacts
path: |-
test/html5/cypress/screenshots
test/html5/cypress/videos
- name: Upload export
if: false
uses: actions/upload-artifact@v4
with:
name: html5-demo
path: docs/demo
test:
name: Test (${{ matrix.platform }}, ${{ matrix.arch }}, ${{ matrix.godot-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
2024-02-23 22:22:29 +01:00
platform: [linux, macos, windows]
2024-02-25 00:24:59 +01:00
arch: [x86_64, x86_32, universal]
godot-version: ["v4.2-stable", "v4.2.1-stable"]
2024-02-18 08:26:32 +01:00
exclude:
2024-02-25 00:24:59 +01:00
- platform: linux
arch: universal
2024-02-23 22:22:29 +01:00
- platform: macos
2024-02-25 00:24:59 +01:00
arch: x86_64
- platform: macos
arch: x86_32
- platform: windows
arch: universal
2024-02-13 03:22:16 +01:00
include:
- platform: linux
os: ubuntu-22.04
2024-02-23 22:22:29 +01:00
- platform: macos
os: macos-12
2024-02-13 03:22:16 +01:00
- platform: windows
os: windows-2022
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
- name: Setup Godot
2024-02-12 23:14:52 +01:00
uses: lihop/setup-godot@v2
with:
version: ${{ matrix.godot-version }}
- name: Macos setup
2024-02-25 01:13:13 +01:00
if: ${{ matrix.platform == 'macos' }}
run: |
# Some macos runners have metal which means we can use vulkan, others don't.
if system_profiler SPDisplaysDataType | grep -q "Metal"; then
echo RENDERING_DRIVER=vulkan >> .env
brew install molten-vk
else
echo RENDERING_DRIVER=opengl3 >> .env
fi
2024-02-24 03:48:48 +01:00
- name: Install just
uses: taiki-e/install-action@just
- name: Install dependencies
run: just install
- name: Import assets
shell: bash
run: godot --editor --headless --quit-after 100 || true
- name: Wait for build
uses: fountainhead/action-wait-for-check@v1.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Build (${{ matrix.platform }}, ${{ matrix.arch }}, debug)
ref: ${{ github.event.pull_request.head.sha || github.sha }}
2024-02-13 09:23:22 +01:00
- name: Install binary build artifacts
uses: actions/download-artifact@v4
with:
path: addons/godot_xterm/native/bin
2024-02-24 04:24:54 +01:00
merge-multiple: true
2024-02-24 07:47:12 +01:00
- name: Set spawn-helper file permissions
if: ${{ matrix.platform == 'macos' }}
# File permissions are not preserved by upload-artifact.
run: chmod +x addons/godot_xterm/native/bin/spawn-helper
- name: Test
2024-02-18 08:26:32 +01:00
shell: bash
run: |
2024-02-25 01:13:13 +01:00
if [ "${{ matrix.platform }}" = "windows" ]; then
just test | tee output.log
2024-02-18 08:26:32 +01:00
else
just test-all | tee output.log
fi
# This step often passes when it shouldn't, due to GUT not failing on script errors
# (see: https://github.com/bitwes/Gut/issues/210). Therefore, we check the output
# for expected (and unexpected) strings.
if grep -q 'SCRIPT_ERROR:' output.log || grep -q 'Tests none' output.log; then
exit 1
2024-02-18 08:26:32 +01:00
fi
merge-artifacts:
name: Merge Artifacts
runs-on: ubuntu-latest
2024-02-24 04:24:54 +01:00
needs: [build-linux, build-other-platforms, test, html5-export]
strategy:
matrix:
target: [release, debug]
steps:
- uses: actions/upload-artifact/merge@v4
with:
name: libgodot-xterm-${{ matrix.target }}
pattern: "*-${{ matrix.target }}"
delete-merged: true
# Git archive should only include addons/godot_xterm directory.
check-archive:
name: "Check Archive"
runs-on: ubuntu-22.04
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
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/godot_xterm directory
run: |
shopt -s nullglob dotglob
ls -laR /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-pre-commit:
name: "Check Pre-Commit"
runs-on: ubuntu-22.04
2022-04-23 10:49:39 +02:00
steps:
2024-02-12 23:14:52 +01:00
- uses: actions/checkout@v4
- uses: pre-commit/action@v3.0.1