Skip to content

Commit 77e3b95

Browse files
authored
Merge pull request #520 from godot-rust/qol/test-nightly-prebuilt
Use nightly godot4-prebuilt for unit-test and clippy
2 parents cc382c3 + 07b8662 commit 77e3b95

File tree

5 files changed

+80
-35
lines changed

5 files changed

+80
-35
lines changed

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

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,35 +86,46 @@ runs:
8686
- name: "Patch prebuilt version ({{ inputs.godot-prebuilt-patch }})"
8787
if: inputs.godot-prebuilt-patch != ''
8888
env:
89-
VERSION: ${{ inputs.godot-prebuilt-patch }}
89+
PATCHED_VERSION: ${{ inputs.godot-prebuilt-patch }}
9090
# sed -i'' needed for macOS compatibility, see https://stackoverflow.com/q/4247068
9191
run: |
92-
echo "Patch prebuilt version to $VERSION..."
92+
# Find the godot4-prebuilt version that gdext currently depends on.
93+
defaultVersion=$(grep 'godot4-prebuilt = {' godot-bindings/Cargo.toml | sed -n 's/.*branch = "\([^"]*\)".*/\1/p')
94+
if [ -z "$defaultVersion" ]; then
95+
echo "::error::prebuilt version not found or format is incorrect."
96+
exit 1
97+
else
98+
echo "Default prebuilt version: $defaultVersion"
99+
fi
100+
101+
# Apply [patch] for godot4-prebuilt crate if needed.
102+
if [[ "$PATCHED_VERSION" != $defaultVersion ]]; then
103+
.github/other/patch-prebuilt.sh "$PATCHED_VERSION"
104+
fi
93105
94-
# Reduce version to "major.minor" format
95-
apiVersion=$(echo $VERSION | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
106+
# Reduce versions to "major.minor" format.
107+
apiVersion=$(echo "$PATCHED_VERSION" | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
108+
apiDefaultVersion=$(echo "$defaultVersion" | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
96109
97-
# For newer versions, update the compatibility_minimum in .gdextension files to the respective version.
98-
# Nothing needs to be done for 4.0.x, as compatibility_minimum didn't exist back then.
99-
if [[ "$apiVersion" == "4.2" ]]; then
110+
# For newer versions, update 'compatibility_minimum' in .gdextension files to the respective version.
111+
# Nothing needs to be done for 4.0.x, as compatibility_minimum didn't exist back then (we do it due to easier code, anyway).
112+
if [[ "$apiVersion" == "$apiDefaultVersion" ]]; then
113+
echo "Already has version $version; no need to change compatibility_minimum."
114+
115+
else
100116
echo "Update compatibility_minimum in .gdextension files to '$apiVersion'..."
101117
dirs=("itest" "examples")
118+
119+
# Note that this is still hardcoded to 4.1, the start of GDExtension's compatibility promise. This makes it easier for users
120+
# to use gdext with older Godot versions. There is anyway a runtime check in gdext that checks compatibility again.
102121
for dir in "${dirs[@]}"; do
103-
find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' 's/compatibility_minimum = 4\.1/compatibility_minimum = $apiVersion/' {} +
122+
find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' "s/compatibility_minimum = 4\.1/compatibility_minimum = $apiVersion/" {} +
104123
done
105124
106-
# Apply Cargo.toml patch for godot4-prebuilt crate
107-
else
108-
# Patch only needed if version is not already set
109-
if grep -E 'godot4-prebuilt = { .+ branch = "$VERSION" }' godot-bindings/Cargo.toml; then
110-
echo "Already has version $version; no need for patch."
111-
else
112-
cat << HEREDOC >> Cargo.toml
113-
[patch."https://github.com/godot-rust/godot4-prebuilt"]
114-
godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "$VERSION" }
115-
HEREDOC
116-
echo "Patched Cargo.toml for version $version."
117-
fi
125+
echo "Example output: itest/godot/itest.gdextension"
126+
echo "----------------------------------------------------"
127+
cat itest/godot/itest.gdextension
128+
echo "----------------------------------------------------"
118129
fi
119130
120131
shell: bash

.github/other/patch-prebuilt.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Copyright (c) godot-rust; Bromeon and contributors.
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
6+
7+
# Sets up a patch in Cargo.toml to use godot4-prebuilt artifacts.
8+
# Input: $version
9+
10+
version="$1"
11+
12+
cat << HEREDOC >> Cargo.toml
13+
[patch."https://github.com/godot-rust/godot4-prebuilt"]
14+
godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "$version" }
15+
HEREDOC
16+
17+
echo "Patched Cargo.toml for version $version."

.github/workflows/full-ci.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
rustfmt:
3636
runs-on: ubuntu-20.04
3737
steps:
38-
- uses: actions/checkout@v3
38+
- uses: actions/checkout@v4
3939

4040
- name: "Install Rust"
4141
uses: ./.github/composite/rust
@@ -50,7 +50,10 @@ jobs:
5050
doc-lints:
5151
runs-on: ubuntu-20.04
5252
steps:
53-
- uses: actions/checkout@v3
53+
- uses: actions/checkout@v4
54+
55+
- name: "Patch Cargo.toml to use nightly extension API"
56+
run: .github/other/patch-prebuilt.sh nightly
5457

5558
- name: "Install Rust"
5659
uses: ./.github/composite/rust
@@ -68,7 +71,10 @@ jobs:
6871
clippy:
6972
runs-on: ubuntu-20.04
7073
steps:
71-
- uses: actions/checkout@v3
74+
- uses: actions/checkout@v4
75+
76+
- name: "Patch Cargo.toml to use nightly extension API"
77+
run: .github/other/patch-prebuilt.sh nightly
7278

7379
- name: "Install Rust"
7480
uses: ./.github/composite/rust
@@ -122,7 +128,12 @@ jobs:
122128
rust-special: -msrv
123129

124130
steps:
125-
- uses: actions/checkout@v3
131+
- uses: actions/checkout@v4
132+
133+
- name: "Patch Cargo.toml to use nightly extension API"
134+
# Only on Linux because godot4-prebuilt/nightly branch doesn't have artifacts for other platforms.
135+
if: matrix.name == 'linux' && matrix.rust-special == ''
136+
run: .github/other/patch-prebuilt.sh nightly
126137

127138
- name: "Install Rust"
128139
uses: ./.github/composite/rust
@@ -297,7 +308,7 @@ jobs:
297308
rust-target: x86_64-unknown-linux-gnu
298309

299310
steps:
300-
- uses: actions/checkout@v3
311+
- uses: actions/checkout@v4
301312

302313
- name: "Run Godot integration test"
303314
uses: ./.github/composite/godot-itest
@@ -317,10 +328,10 @@ jobs:
317328
license-guard:
318329
runs-on: ubuntu-20.04
319330
steps:
320-
- uses: actions/checkout@v3
331+
- uses: actions/checkout@v4
321332

322333
- name: "Check license headers"
323-
uses: apache/skywalking-eyes/header@v0.4.0
334+
uses: apache/skywalking-eyes/header@v0.5.0
324335
with:
325336
# log: debug # optional: set the log level. The default value is `info`.
326337
config: .github/other/licenserc.yml

.github/workflows/minimal-ci.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
rustfmt:
4242
runs-on: ubuntu-20.04
4343
steps:
44-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v4
4545

4646
- name: "Install Rust"
4747
uses: ./.github/composite/rust
@@ -57,7 +57,7 @@ jobs:
5757
doc-lints:
5858
runs-on: ubuntu-20.04
5959
steps:
60-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
6161

6262
- name: "Install Rust"
6363
uses: ./.github/composite/rust
@@ -75,7 +75,10 @@ jobs:
7575
clippy:
7676
runs-on: ubuntu-20.04
7777
steps:
78-
- uses: actions/checkout@v3
78+
- uses: actions/checkout@v4
79+
80+
- name: "Patch Cargo.toml to use nightly extension API"
81+
run: .github/other/patch-prebuilt.sh nightly
7982

8083
- name: "Install Rust"
8184
uses: ./.github/composite/rust
@@ -99,7 +102,10 @@ jobs:
99102
name: unit-test
100103
runs-on: ubuntu-20.04
101104
steps:
102-
- uses: actions/checkout@v3
105+
- uses: actions/checkout@v4
106+
107+
- name: "Patch Cargo.toml to use nightly extension API"
108+
run: .github/other/patch-prebuilt.sh nightly
103109

104110
- name: "Install Rust"
105111
uses: ./.github/composite/rust
@@ -196,7 +202,7 @@ jobs:
196202
rust-target: x86_64-unknown-linux-gnu
197203

198204
steps:
199-
- uses: actions/checkout@v3
205+
- uses: actions/checkout@v4
200206

201207
- name: "Run Godot integration test"
202208
uses: ./.github/composite/godot-itest
@@ -216,10 +222,10 @@ jobs:
216222
license-guard:
217223
runs-on: ubuntu-20.04
218224
steps:
219-
- uses: actions/checkout@v3
225+
- uses: actions/checkout@v4
220226

221227
- name: "Check and fix license headers"
222-
uses: apache/skywalking-eyes/header@v0.4.0
228+
uses: apache/skywalking-eyes/header@v0.5.0
223229
with:
224230
# log: debug # optional: set the log level. The default value is `info`.
225231
config: .github/other/licenserc.yml

.github/workflows/update-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
# Checkout is always needed, for the notify step
2626
- name: "Checkout"
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
# This is just a sanity check to make sure that the follow-up docs generation doesn't break.
3030
# So we use the Rust version provided by the GitHub runners, which hopefully is >= MSRV.

0 commit comments

Comments
 (0)