forked from youngledo/godot-java
-
Notifications
You must be signed in to change notification settings - Fork 0
365 lines (326 loc) · 14.7 KB
/
ci.yml
File metadata and controls
365 lines (326 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Allow manual trigger for full compatibility testing
workflow_dispatch:
inputs:
godot_version:
description: 'Godot version to test (e.g. 4.6.2-stable)'
required: false
default: '4.6.2-stable'
env:
GODOT_VERSION: ${{ github.event.inputs.godot_version || '4.6.2-stable' }}
GODOT_VERSION_NODOT: ${{ (github.event.inputs.godot_version || '4.6.2-stable') && '4.6.2' }}
jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
include:
- os: macos-latest
native_build: ./godot-java-core/native/build-macos.sh
native_profile: native-macos-universal
export_preset: macOS
export_output: build/macos/godot-java-it-test.zip
- os: ubuntu-latest
native_build: ./godot-java-core/native/build-linux.sh
native_profile: native-linux-x86_64
export_preset: Linux
export_output: build/linux/godot-java-it-test.x86_64
- os: windows-latest
native_build: ./godot-java-core/native/build-windows.bat
native_profile: native-windows-x86_64
export_preset: Windows
export_output: build/windows/godot-java-it-test.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Resolve Godot download URLs
id: godot-urls
shell: bash
run: |
VERSION="${{ env.GODOT_VERSION }}"
NODOT="${{ env.GODOT_VERSION_NODOT }}"
case "${RUNNER_OS}" in
Linux)
echo "godot_url=https://github.com/godotengine/godot/releases/download/${VERSION}/Godot_v${VERSION}_linux.x86_64.zip" >> $GITHUB_OUTPUT
echo "godot_exe=Godot_v${VERSION}_linux.x86_64" >> $GITHUB_OUTPUT
;;
macOS)
echo "godot_url=https://github.com/godotengine/godot/releases/download/${VERSION}/Godot_v${VERSION}_macos.universal.zip" >> $GITHUB_OUTPUT
echo "godot_exe=Godot.app/Contents/MacOS/Godot" >> $GITHUB_OUTPUT
;;
Windows)
echo "godot_url=https://github.com/godotengine/godot/releases/download/${VERSION}/Godot_v${VERSION}_win64.exe.zip" >> $GITHUB_OUTPUT
echo "godot_exe=Godot_v${VERSION}_win64.exe" >> $GITHUB_OUTPUT
;;
esac
echo "template_url=https://github.com/godotengine/godot/releases/download/${VERSION}/Godot_v${VERSION}_export_templates.tpz" >> $GITHUB_OUTPUT
- name: Cache Godot
id: cache-godot
uses: actions/cache@v4
with:
path: godot-bin
key: godot-${{ env.GODOT_VERSION }}-${{ runner.os }}
- name: Download Godot
if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
mkdir -p godot-bin
curl -L -o godot-bin/godot.zip "${{ steps.godot-urls.outputs.godot_url }}"
unzip -q godot-bin/godot.zip -d godot-bin
rm godot-bin/godot.zip
chmod +x godot-bin/${{ steps.godot-urls.outputs.godot_exe }}
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: brew install cmake
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential
- name: Setup MSVC environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Build native library (macOS)
if: runner.os == 'macOS'
run: |
echo "=== Building native library (macOS) ==="
chmod +x "${{ matrix.native_build }}"
"${{ matrix.native_build }}"
echo "source build:"
ls -la godot-java-core/native/build/ || echo "not found"
- name: Build native library (Linux)
if: runner.os == 'Linux'
run: |
echo "=== Building native library (Linux) ==="
chmod +x "${{ matrix.native_build }}"
"${{ matrix.native_build }}"
echo "source build:"
ls -la godot-java-core/native/build/ || echo "not found"
- name: Build native library (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
echo === Building native library (Windows) ===
call "${{ matrix.native_build }}"
echo source build:
dir godot-java-core\native\build\ 2>nul || echo not found
- name: Build
run: ./mvnw clean package -DskipTests -B -Pskip-native-unpack
- name: Create extension_list.cfg for CI
shell: bash
run: |
mkdir -p godot-java-examples/examples/it-test/.godot
printf 'res://godot-java.gdextension\n' > godot-java-examples/examples/it-test/.godot/extension_list.cfg
echo "extension_list.cfg contents:"
cat godot-java-examples/examples/it-test/.godot/extension_list.cfg
echo "--- end ---"
- name: Package native artifact (macOS/Linux)
if: runner.os != 'Windows'
run: ./mvnw package -pl godot-java-native -Ppackage-native,${{ matrix.native_profile }} -Dspotless.skip=true -B
- name: Package native artifact (Windows)
if: runner.os == 'Windows'
shell: cmd
run: .\mvnw.cmd package -pl godot-java-native -Ppackage-native,${{ matrix.native_profile }} -Dspotless.skip=true -B
- name: Create extension_list.cfg for CI
shell: bash
run: |
mkdir -p godot-java-examples/examples/it-test/.godot
printf 'res://godot-java.gdextension\n' > godot-java-examples/examples/it-test/.godot/extension_list.cfg
echo "extension_list.cfg contents:"
cat godot-java-examples/examples/it-test/.godot/extension_list.cfg
echo "--- end ---"
- name: Sync godot-java runtime to it-test (bash)
if: runner.os != 'Windows'
run: |
chmod +x scripts/sync-godot-java.sh
NATIVE_ZIP=$(find godot-java-native/target -name 'godot-java-native-*.zip' | head -1)
scripts/sync-godot-java.sh \
--project godot-java-examples/examples/it-test \
--app-jar godot-java-examples/target/godot-java-examples.jar \
--native-zip "$NATIVE_ZIP"
ls -la godot-java-examples/examples/it-test/godot-java/
- name: Sync godot-java runtime to it-test (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
NATIVE_ZIP=$(find godot-java-native/target -name 'godot-java-native-*.zip' | head -1)
scripts/sync-godot-java.sh \
--project godot-java-examples/examples/it-test \
--app-jar godot-java-examples/target/godot-java-examples.jar \
--native-zip "$NATIVE_ZIP"
ls -la godot-java-examples/examples/it-test/godot-java/
- name: Verify test environment
shell: bash
run: |
echo "=== Godot version: ${{ env.GODOT_VERSION }} ==="
echo "=== .gdextension contents ==="
cat godot-java-examples/examples/it-test/godot-java.gdextension
echo "=== .gdextension hex dump (first line) ==="
head -1 godot-java-examples/examples/it-test/godot-java.gdextension | xxd | head -3
echo "=== godot-java/ contents ==="
ls -la godot-java-examples/examples/it-test/godot-java/
echo "=== extension_list.cfg ==="
cat godot-java-examples/examples/it-test/.godot/extension_list.cfg
echo "=== Godot binary ==="
ls -la godot-bin/ || echo "godot-bin/ not found"
echo "=== JAVA_HOME ==="
echo "$JAVA_HOME"
- name: Install Godot export templates
shell: bash
run: |
NODOT="${{ env.GODOT_VERSION_NODOT }}"
case "${RUNNER_OS}" in
Linux)
TEMPLATE_DIR="$HOME/.local/share/godot/export_templates/${NODOT}.stable"
;;
macOS)
TEMPLATE_DIR="$HOME/Library/Application Support/Godot/export_templates/${NODOT}.stable"
;;
Windows)
TEMPLATE_DIR="$APPDATA/Godot/export_templates/${NODOT}.stable"
;;
*)
echo "Unsupported runner OS: ${RUNNER_OS}" >&2
exit 1
;;
esac
mkdir -p "$TEMPLATE_DIR"
curl -L -o godot-bin/export_templates.tpz "${{ steps.godot-urls.outputs.template_url }}"
unzip -q -o godot-bin/export_templates.tpz -d godot-bin/export_templates
cp godot-bin/export_templates/templates/* "$TEMPLATE_DIR/"
- name: Export smoke project
shell: bash
env:
GODOT_JAVA_CLASSPATH: ${{ github.workspace }}/godot-java-examples/examples/it-test/godot-java/app.jar
run: |
mkdir -p "$(dirname "godot-java-examples/examples/it-test/${{ matrix.export_output }}")"
godot-bin/${{ steps.godot-urls.outputs.godot_exe }} \
--headless \
--path godot-java-examples/examples/it-test \
--export-release "${{ matrix.export_preset }}" \
"${{ matrix.export_output }}"
- name: Run exported smoke project (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
EXPORT_DIR=godot-java-examples/examples/it-test/build/linux
rm -rf "$EXPORT_DIR/godot-java"
cp -R godot-java-examples/examples/it-test/godot-java "$EXPORT_DIR/godot-java"
(
cd "$EXPORT_DIR"
GODOT_JAVA_CLASSPATH="$PWD/godot-java/app.jar" ./godot-java-it-test.x86_64 --headless
)
- name: Run exported smoke project (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
unzip -q godot-java-examples/examples/it-test/build/macos/godot-java-it-test.zip -d godot-java-examples/examples/it-test/build/macos/exported
EXE=$(find godot-java-examples/examples/it-test/build/macos/exported -path '*.app/Contents/MacOS/*' -type f | head -1)
APP_DIR="${EXE%/Contents/MacOS/*}"
RUNTIME_DIR="$APP_DIR/Contents/Resources/godot-java"
rm -rf "$RUNTIME_DIR"
mkdir -p "$RUNTIME_DIR"
cp -R godot-java-examples/examples/it-test/godot-java/. "$RUNTIME_DIR/"
RUNTIME_DIR="$(cd "$RUNTIME_DIR" && pwd)"
ls -la "$RUNTIME_DIR"
jar tf "$RUNTIME_DIR/app.jar" | grep 'org/godot/bootstrap/Bootstrap.class'
chmod +x "$EXE"
GODOT_JAVA_CLASSPATH="$RUNTIME_DIR/app.jar" "$EXE" --headless
- name: Run exported smoke project (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
EXPORT_DIR=godot-java-examples/examples/it-test/build/windows
rm -rf "$EXPORT_DIR/godot-java"
cp -R godot-java-examples/examples/it-test/godot-java "$EXPORT_DIR/godot-java"
(
cd "$EXPORT_DIR"
GODOT_JAVA_CLASSPATH="$PWD/godot-java/app.jar" ./godot-java-it-test.exe --headless
)
- name: Run all tests (macOS)
if: runner.os == 'macOS'
env:
GODOT_BIN: ${{ github.workspace }}/godot-bin/Godot.app/Contents/MacOS/Godot
GODOT_JAVA_CLASSPATH: ${{ github.workspace }}/godot-java-examples/examples/it-test/godot-java/app.jar
run: ./mvnw test -pl godot-java-core -B
- name: Run all tests (Linux)
if: runner.os == 'Linux'
env:
GODOT_BIN: ${{ github.workspace }}/godot-bin/${{ steps.godot-urls.outputs.godot_exe }}
GODOT_JAVA_CLASSPATH: ${{ github.workspace }}/godot-java-examples/examples/it-test/godot-java/app.jar
run: ./mvnw test -pl godot-java-core -B
- name: Run all tests (Windows)
if: runner.os == 'Windows'
shell: cmd
env:
GODOT_BIN: ${{ github.workspace }}\godot-bin\${{ steps.godot-urls.outputs.godot_exe }}
GODOT_JAVA_CLASSPATH: ${{ github.workspace }}\godot-java-examples\examples\it-test\godot-java\app.jar
run: .\mvnw.cmd test -pl godot-java-core -B
- name: Upload stability diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: stability-diagnostics-${{ runner.os }}
if-no-files-found: ignore
path: |
godot-java-core/target/surefire-reports/**
godot-java-examples/examples/it-test/.godot/**
godot-java-examples/examples/it-test/build/**
godot-java-examples/examples/it-test/godot-java/**
# Codegen compatibility check: verify code generator works with different API versions
codegen-compat:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- godot_version: '4.3-stable'
api_url: 'https://raw.githubusercontent.com/godotengine/godot/4.3-stable/extension_api.json'
- godot_version: '4.4-stable'
api_url: 'https://raw.githubusercontent.com/godotengine/godot/4.4-stable/extension_api.json'
- godot_version: '4.5-stable'
api_url: 'https://raw.githubusercontent.com/godotengine/godot/4.5-stable/extension_api.json'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
- name: Download extension_api.json for ${{ matrix.godot_version }}
run: |
curl -L -o extension_api.json "${{ matrix.api_url }}"
echo "Downloaded extension_api.json for ${{ matrix.godot_version }}"
head -c 200 extension_api.json
- name: Run code generator with ${{ matrix.godot_version }} API
run: |
./mvnw compile -pl godot-java-code-generator -DskipTests -B -q
JAR=$(find godot-java-code-generator/target -name 'godot-java-code-generator-*-with-dependencies.jar' | head -1)
mkdir -p /tmp/codegen-output-${{ matrix.godot_version }}
java -jar "$JAR" extension_api.json godot-api/gdextension_interface.json /tmp/codegen-output-${{ matrix.godot_version }} --force
echo "Generated $(find /tmp/codegen-output-${{ matrix.godot_version }} -name '*.java' | wc -l) files"
- name: Upload generated code
if: failure()
uses: actions/upload-artifact@v4
with:
name: codegen-${{ matrix.godot_version }}
path: /tmp/codegen-output-${{ matrix.godot_version }}