Skip to content

Commit 4179fb4

Browse files
authored
Merge pull request #449 from godot-rust/bugfix/macos-ci
CI: update LLVM from 10.0 to 15.0.7 -> fix spurious macOS failures
2 parents 41ce77f + f024019 commit 4179fb4

File tree

2 files changed

+29
-37
lines changed

2 files changed

+29
-37
lines changed

.github/composite/llvm/action.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
name: llvm
66
description: "Install LLVM + Clang, with caching"
77

8-
#inputs:
9-
# llvm:
10-
# required: false
11-
# default: 'true'
12-
# description: "Whether LLVM should be installed ('true' by default)"
8+
inputs:
9+
llvm-version:
10+
required: false
11+
default: '15.0.7'
12+
description: "LLVM versions. Greater than 15 may not be supported in all runners."
1313

1414
runs:
1515
using: "composite"
@@ -31,12 +31,13 @@ runs:
3131
# C:/Program Files/LLVM
3232
# ./llvm
3333
path: ${{ env.LLVM_INSTALL_DIR }}
34-
key: llvm-10.0
34+
key: "llvm-${{ inputs.llvm-version }}"
3535

3636
- uses: KyleMayes/install-llvm-action@v1
3737
# if: inputs.llvm == 'true'
3838
with:
39-
version: "10.0"
39+
# Newer versions failed on macOS with "Unsupported target! (platform='darwin', version='17.0.2')"
40+
version: "${{ inputs.llvm-version }}"
4041
directory: ${{ env.LLVM_INSTALL_DIR }}
4142
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
4243

godot-bindings/src/godot_exe.rs

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,33 +100,26 @@ fn update_version_file(version: &str) {
100100
*/
101101

102102
pub(crate) fn read_godot_version(godot_bin: &Path) -> GodotVersion {
103-
let output = Command::new(godot_bin)
104-
.arg("--version")
105-
.output()
106-
.unwrap_or_else(|_| {
107-
panic!(
108-
"failed to invoke Godot executable '{}'",
109-
godot_bin.display()
110-
)
111-
});
103+
let mut cmd = Command::new(godot_bin);
104+
cmd.arg("--version");
112105

113-
let output = String::from_utf8(output.stdout).expect("convert Godot version to UTF-8");
114-
println!("Godot version: {output}");
106+
let output = execute(cmd, "read Godot version");
107+
let stdout = std::str::from_utf8(&output.stdout).expect("convert Godot version to UTF-8");
115108

116-
match parse_godot_version(&output) {
109+
match parse_godot_version(&stdout) {
117110
Ok(parsed) => {
118111
assert_eq!(
119112
parsed.major,
120113
4,
121114
"Only Godot versions >= 4.0 are supported; found version {}.",
122-
output.trim()
115+
stdout.trim()
123116
);
124117

125118
parsed
126119
}
127120
Err(e) => {
128121
// Don't treat this as fatal error
129-
panic!("failed to parse Godot version '{output}': {e}")
122+
panic!("failed to parse Godot version '{stdout}': {e}")
130123
}
131124
}
132125
}
@@ -275,27 +268,25 @@ pub(crate) fn locate_godot_binary() -> PathBuf {
275268
}
276269
}
277270

278-
fn execute(mut cmd: Command, error_message: &str) -> Output {
271+
fn execute(cmd: Command, error_message: &str) -> Output {
272+
try_execute(cmd, error_message).unwrap_or_else(|e| panic!("{}", e))
273+
}
274+
275+
fn try_execute(mut cmd: Command, error_message: &str) -> Result<Output, String> {
279276
let output = cmd
280277
.output()
281-
.unwrap_or_else(|_| panic!("failed to execute command: {error_message}"));
278+
.map_err(|_| format!("failed to invoke command ({error_message})\n\t{cmd:?}"))?;
279+
280+
println!("[stdout] {}", std::str::from_utf8(&output.stdout).unwrap());
281+
println!("[stderr] {}", std::str::from_utf8(&output.stderr).unwrap());
282+
println!("[status] {}", output.status);
282283

283284
if output.status.success() {
284-
println!(
285-
"[stdout] {}",
286-
String::from_utf8(output.stdout.clone()).unwrap()
287-
);
288-
println!(
289-
"[stderr] {}",
290-
String::from_utf8(output.stderr.clone()).unwrap()
291-
);
292-
println!("[status] {}", output.status);
293-
output
285+
Ok(output)
294286
} else {
295-
println!("[stdout] {}", String::from_utf8(output.stdout).unwrap());
296-
println!("[stderr] {}", String::from_utf8(output.stderr).unwrap());
297-
println!("[status] {}", output.status);
298-
panic!("command returned error: {error_message}");
287+
Err(format!(
288+
"command returned error ({error_message})\n\t{cmd:?}"
289+
))
299290
}
300291
}
301292

0 commit comments

Comments
 (0)