Skip to content

Commit 46b151f

Browse files
authored
Build against all API versions (#60)
1 parent 151d377 commit 46b151f

File tree

3 files changed

+79
-13
lines changed

3 files changed

+79
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
runs-on: "ubuntu-22.04"
1818
env:
1919
RUSTFLAGS: "-D warnings"
20+
strategy:
21+
matrix:
22+
api_version: ["4-1", "4-2", "4-3"]
2023

2124
steps:
2225
- name: Checkout
@@ -30,19 +33,11 @@ jobs:
3033
- name: Build Debug
3134
run: |
3235
set -o pipefail
33-
cargo build --workspace --all-features --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
34-
- name: Build Debug Runtime
35-
run: |
36-
set -o pipefail
37-
cargo build -p godot-rust-script --features "runtime" --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
38-
- name: Build Debug Scripts
39-
run: |
40-
set -o pipefail
41-
cargo build -p godot-rust-script --features "scripts" --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
36+
cargo build --workspace --features "godot/api-${{ matrix.api_version}}" --all-features --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
4237
- name: Build Release
4338
run: |
4439
set -o pipefail
45-
cargo build --release --workspace --all-features --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
40+
cargo build --release --workspace --features "godot/api-${{ matrix.api_version}}" --all-features --message-format json | clippy-sarif | tee rust-build-results.sarif | sarif-fmt
4641
- name: Upload Results
4742
uses: github/codeql-action/upload-sarif@v2
4843
if: ${{ always() }}
@@ -52,6 +47,9 @@ jobs:
5247

5348
clippy:
5449
runs-on: "ubuntu-22.04"
50+
strategy:
51+
matrix:
52+
api_version: ["4-1", "4-2", "4-3"]
5553

5654
steps:
5755
- name: Checkout
@@ -65,27 +63,49 @@ jobs:
6563
- name: Checks
6664
run: |
6765
set -o pipefail
68-
cargo clippy --message-format json --workspace --all-features -- -D warnings | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
66+
cargo clippy --message-format json --workspace --all-features --features "godot/api-${{ matrix.api_version}}" -- -D warnings | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
6967
- name: Upload Results
70-
uses: github/codeql-action/upload-sarif@v2
68+
uses: github/codeql-action/upload-sarif@v3
7169
if: ${{ always() }}
7270
with:
7371
sarif_file: rust-clippy-results.sarif
7472
wait-for-processing: true
7573

7674
tests:
7775
runs-on: "ubuntu-22.04"
76+
strategy:
77+
matrix:
78+
api_version: ["4-1", "4-2", "4-3", "custom"]
7879

7980
steps:
8081
- name: Checkout
8182
uses: actions/checkout@v3
83+
8284
- name: Setup Cache
8385
uses: Swatinem/rust-cache@v2
8486
with:
8587
cache-on-failure: true
88+
89+
- name: Install ENV
90+
run: |
91+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
92+
brew install nushell
93+
94+
- name: Download Godot Prerelease
95+
id: prerelease_setup
96+
if: ${{ matrix.api_version == 'custom' }}
97+
run: |
98+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
99+
brew install llvm
100+
GODOT4_BIN="$(./download_godot_dev.nu)"
101+
echo "godot4_bin=$GODOT4_BIN" >> "$GITHUB_OUTPUT"
102+
86103
- name: Tests
104+
env:
105+
LLVM_PATH: "/home/linuxbrew/.linuxbrew/opt/llvm/bin"
106+
GODOT4_BIN: ${{ steps.prerelease_setup.outputs.godot4_bin }}
87107
run: |
88-
cargo test
108+
cargo test --features "godot/api-${{ matrix.api_version}}"
89109
90110
license:
91111
runs-on: "ubuntu-22.04"

download_godot_dev.nu

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env nu
2+
3+
const GODOT_BUILDS = "godotengine/godot-builds"
4+
5+
let tmp_dir = mktemp -d
6+
let godot_dev_dir = $"($tmp_dir)/godot_dev"
7+
let godot_dev_zip = $"($godot_dev_dir).zip"
8+
9+
print -e $"fetching releases from ($GODOT_BUILDS)..."
10+
let asset = http get $"https://api.github.com/repos/($GODOT_BUILDS)/releases"
11+
| filter {|item| $item.tag_name | str starts-with "4." }
12+
| get 0.assets
13+
| filter {|item| $item.name | str contains "linux.x86_64" }
14+
| get 0
15+
16+
print -e $"downloading prebuilt prerelease from ($asset.browser_download_url)..."
17+
http get $asset.browser_download_url
18+
| save $godot_dev_zip
19+
20+
print -e "extracting zip archive..."
21+
unzip -q -d $godot_dev_dir $godot_dev_zip
22+
23+
ls $godot_dev_dir | get 0.name | print

rust-script/src/static_script_registry.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use crate::runtime::GodotScriptObject;
2222
godot::sys::plugin_registry!(pub SCRIPT_REGISTRY: RegistryItem);
2323

2424
#[macro_export]
25+
#[cfg(before_api = "4.4")]
2526
macro_rules! register_script_class {
2627
($class_name:ty, $base_name:ty, $desc:expr, $props:expr, $signals:expr) => {
2728
$crate::private_export::plugin_add! {
@@ -43,6 +44,28 @@ macro_rules! register_script_class {
4344
};
4445
}
4546

47+
#[macro_export]
48+
#[cfg(since_api = "4.4")]
49+
macro_rules! register_script_class {
50+
($class_name:ty, $base_name:ty, $desc:expr, $props:expr, $signals:expr) => {
51+
$crate::private_export::plugin_add! {
52+
SCRIPT_REGISTRY in $crate::private_export;
53+
$crate::private_export::RegistryItem::Entry($crate::private_export::RustScriptEntry {
54+
class_name: stringify!($class_name),
55+
base_type_name: <$base_name as $crate::godot::prelude::GodotClass>::class_name().to_cow_str(),
56+
properties: || {
57+
$props
58+
},
59+
signals: || {
60+
$signals
61+
},
62+
create_data: $crate::private_export::create_default_data_struct::<$class_name>,
63+
description: $desc,
64+
})
65+
}
66+
};
67+
}
68+
4669
#[macro_export]
4770
macro_rules! register_script_methods {
4871
($class_name:ty, $methods:expr) => {

0 commit comments

Comments
 (0)