Skip to content

Commit 627d408

Browse files
bors[bot]lilizoeyBromeon
authored
Merge #288
288: Run CI against stable Godot runtime r=Bromeon a=Bromeon Adds CI jobs that **run** against stable release of the last Godot minor version (here 4.0.3). This distinction is important, as we have two dimensions of Godot versions now: * **GDExtension API** -- this is the version of the GDExtension API against which gdext is _compiled_. * **Runtime** -- this is the version of the Godot binary under which gdext _runs_. By default, most jobs include latest Godot nightly version (so that is not explicitly annotated in the names). `-nightly` means that a nightly _API_ version is used. `stableRt` means stable _runtime_ (the new jobs). Includes #285 as a base, as that is required to fix failing jobs with Godot 4.0.3 stable. Runs only clang memchecks for now; the gcc ones don't add that much, and we already have a huge number of jobs now. We may reduce this over time. Co-authored-by: Lili Zoey <[email protected]> Co-authored-by: Jan Haller <[email protected]>
2 parents 7dbd80f + 27a3a7f commit 627d408

File tree

22 files changed

+274
-74
lines changed

22 files changed

+274
-74
lines changed

.github/composite/godot-install/action.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ runs:
3737
# shell: bash
3838

3939
- name: "Download Godot artifact"
40+
env:
41+
ARTIFACT_NAME: ${{ inputs.artifact-name }}
4042
# if: steps.cache-godot.outputs.cache-hit != 'true'
4143
# If a specific Godot revision should be used, rather than latest, use this:
4244
# curl https://nightly.link/Bromeon/godot4-nightly/actions/runs/4910907653/${{ inputs.artifact-name }}.zip \
4345
run: |
44-
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/${{ inputs.artifact-name }}.zip \
45-
-Lo artifact.zip \
46-
--retry 3
46+
if [[ $ARTIFACT_NAME == *"stable"* ]]; then
47+
url="https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot-stable/master/$ARTIFACT_NAME.zip"
48+
else
49+
url="https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot-nightly/master/$ARTIFACT_NAME.zip"
50+
fi
51+
52+
curl "$url" -Lo artifact.zip --retry 3
4753
unzip artifact.zip -d $RUNNER_DIR/godot_bin
4854
shell: bash
4955

.github/workflows/full-ci.yml

+46-31
Original file line numberDiff line numberDiff line change
@@ -123,47 +123,64 @@ jobs:
123123
strategy:
124124
fail-fast: false # cancel all jobs as soon as one fails?
125125
matrix:
126+
# Naming: {os}[-{runtimeVersion}]-{apiVersion}
127+
# runtimeVersion = version of Godot binary; apiVersion = version of GDExtension API against which gdext is compiled.
128+
126129
# Order this way because macOS typically has the longest duration, followed by Windows, so it benefits total workflow execution time.
127130
# Additionally, the 'linux (msrv *)' special case will then be listed next to the other 'linux' jobs.
128131
# Note: Windows uses '--target x86_64-pc-windows-msvc' by default as Cargo argument.
129132
include:
130133
# macOS
131134

135+
- name: macos-stableRt-4.0.3
136+
os: macos-12
137+
artifact-name: macos-stable
138+
godot-binary: godot.macos.editor.dev.x86_64
139+
godot-prebuilt-patch: '4.0.3'
140+
132141
- name: macos-4.0.3
133142
os: macos-12
134-
artifact-name: macos
143+
artifact-name: macos-nightly
135144
godot-binary: godot.macos.editor.dev.x86_64
136145
godot-prebuilt-patch: '4.0.3'
137146

138147
- name: macos-double
139148
os: macos-12
149+
artifact-name: macos-double-nightly
140150
godot-binary: godot.macos.editor.dev.double.x86_64
141151
rust-extra-args: --features godot/double-precision
142152

143153
- name: macos-nightly
144154
os: macos-12
145-
artifact-name: macos
155+
artifact-name: macos-nightly
146156
godot-binary: godot.macos.editor.dev.x86_64
147157
rust-extra-args: --features godot/custom-godot
148158
with-llvm: true
149159
godot-prebuilt-patch: '4.1'
150160

151161
# Windows
152162

163+
- name: windows-stableRt-4.0.3
164+
os: windows-latest
165+
artifact-name: windows-stable
166+
godot-binary: godot.windows.editor.dev.x86_64.exe
167+
godot-prebuilt-patch: '4.0.3'
168+
153169
- name: windows-4.0.3
154170
os: windows-latest
155-
artifact-name: windows
171+
artifact-name: windows-nightly
156172
godot-binary: godot.windows.editor.dev.x86_64.exe
157173
godot-prebuilt-patch: '4.0.3'
158174

159175
- name: windows-double
160176
os: windows-latest
177+
artifact-name: windows-double-nightly
161178
godot-binary: godot.windows.editor.dev.double.x86_64.exe
162179
rust-extra-args: --features godot/double-precision
163180

164181
- name: windows-nightly
165182
os: windows-latest
166-
artifact-name: windows
183+
artifact-name: windows-nightly
167184
godot-binary: godot.windows.editor.dev.x86_64.exe
168185
rust-extra-args: --features godot/custom-godot
169186
godot-prebuilt-patch: '4.1'
@@ -172,44 +189,50 @@ jobs:
172189

173190
# Don't use latest Ubuntu (22.04) as it breaks lots of ecosystem compatibility.
174191
# If ever moving to ubuntu-latest, need to manually install libtinfo5 for LLVM.
192+
- name: linux-stableRt-4.0.3
193+
os: ubuntu-20.04
194+
artifact-name: linux-stable
195+
godot-binary: godot.linuxbsd.editor.dev.x86_64
196+
175197
- name: linux-4.0.3
176198
os: ubuntu-20.04
177-
artifact-name: linux
199+
artifact-name: linux-nightly
178200
godot-binary: godot.linuxbsd.editor.dev.x86_64
179201
godot-check-header: false # disabled for now
180202

181203
- name: linux-4.0.2
182204
os: ubuntu-20.04
183-
artifact-name: linux
205+
artifact-name: linux-nightly
184206
godot-binary: godot.linuxbsd.editor.dev.x86_64
185207
godot-prebuilt-patch: '4.0.2'
186208

187209
- name: linux-4.0.1
188210
os: ubuntu-20.04
189-
artifact-name: linux
211+
artifact-name: linux-nightly
190212
godot-binary: godot.linuxbsd.editor.dev.x86_64
191213
godot-prebuilt-patch: '4.0.1'
192214

193215
- name: linux-4.0
194216
os: ubuntu-20.04
195-
artifact-name: linux
217+
artifact-name: linux-nightly
196218
godot-binary: godot.linuxbsd.editor.dev.x86_64
197219
godot-prebuilt-patch: '4.0'
198220

199221
- name: linux-double
200222
os: ubuntu-20.04
223+
artifact-name: linux-double-nightly
201224
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
202225
rust-extra-args: --features godot/double-precision
203226

204227
- name: linux-features
205228
os: ubuntu-20.04
206-
artifact-name: linux
229+
artifact-name: linux-nightly
207230
godot-binary: godot.linuxbsd.editor.dev.x86_64
208231
rust-extra-args: --features godot/threads,godot/serde
209232

210233
- name: linux-nightly
211234
os: ubuntu-20.04
212-
artifact-name: linux
235+
artifact-name: linux-nightly
213236
godot-binary: godot.linuxbsd.editor.dev.x86_64
214237
rust-extra-args: --features godot/custom-godot
215238
godot-prebuilt-patch: '4.1'
@@ -220,35 +243,27 @@ jobs:
220243
# The gcc version can possibly be removed later, as it is slower and needs a larger artifact than the clang one.
221244

222245
# --disallow-focus: fail if #[itest(focus)] is encountered, to prevent running only a few tests for full CI
223-
- name: linux-memcheck-gcc-4.0.3
224-
os: ubuntu-20.04
225-
artifact-name: linux-memcheck-gcc
226-
godot-binary: godot.linuxbsd.editor.dev.x86_64.san
227-
godot-args: -- --disallow-focus
228-
rust-toolchain: nightly
229-
rust-env-rustflags: -Zrandomize-layout
230246

231-
- name: linux-memcheck-clang-4.0.3
247+
- name: linux-memcheck-stableRt-4.0.3
232248
os: ubuntu-20.04
233-
artifact-name: linux-memcheck-clang
249+
artifact-name: linux-memcheck-clang-stable
234250
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
235251
godot-args: -- --disallow-focus
236252
rust-toolchain: nightly
237253
rust-env-rustflags: -Zrandomize-layout
238254

239-
- name: linux-memcheck-gcc-nightly
240-
os: ubuntu-20.04
241-
artifact-name: linux-memcheck-gcc
242-
godot-binary: godot.linuxbsd.editor.dev.x86_64.san
243-
godot-args: -- --disallow-focus
244-
rust-toolchain: nightly
245-
rust-env-rustflags: -Zrandomize-layout
246-
rust-extra-args: --features godot/custom-godot
247-
godot-prebuilt-patch: '4.1'
255+
# FIXME(#298): memory leaks detected when running 4.0.3 API with 4.1+ binary
256+
# - name: linux-memcheck-4.0.3
257+
# os: ubuntu-20.04
258+
# artifact-name: linux-memcheck-clang-nightly
259+
# godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
260+
# godot-args: -- --disallow-focus
261+
# rust-toolchain: nightly
262+
# rust-env-rustflags: -Zrandomize-layout
248263

249-
- name: linux-memcheck-clang-nightly
264+
- name: linux-memcheck-nightly
250265
os: ubuntu-20.04
251-
artifact-name: linux-memcheck-clang
266+
artifact-name: linux-memcheck-clang-nightly
252267
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
253268
godot-args: -- --disallow-focus
254269
rust-toolchain: nightly
@@ -263,7 +278,7 @@ jobs:
263278
- name: "Run Godot integration test"
264279
uses: ./.github/composite/godot-itest
265280
with:
266-
artifact-name: godot-${{ matrix.artifact-name || matrix.name }}
281+
artifact-name: godot-${{ matrix.artifact-name }}
267282
godot-binary: ${{ matrix.godot-binary }}
268283
godot-args: ${{ matrix.godot-args }}
269284
godot-prebuilt-patch: ${{ matrix.godot-prebuilt-patch }}

.github/workflows/minimal-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
- name: "Run Godot integration test"
8787
uses: ./.github/composite/godot-itest
8888
with:
89-
artifact-name: godot-linux
89+
artifact-name: godot-linux-nightly
9090
godot-binary: godot.linuxbsd.editor.dev.x86_64
9191

9292

godot-bindings/src/godot_exe.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
//! Commands related to Godot executable
88
9-
use crate::custom::godot_version::GodotVersion;
109
use crate::godot_version::parse_godot_version;
1110
use crate::header_gen::generate_rust_binding;
1211
use crate::watch::StopWatch;
12+
use crate::GodotVersion;
1313

1414
use regex::Regex;
1515
use std::fs;
@@ -99,7 +99,7 @@ fn update_version_file(version: &str) {
9999
}
100100
*/
101101

102-
fn read_godot_version(godot_bin: &Path) -> GodotVersion {
102+
pub(crate) fn read_godot_version(godot_bin: &Path) -> GodotVersion {
103103
let output = Command::new(godot_bin)
104104
.arg("--version")
105105
.output()
@@ -259,7 +259,7 @@ fn polyfill_legacy_header(c: &mut String) {
259259
);
260260
}
261261

262-
fn locate_godot_binary() -> PathBuf {
262+
pub(crate) fn locate_godot_binary() -> PathBuf {
263263
if let Ok(string) = std::env::var("GODOT4_BIN") {
264264
println!("Found GODOT4_BIN with path to executable: '{string}'");
265265
println!("cargo:rerun-if-env-changed=GODOT4_BIN");

godot-bindings/src/godot_version.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,11 @@
66

77
//#![allow(unused_variables, dead_code)]
88

9+
use crate::GodotVersion;
910
use regex::{Captures, Regex};
1011
use std::error::Error;
1112
use std::str::FromStr;
1213

13-
#[derive(Debug, Eq, PartialEq)]
14-
pub struct GodotVersion {
15-
/// the original string (trimmed, stripped of text around)
16-
pub full_string: String,
17-
18-
pub major: u8,
19-
pub minor: u8,
20-
21-
/// 0 if none
22-
pub patch: u8,
23-
24-
/// alpha|beta|dev|stable
25-
pub status: String,
26-
27-
/// Git revision 'custom_build.{rev}' or '{official}.rev', if available
28-
pub custom_rev: Option<String>,
29-
}
30-
3114
pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Error>> {
3215
// Format of the string emitted by `godot --version`:
3316
// https://github.com/godot-rust/gdext/issues/118#issuecomment-1465748123

godot-bindings/src/lib.rs

+59
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ compile_error!(
1717
"At least one of `custom-godot` or `prebuilt-godot` must be specified (none given)."
1818
);
1919

20+
// This is outside of `godot_version` to allow us to use it even when we don't have the `custom-godot`
21+
// feature enabled.
22+
#[derive(Debug, Eq, PartialEq)]
23+
pub struct GodotVersion {
24+
/// the original string (trimmed, stripped of text around)
25+
pub full_string: String,
26+
27+
pub major: u8,
28+
pub minor: u8,
29+
30+
/// 0 if none
31+
pub patch: u8,
32+
33+
/// alpha|beta|dev|stable
34+
pub status: String,
35+
36+
/// Git revision 'custom_build.{rev}' or '{official}.rev', if available
37+
pub custom_rev: Option<String>,
38+
}
39+
2040
// ----------------------------------------------------------------------------------------------------------------------------------------------
2141
// Regenerate all files
2242

@@ -41,6 +61,10 @@ mod custom {
4161
pub fn write_gdextension_headers_from_c(h_path: &Path, rs_path: &Path, watch: &mut StopWatch) {
4262
godot_exe::write_gdextension_headers(h_path, rs_path, true, watch);
4363
}
64+
65+
pub(crate) fn get_godot_version() -> GodotVersion {
66+
godot_exe::read_godot_version(&godot_exe::locate_godot_binary())
67+
}
4468
}
4569

4670
#[cfg(feature = "custom-godot")]
@@ -70,6 +94,23 @@ mod prebuilt {
7094
.unwrap_or_else(|e| panic!("failed to write gdextension_interface.rs: {e}"));
7195
watch.record("write_header_rs");
7296
}
97+
98+
pub(crate) fn get_godot_version() -> GodotVersion {
99+
let version: Vec<&str> = godot4_prebuilt::GODOT_VERSION
100+
.split('.')
101+
.collect::<Vec<_>>();
102+
GodotVersion {
103+
full_string: godot4_prebuilt::GODOT_VERSION.into(),
104+
major: version[0].parse().unwrap(),
105+
minor: version[1].parse().unwrap(),
106+
patch: version
107+
.get(2)
108+
.and_then(|patch| patch.parse().ok())
109+
.unwrap_or(0),
110+
status: "stable".into(),
111+
custom_rev: None,
112+
}
113+
}
73114
}
74115

75116
#[cfg(not(feature = "custom-godot"))]
@@ -85,3 +126,21 @@ pub fn clear_dir(dir: &Path, watch: &mut StopWatch) {
85126
}
86127
std::fs::create_dir_all(dir).unwrap_or_else(|e| panic!("failed to create dir: {e}"));
87128
}
129+
130+
pub fn emit_godot_version_cfg() {
131+
let GodotVersion {
132+
major,
133+
minor,
134+
patch,
135+
..
136+
} = get_godot_version();
137+
138+
println!(r#"cargo:rustc-cfg=gdextension_api="{major}.{minor}""#);
139+
140+
// Godot drops the patch version if it is 0.
141+
if patch != 0 {
142+
println!(r#"cargo:rustc-cfg=gdextension_exact_api="{major}.{minor}.{patch}""#);
143+
} else {
144+
println!(r#"cargo:rustc-cfg=gdextension_exact_api="{major}.{minor}""#);
145+
}
146+
}

godot-codegen/src/central_generator.rs

+9
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ fn make_build_config(header: &Header) -> TokenStream {
272272
String::from_utf8_lossy(c_str.to_bytes()).to_string()
273273
}
274274
}
275+
276+
/// Version of the Godot engine which loaded gdext via GDExtension binding, as
277+
/// `(major, minor, patch)` triple.
278+
pub fn godot_runtime_version_triple() -> (u8, u8, u8) {
279+
let version = unsafe {
280+
crate::runtime_metadata().godot_version
281+
};
282+
(version.major as u8, version.minor as u8, version.patch as u8)
283+
}
275284
}
276285
}
277286
}

godot-core/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ godot = { path = "../godot" }
2929
serde_json = "1.0"
3030

3131
[build-dependencies]
32+
godot-bindings = { path = "../godot-bindings" }
3233
godot-codegen = { path = "../godot-codegen" }

godot-core/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ fn main() {
1717

1818
godot_codegen::generate_core_files(gen_path);
1919
println!("cargo:rerun-if-changed=build.rs");
20+
21+
godot_bindings::emit_godot_version_cfg();
2022
}

godot-core/src/builtin/array.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ impl<T: VariantMetadata> FromVariant for Array<T> {
717717
}
718718

719719
let array = unsafe {
720-
Self::from_sys_init(|self_ptr| {
720+
sys::from_sys_init_or_init_default::<Self>(|self_ptr| {
721721
let array_from_variant = sys::builtin_fn!(array_from_variant);
722722
array_from_variant(self_ptr, variant.var_sys());
723723
})

0 commit comments

Comments
 (0)