Skip to content

Commit 9b4a139

Browse files
committed
Proof of concept for a hot-reload test case
1 parent 154dfbf commit 9b4a139

File tree

4 files changed

+306
-119
lines changed

4 files changed

+306
-119
lines changed

.github/workflows/ci-cmake.yml

Lines changed: 92 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,53 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
include:
35+
# Linux: Standard tests with bash
3536
- name: 🐧 Linux (GCC, Makefiles)
3637
os: ubuntu-22.04
3738
platform: linux
3839
config-flags: -DCMAKE_BUILD_TYPE=Release
3940
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release.cmake
4041
artifact-path: cmake-build/bin/libgodot-cpp.linux.template_release.x86_64.a
4142
run-tests: true
42-
43+
godot_workflow: linux_builds.yml
44+
godot_artifact_name: linux-editor-mono
45+
godot_binary_path: godot.linuxbsd.editor.x86_64.mono
46+
test_shell: bash
47+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_linux.x86_64.zip
48+
stable_binary_path: Godot_v4.5.1-stable_linux.x86_64
49+
50+
# Windows MSVC: Tests with pwsh, .exe binary
4351
- name: 🏁 Windows (x86_64, MSVC)
4452
os: windows-2022
4553
platform: windows
4654
compiler: msvc
4755
build-flags: --config Release
4856
artifact-name: godot-cpp-windows-msvc2019-x86_64-release.cmake
4957
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.lib
50-
run-tests: false
51-
58+
run-tests: true # Enabled: Uses PS1 script
59+
godot_workflow: windows_builds.yml
60+
godot_artifact_name: windows-editor-mono
61+
godot_binary_path: godot.windows.editor.x86_64.mono.exe
62+
test_shell: pwsh
63+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_win64.zip
64+
stable_binary_path: Godot_v4.5.1-stable_win64.exe
65+
66+
# macOS: Tests with bash, .app path
67+
- name: 🍎 macOS (universal, Makefiles)
68+
os: macos-latest
69+
platform: macos
70+
config-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
71+
artifact-name: godot-cpp-macos-universal-release.cmake
72+
artifact-path: cmake-build/bin/libgodot-cpp.macos.template_release.universal.a
73+
run-tests: true # Enabled: Quick macOS validation
74+
godot_workflow: macos_builds.yml
75+
godot_artifact_name: macos-editor-mono
76+
godot_binary_path: Godot.app/Contents/MacOS/Godot # Inside .app bundle
77+
test_shell: bash
78+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_macos.universal.zip
79+
stable_binary_path: Godot_v4.5.1-stable_macos.universal/Godot.app/Contents/MacOS/Godot
80+
81+
# Other platforms: No tests, no godot vars (MinGW uses compiler: mingw, etc.)
5282
- name: 🏁 Windows (x86_64, MinGW, Ninja)
5383
os: windows-2022
5484
platform: windows
@@ -60,14 +90,6 @@ jobs:
6090
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.a
6191
run-tests: false
6292

63-
- name: 🍎 macOS (universal, Makefiles)
64-
os: macos-latest
65-
platform: macos
66-
config-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
67-
artifact-name: godot-cpp-macos-universal-release.cmake
68-
artifact-path: cmake-build/bin/libgodot-cpp.macos.template_release.universal.a
69-
run-tests: false
70-
7193
- name: 🤖 Android (arm64, Ninja)
7294
os: ubuntu-22.04
7395
platform: android
@@ -140,43 +162,83 @@ jobs:
140162
shell: bash
141163
run: ${SCCACHE_PATH} --show-stats
142164

165+
# Godot Download & Prep (only if run-tests: true) - Identical to SCons
143166
- name: Download latest Godot artifacts
144-
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
167+
id: godot-download
145168
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
169+
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
146170
with:
147171
repo: godotengine/godot
148172
branch: master
149173
event: push
150-
workflow: linux_builds.yml
174+
workflow: ${{ matrix.godot_workflow }}
151175
workflow_conclusion: success
152-
name: linux-editor-mono
176+
name: ${{ matrix.godot_artifact_name }}
153177
search_artifacts: true
154178
check_artifacts: true
155179
ensure_latest: true
156180
path: godot-artifacts
181+
if_no_artifact_found: warn
182+
continue-on-error: true
183+
184+
- name: Download stable Godot (fallback or non-master)
185+
id: godot-fallback
186+
if: |
187+
matrix.run-tests &&
188+
(
189+
(env.GODOT_TEST_VERSION == 'master' && steps.godot-download.outcome != 'success') ||
190+
env.GODOT_TEST_VERSION != 'master'
191+
)
192+
shell: ${{ matrix.test_shell }}
193+
run: |
194+
curl -L -o Godot.zip "${{ matrix.stable_url }}"
195+
unzip -q Godot.zip
196+
echo "GODOT=$(pwd)/${{ matrix.stable_binary_path }}" >> $GITHUB_ENV
157197
158-
- name: Prepare Godot artifacts for testing
159-
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
198+
- name: Prepare Godot binary from artifacts
199+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master' && steps.godot-download.outcome == 'success'
200+
shell: ${{ matrix.test_shell }}
160201
run: |
161-
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
162-
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
202+
if [ "${{ matrix.platform }}" != "windows" ]; then
203+
chmod +x "./godot-artifacts/${{ matrix.godot_binary_path }}"
204+
fi
205+
echo "GODOT=$(pwd)/godot-artifacts/${{ matrix.godot_binary_path }}" >> $GITHUB_ENV
163206
164-
- name: Download requested Godot version for testing
165-
if: matrix.run-tests && env.GODOT_TEST_VERSION != 'master'
207+
- name: Verify Godot binary
208+
if: matrix.run-tests
209+
shell: ${{ matrix.test_shell }}
210+
run: $GODOT --headless --version
211+
212+
- name: Prep project import
213+
if: matrix.run-tests
214+
shell: ${{ matrix.test_shell }}
215+
run: |
216+
cd test/project
217+
timeout 30 $GODOT --import --headless || true
218+
219+
- name: Run unit tests
220+
if: matrix.run-tests
221+
shell: ${{ matrix.test_shell }}
222+
working-directory: test
166223
run: |
167-
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
168-
unzip -a Godot.zip
169-
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
170-
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
224+
if [ "${{ matrix.test_shell }}" = "pwsh" ]; then
225+
pwsh -File ./run-tests.ps1 --unit-only
226+
else
227+
./run-tests.sh --unit-only
228+
fi
171229
172-
- name: Run tests
230+
- name: Run reload test
173231
if: matrix.run-tests
232+
shell: ${{ matrix.test_shell }}
233+
working-directory: test
174234
run: |
175-
$GODOT --headless --version
176-
cd test
177-
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
178-
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
179-
./run-tests.sh
235+
rm -f project/test_reload_lock
236+
if [ "${{ matrix.test_shell }}" = "pwsh" ]; then
237+
pwsh -File ./run-tests.ps1 --reload-only
238+
else
239+
./run-tests.sh --reload-only
240+
fi
241+
rm -f project/test_reload_lock
180242
181243
- name: Upload artifact
182244
uses: actions/upload-artifact@v4

.github/workflows/ci-scons.yml

Lines changed: 102 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,53 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
include:
28+
# Linux: Standard tests with bash
2829
- name: 🐧 Linux (GCC)
2930
os: ubuntu-22.04
3031
platform: linux
3132
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
3233
artifact-path: bin/libgodot-cpp.linux.template_release.x86_64.a
3334
run-tests: true
3435
cache-name: linux-x86_64
35-
36+
godot_workflow: linux_builds.yml
37+
godot_artifact_name: linux-editor-mono
38+
godot_binary_path: godot.linuxbsd.editor.x86_64.mono
39+
test_shell: bash
40+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_linux.x86_64.zip
41+
stable_binary_path: Godot_v4.5.1-stable_linux.x86_64
42+
43+
# Windows MSVC: Tests with pwsh, .exe binary
3644
- name: 🏁 Windows (x86_64, MSVC)
3745
os: windows-2022
3846
platform: windows
3947
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
4048
artifact-path: bin/libgodot-cpp.windows.template_release.x86_64.lib
41-
run-tests: false
49+
run-tests: true # Enabled: Uses PS1 script
4250
cache-name: windows-x86_64-msvc
43-
51+
godot_workflow: windows_builds.yml
52+
godot_artifact_name: windows-editor-mono
53+
godot_binary_path: godot.windows.editor.x86_64.mono.exe
54+
test_shell: pwsh
55+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_win64.zip
56+
stable_binary_path: Godot_v4.5.1-stable_win64.exe
57+
58+
# macOS: Tests with bash, .app path
59+
- name: 🍎 macOS (universal)
60+
os: macos-latest
61+
platform: macos
62+
artifact-name: godot-cpp-macos-universal-release
63+
artifact-path: bin/libgodot-cpp.macos.template_release.universal.a
64+
flags: arch=universal
65+
run-tests: true # Enabled: Quick macOS validation
66+
cache-name: macos-universal
67+
godot_workflow: macos_builds.yml
68+
godot_artifact_name: macos-editor-mono
69+
godot_binary_path: Godot.app/Contents/MacOS/Godot # Inside .app bundle
70+
test_shell: bash
71+
stable_url: https://github.com/godotengine/godot-builds/releases/download/4.5.1-stable/Godot_v4.5.1-stable_macos.universal.zip
72+
stable_binary_path: Godot_v4.5.1-stable_macos.universal/Godot.app/Contents/MacOS/Godot
73+
74+
# Other platforms: No tests, no godot vars
4475
- name: 🏁 Windows (x86_64, MinGW)
4576
os: windows-2022
4677
platform: windows
@@ -50,15 +81,6 @@ jobs:
5081
run-tests: false
5182
cache-name: windows-x86_64-mingw
5283

53-
- name: 🍎 macOS (universal)
54-
os: macos-latest
55-
platform: macos
56-
artifact-name: godot-cpp-macos-universal-release
57-
artifact-path: bin/libgodot-cpp.macos.template_release.universal.a
58-
flags: arch=universal
59-
run-tests: false
60-
cache-name: macos-universal
61-
6284
- name: 🤖 Android (arm64)
6385
os: ubuntu-22.04
6486
platform: android
@@ -133,43 +155,91 @@ jobs:
133155
cache-name: ${{ matrix.cache-name }}
134156
continue-on-error: true
135157

158+
# Godot Download & Prep (only if run-tests: true)
136159
- name: Download latest Godot artifacts
137-
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
160+
id: godot-download
138161
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
162+
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
139163
with:
140164
repo: godotengine/godot
141165
branch: master
142166
event: push
143-
workflow: linux_builds.yml
167+
workflow: ${{ matrix.godot_workflow }}
144168
workflow_conclusion: success
145-
name: linux-editor-mono
169+
name: ${{ matrix.godot_artifact_name }}
146170
search_artifacts: true
147171
check_artifacts: true
148172
ensure_latest: true
149173
path: godot-artifacts
150-
151-
- name: Prepare Godot artifacts for testing
152-
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
174+
if_no_artifact_found: warn
175+
continue-on-error: true # Allows fallback step
176+
177+
- name: Download stable Godot (fallback or non-master)
178+
id: godot-fallback
179+
if: |
180+
matrix.run-tests &&
181+
(
182+
(env.GODOT_TEST_VERSION == 'master' && steps.godot-download.outcome != 'success') ||
183+
env.GODOT_TEST_VERSION != 'master'
184+
)
185+
shell: ${{ matrix.test_shell }}
186+
run: |
187+
# wget/unzip to stable (matrix provides exact URL/path)
188+
curl -L -o Godot.zip "${{ matrix.stable_url }}"
189+
unzip -q Godot.zip
190+
# Set GODOT env (platform-specific path from matrix)
191+
echo "GODOT=$(pwd)/${{ matrix.stable_binary_path }}" >> $GITHUB_ENV
192+
193+
- name: Prepare Godot binary from artifacts
194+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master' && steps.godot-download.outcome == 'success'
195+
shell: ${{ matrix.test_shell }}
153196
run: |
154-
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
155-
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
197+
# chmod only if not Windows (matrix binary_path assumes extracted name)
198+
if [ "${{ matrix.platform }}" != "windows" ]; then
199+
chmod +x "./godot-artifacts/${{ matrix.godot_binary_path }}"
200+
fi
201+
# Set GODOT env
202+
echo "GODOT=$(pwd)/godot-artifacts/${{ matrix.godot_binary_path }}" >> $GITHUB_ENV
203+
204+
- name: Verify Godot binary
205+
if: matrix.run-tests
206+
shell: ${{ matrix.test_shell }}
207+
run: $GODOT --headless --version # Confirms correct binary loaded
156208

157-
- name: Download requested Godot version for testing
158-
if: matrix.run-tests && env.GODOT_TEST_VERSION != 'master'
209+
# Test Execution (separate for clarity; scripts handle internals)
210+
- name: Prep project import
211+
if: matrix.run-tests
212+
shell: ${{ matrix.test_shell }}
159213
run: |
160-
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
161-
unzip -a Godot.zip
162-
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
163-
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
214+
cd test/project
215+
# Timeout import (30s, ignore crash)
216+
timeout 30 $GODOT --import --headless || true # Bash; for pwsh, matrix.shell handles equiv if needed
164217
165-
- name: Run tests
218+
- name: Run unit tests
166219
if: matrix.run-tests
220+
shell: ${{ matrix.test_shell }}
221+
working-directory: test
167222
run: |
168-
$GODOT --headless --version
169-
cd test
170-
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
171-
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
172-
./run-tests.sh
223+
# Calls run-tests.sh/ps1 for first half (unit tests)
224+
if [ "${{ matrix.test_shell }}" = "pwsh" ]; then
225+
pwsh -File ./run-tests.ps1 --unit-only # Assume PS1 updated with flag; else split script
226+
else
227+
./run-tests.sh --unit-only # Assume bash updated with flag
228+
fi
229+
230+
- name: Run reload test
231+
if: matrix.run-tests
232+
shell: ${{ matrix.test_shell }}
233+
working-directory: test
234+
run: |
235+
# Handles lock/filtering in script
236+
rm -f project/test_reload_lock # Pre-clean (cross-shell safe)
237+
if [ "${{ matrix.test_shell }}" = "pwsh" ]; then
238+
pwsh -File ./run-tests.ps1 --reload-only
239+
else
240+
./run-tests.sh --reload-only
241+
fi
242+
rm -f project/test_reload_lock # Post-clean
173243
174244
- name: Upload artifact
175245
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)