Skip to content

Commit 66b2dd7

Browse files
bors[bot]Bromeon
andauthored
Merge #833
833: Feature flag for custom Godot version r=Bromeon a=Bromeon Enables the use of custom Godot builds in a straightforward way. This includes older versions such as Godot 3.2, for which `api.json` is no longer shipped along. Previous process (see also [book](https://godot-rust.github.io/book/advanced-guides/custom-godot.html)): * create a local copy of godot-rust * Run `godot --gdnative-generate-json-api` * replace `api.json` inside `gdnative-binding` New process: * enable feature `custom-godot` * make sure `godot` executable is in path **OR** set `GODOT_BIN` env var * done This supersedes the previous `bindings` feature, which is now removed. I also added CI support for previous Godot version 3.3.1, so far only for integration tests. Originally I wanted to use Godot 3.2 (the oldest supported version), however godotengine/godot#36582 prevented headless versions from generating `api.json` reliably without crashing. This has been fixed for versions >= 3.3.1. There is still testing to be done; feedback is always appreciated! 🙂 Closes #640. Thanks for the great ideas in that issue. Co-authored-by: Jan Haller <[email protected]>
2 parents 8d9b982 + 2910280 commit 66b2dd7

File tree

19 files changed

+284
-201
lines changed

19 files changed

+284
-201
lines changed

.github/composite/godot/action.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: godot
2+
description: "Run Godot integration tests"
3+
4+
inputs:
5+
godot_ver:
6+
required: true
7+
description: "Godot version (e.g. '3.2')"
8+
9+
rust_toolchain:
10+
required: false
11+
default: 'stable'
12+
description: "Rust toolchain specifier (e.g. 'nightly')"
13+
14+
rust_extra_args:
15+
required: false
16+
default: ''
17+
description: "Extra command line arguments for 'cargo build', e.g. features"
18+
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Install Rust
25+
uses: ./.github/composite/rust
26+
with:
27+
rust: ${{ inputs.rust_toolchain }}
28+
- name: "Check cache for installed Godot version"
29+
id: "cache-godot"
30+
uses: actions/cache@v2
31+
with:
32+
path: ${{ runner.temp }}/godot_bin
33+
key: godot-${{ runner.os }}-v${{ inputs.godot_ver }}
34+
- name: "Install Godot"
35+
if: steps.cache-godot.outputs.cache-hit != 'true'
36+
run: |
37+
wget --no-verbose "https://downloads.tuxfamily.org/godotengine/${{ inputs.godot_ver }}/Godot_v${{ inputs.godot_ver }}-stable_linux_headless.64.zip" -O /tmp/godot.zip
38+
unzip -o /tmp/godot.zip -d ${{ runner.temp }}/godot_bin
39+
shell: bash
40+
- name: "Set environment variable"
41+
run: |
42+
echo "GODOT_BIN=${{ runner.temp }}/godot_bin/Godot_v${{ inputs.godot_ver }}-stable_linux_headless.64" >> $GITHUB_ENV
43+
shell: bash
44+
- name: "Build godot-rust"
45+
run: |
46+
echo "File size of api.json -- before:"
47+
stat -c %s gdnative-bindings/api.json
48+
49+
#echo "CRC32 of api.json: "
50+
#crc32 gdnative-bindings/api.json
51+
cd test
52+
cargo build ${{ inputs.rust_extra_args }}
53+
54+
cd ..
55+
echo "File size of api.json -- after:"
56+
stat -c %s gdnative-bindings/api.json
57+
shell: bash
58+
- name: "Run Godot integration tests"
59+
run: |
60+
cd test;
61+
mkdir -p ./project/lib;
62+
cp ../target/debug/libgdnative_test.so ./project/lib/;
63+
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
64+
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
65+
exit 1;
66+
fi;
67+
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
68+
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
69+
exit 1;
70+
fi;
71+
cargo build --features type-tag-fallback;
72+
mkdir -p ./project/lib;
73+
cp ../target/debug/libgdnative_test.so ./project/lib/;
74+
${GODOT_BIN} --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
75+
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
76+
exit 1;
77+
fi;
78+
${GODOT_BIN} -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
79+
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
80+
exit 1;
81+
fi;
82+
shell: bash

.github/workflows/doc.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ on:
1414

1515

1616
env:
17-
GDNATIVE_LIB_RS_PREFIX: |-
17+
GDRUST_LIB_RS_PREFIX: |-
1818
//! _**Note:** This documentation refers to the [latest GitHub version](https://github.com/godot-rust/godot-rust) and is subject to change._<br>
1919
//! _For stable releases, visit [docs.rs/gdnative](https://docs.rs/gdnative)._
2020
//! <br><br>
2121
//!
22-
GDNATIVE_DOC_REPO: [email protected]:godot-rust/docs.git
23-
GDNATIVE_DOC_BRANCH: gh-pages
22+
GDRUST_DOC_REPO: [email protected]:godot-rust/docs.git
23+
GDRUST_DOC_BRANCH: gh-pages
24+
GDRUST_FEATURES: "async,serde"
2425

2526

2627
# In the very unlikely cases where two PRs are merged, and the first 'doc' job is still running when the 2nd 'full-ci' starts,
@@ -46,13 +47,13 @@ jobs:
4647
- name: "Pre-process input"
4748
run: |
4849
mv ${GITHUB_WORKSPACE}/gdnative/src/lib.rs tmp_lib.rs
49-
(echo "${GDNATIVE_LIB_RS_PREFIX}"; cat tmp_lib.rs) > ${GITHUB_WORKSPACE}/gdnative/src/lib.rs
50+
(echo "${GDRUST_LIB_RS_PREFIX}"; cat tmp_lib.rs) > ${GITHUB_WORKSPACE}/gdnative/src/lib.rs
5051
5152
- name: "Generate documentation"
5253
uses: actions-rs/cargo@v1
5354
with:
5455
command: doc
55-
args: -p gdnative --lib --no-deps --all-features
56+
args: -p gdnative --lib --no-deps --features ${GDRUST_FEATURES}
5657

5758
# For email address, see https://github.community/t/github-actions-bot-email-address/17204
5859
# As search-index.js changes every time, even if source hasn't changed, this will not need 'git commit --allow-empty'
@@ -65,25 +66,25 @@ jobs:
6566
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
6667
6768
mkdir doc && cd doc
68-
git clone --single-branch --branch ${GDNATIVE_DOC_BRANCH} --no-checkout ${GDNATIVE_DOC_REPO} . \
69-
|| (git init -b ${GDNATIVE_DOC_BRANCH} && git remote add origin ${GDNATIVE_DOC_REPO})
69+
git clone --single-branch --branch ${GDRUST_DOC_BRANCH} --no-checkout ${GDRUST_DOC_REPO} . \
70+
|| (git init -b ${GDRUST_DOC_BRANCH} && git remote add origin ${GDRUST_DOC_REPO})
7071
7172
mv ${GITHUB_WORKSPACE}/target/doc/* .
7273
mv ${GITHUB_WORKSPACE}/.github/workflows/doc/* .
7374
74-
GDNATIVE_VERSION=$(grep -Po '^version = "\K[^"]*' ${GITHUB_WORKSPACE}/gdnative/Cargo.toml)
75-
GDNATIVE_SHORT_SHA=$(git rev-parse --short "${GITHUB_SHA}")
75+
GDRUST_VERSION=$(grep -Po '^version = "\K[^"]*' ${GITHUB_WORKSPACE}/gdnative/Cargo.toml)
76+
GDRUST_SHORT_SHA=$(git rev-parse --short "${GITHUB_SHA}")
7677
77-
find gdnative -name .html -o -type f -print0 | xargs -0 sed -i 's/'"${GDNATIVE_VERSION}"'/master/g'
78+
find gdnative -name .html -o -type f -print0 | xargs -0 sed -i 's/'"${GDRUST_VERSION}"'/master/g'
7879
7980
git add --all
80-
git commit -m "Sync doc from ${GDNATIVE_SHORT_SHA}
81+
git commit -m "Sync doc from ${GDRUST_SHORT_SHA}
8182
8283
Revision in godot-rust: ${GITHUB_SHA}"
8384
8485
- name: "Upload"
8586
working-directory: doc
86-
run: git push origin ${GDNATIVE_DOC_BRANCH}
87+
run: git push origin ${GDRUST_DOC_BRANCH}
8788

8889
- name: "Cleanup"
8990
run: shred -u ~/.ssh/id_rsa

.github/workflows/full-ci.yml

Lines changed: 48 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ env:
3232

3333
# Local variables
3434
# Note: using variables is limited at the moment, see https://github.com/actions/runner/issues/480
35-
GODOT_VER: "3.4"
36-
GODOT_REL: stable
35+
GDRUST_FEATURES: "gdnative/async,gdnative/serde"
3736

3837
on:
3938
push:
@@ -50,11 +49,11 @@ jobs:
5049
runs-on: ubuntu-latest
5150
steps:
5251
- uses: actions/checkout@v2
53-
- name: Install Rust
52+
- name: "Install Rust"
5453
uses: ./.github/composite/rust
5554
with:
5655
components: rustfmt
57-
- name: Check rustfmt
56+
- name: "Check rustfmt"
5857
run: cargo fmt --all -- --check;
5958

6059
clippy:
@@ -71,13 +70,13 @@ jobs:
7170
postfix: ' (nightly)'
7271
steps:
7372
- uses: actions/checkout@v2
74-
- name: Install Rust
73+
- name: "Install Rust"
7574
uses: ./.github/composite/rust
7675
with:
7776
rust: ${{ matrix.rust.toolchain }}
7877
components: clippy
79-
- name: Check clippy
80-
run: cargo clippy --workspace --all-features -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented;
78+
- name: "Check clippy"
79+
run: cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented;
8180

8281
test:
8382
name: test-${{ matrix.os.name }}${{ matrix.rust.postfix }}
@@ -106,22 +105,22 @@ jobs:
106105
- rust: { toolchain: 'nightly' }
107106
testflags: '-- --skip ui_tests'
108107
- os: { id: ubuntu-latest, name: linux }
109-
rust: { toolchain: '1.48', postfix: ' (msrv 1.48)' }
108+
rust: { toolchain: '1.51', postfix: ' (msrv 1.51)' }
110109
testflags: '-- --skip ui_tests'
111110
runs-on: ${{ matrix.os.id }}
112111
steps:
113112
- uses: actions/checkout@v2
114-
- name: Install Rust
113+
- name: "Install Rust"
115114
uses: ./.github/composite/rust
116115
with:
117116
rust: ${{ matrix.rust.toolchain }}
118-
- name: Install LLVM
117+
- name: "Install LLVM"
119118
uses: ./.github/composite/llvm
120119
if: ${{ matrix.os.id == 'windows-latest' }}
121-
- name: Compile tests
122-
run: cargo test --workspace --all-features --no-run;
123-
- name: Test
124-
run: cargo test --workspace --all-features ${{ matrix.testflags }};
120+
- name: "Compile tests"
121+
run: cargo test --workspace --features ${GDRUST_FEATURES} --no-run;
122+
- name: "Test"
123+
run: cargo test --workspace --features ${GDRUST_FEATURES} ${{ matrix.testflags }};
125124

126125
build-release:
127126
name: build-release-${{ matrix.os.name }}
@@ -139,14 +138,14 @@ jobs:
139138
runs-on: ${{ matrix.os.id }}
140139
steps:
141140
- uses: actions/checkout@v2
142-
- name: Install Rust
141+
- name: "Install Rust"
143142
uses: ./.github/composite/rust
144143
with:
145144
rust: stable
146-
- name: Install LLVM
145+
- name: "Install LLVM"
147146
uses: ./.github/composite/llvm
148147
if: ${{ matrix.os.id == 'windows-latest' }}
149-
- name: Release build (check only)
148+
- name: "Release build (check only)"
150149
run: cargo check --release;
151150

152151
build-ios:
@@ -158,18 +157,18 @@ jobs:
158157
runs-on: macos-latest
159158
steps:
160159
- uses: actions/checkout@v2
161-
- name: Install Rust
160+
- name: "Install Rust"
162161
uses: ./.github/composite/rust
163162
#with:
164163
# rust: ${{ matrix.rust.toolchain }}
165-
- name: Install cargo-dinghy
164+
- name: "Install cargo-dinghy"
166165
run: |
167166
rustup target add x86_64-apple-ios;
168167
curl -L https://github.com/sonos/dinghy/releases/download/0.4.62/cargo-dinghy-macos-0.4.62.tgz -o cargo-dinghy-macos.tar.gz;
169168
tar -zxvf cargo-dinghy-macos.tar.gz;
170169
mkdir -p $HOME/.cargo/bin;
171170
cp cargo-dinghy-0.4.62/cargo-dinghy $HOME/.cargo/bin;
172-
- name: Cross-compile to iOS
171+
- name: "Cross-compile to iOS"
173172
run: |
174173
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1);
175174
export SIM_ID=$(xcrun simctl create My-iphone11 com.apple.CoreSimulator.SimDeviceType.iPhone-11 $RUNTIME_ID);
@@ -190,11 +189,11 @@ jobs:
190189
runs-on: ubuntu-latest
191190
steps:
192191
- uses: actions/checkout@v2
193-
- name: Install Rust
192+
- name: "Install Rust"
194193
uses: ./.github/composite/rust
195194
#with:
196195
# rust: ${{ matrix.rust.toolchain }}
197-
- name: Install Java + NDK
196+
- name: "Install Java + NDK"
198197
run: |
199198
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64;
200199
export ANDROID_SDK_ROOT=/opt/ndk/android-ndk-r21d;
@@ -227,65 +226,42 @@ jobs:
227226
cargo build --target armv7-linux-androideabi --release;
228227
229228
integration-test-godot:
230-
name: itest-godot${{ matrix.rust.postfix }}
229+
name: itest-godot-${{ matrix.godot }}${{ matrix.postfix }}
231230
needs: rustfmt
232231
continue-on-error: ${{ matrix.rust.toolchain == 'nightly' }}
233232
strategy:
233+
fail-fast: false # cancel all jobs as soon as one fails?
234234
matrix:
235-
rust:
236-
- toolchain: stable
235+
include:
236+
# Latest Godot with different Rust versions
237+
- rust: stable
238+
godot: "3.4.1"
237239
postfix: ''
238-
- toolchain: nightly
240+
- rust: nightly
241+
godot: "3.4.1"
239242
postfix: ' (nightly)'
240-
- toolchain: '1.48'
241-
postfix: ' (msrv 1.48)'
243+
- rust: '1.51'
244+
godot: "3.4.1"
245+
postfix: ' (msrv 1.51)'
246+
247+
# Test with older engine version
248+
# Note: headless versions of Godot <= 3.3 may crash with a bug, see feature description in lib.rs
249+
- rust: stable
250+
godot: "3.3.1"
251+
postfix: ''
252+
build_args: '--features custom-godot'
253+
242254
runs-on: ubuntu-latest
243255
steps:
244256
- uses: actions/checkout@v2
245-
- name: Install Rust
246-
uses: ./.github/composite/rust
257+
- name: "Run Godot integration test"
258+
uses: ./.github/composite/godot
247259
with:
248-
rust: ${{ matrix.rust.toolchain }}
249-
- name: Check cache for installed Godot version
250-
id: cache-godot
251-
uses: actions/cache@v2
252-
with:
253-
path: ${{ runner.temp }}/godot_bin
254-
key: godot-${{ runner.os }}-v${{ env.GODOT_VER }}-${{ env.GODOT_REL }}
255-
- name: Install Godot
256-
if: steps.cache-godot.outputs.cache-hit != 'true'
257-
run: |
258-
wget "https://downloads.tuxfamily.org/godotengine/$GODOT_VER/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64.zip" -O /tmp/godot.zip
259-
unzip /tmp/godot.zip -d ${{ runner.temp }}/godot_bin
260-
- name: Build godot-rust
261-
run: |
262-
cd test;
263-
cargo build;
264-
- name: Run Godot integration tests
265-
run: |
266-
cd test;
267-
mkdir -p ./project/lib;
268-
cp ../target/debug/libgdnative_test.so ./project/lib/;
269-
"${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
270-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
271-
exit 1;
272-
fi;
273-
"${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
274-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
275-
exit 1;
276-
fi;
277-
cargo build --features=type_tag_fallback;
278-
mkdir -p ./project/lib;
279-
cp ../target/debug/libgdnative_test.so ./project/lib/;
280-
"${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" --path ./project/ > >(tee "${{ runner.temp }}/stdout.log");
281-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
282-
exit 1;
283-
fi;
284-
"${{ runner.temp }}/godot_bin/Godot_v${GODOT_VER}-${GODOT_REL}_linux_headless.64" -e --path ./project/ --run-editor-tests > >(tee "${{ runner.temp }}/stdout.log");
285-
if grep -q "Leaked instance" "${{ runner.temp }}/stdout.log"; then
286-
exit 1;
287-
fi;
288-
260+
rust_toolchain: ${{ matrix.rust }}
261+
rust_extra_args: ${{ matrix.build_args }}
262+
godot_ver: ${{ matrix.godot }}
263+
264+
289265
# This job doesn't actually test anything, but is used to tell bors that the build completed,
290266
# as there is no practical way to detect when a workflow is successful, listening to webhooks only.
291267
# The ID (not name) of this job is the one referenced in bors.toml.
@@ -303,5 +279,5 @@ jobs:
303279
- build-android
304280
runs-on: ubuntu-latest
305281
steps:
306-
- name: Mark the job as a success
282+
- name: "Mark the job as a success"
307283
run: exit 0

0 commit comments

Comments
 (0)