From b04cc3fa3fd4988a580dc651e5a947bf6f281ce7 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Thu, 12 Oct 2023 20:17:24 +0200 Subject: [PATCH] (undo) limit godot-itest to parse version --- .github/composite/godot-itest/action.yml | 77 +++++++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/.github/composite/godot-itest/action.yml b/.github/composite/godot-itest/action.yml index 14e7e73eb..db796d263 100644 --- a/.github/composite/godot-itest/action.yml +++ b/.github/composite/godot-itest/action.yml @@ -72,11 +72,82 @@ runs: - name: "Inspect Godot version" run: | godotVer=$($GODOT4_BIN --version | xargs) - echo ":heavy_check_mark: Version \`$godotVer\`" >> $GITHUB_STEP_SUMMARY + gitSha=$(echo $godotVer | sed -E "s/.+custom_build\.//") + echo "GODOT_BUILT_FROM=_Built from [\`$godotVer\`](https://github.com/godotengine/godot/commit/$gitSha)._" >> $GITHUB_ENV + shell: bash + + - name: "Install Rust" + uses: ./.github/composite/rust + with: + rust: ${{ inputs.rust-toolchain }} + with-llvm: ${{ inputs.with-llvm }} + + - name: "Patch prebuilt version ({{ inputs.godot-prebuilt-patch }})" + if: inputs.godot-prebuilt-patch != '' + env: + VERSION: ${{ inputs.godot-prebuilt-patch }} + # sed -i'' needed for macOS compatibility, see https://stackoverflow.com/q/4247068 + run: | + echo "Patch prebuilt version to $VERSION..." + + # Reduce version to "major.minor" format + apiVersion=$(echo $VERSION | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/') + + # For newer versions, update the compatibility_minimum in .gdextension files to the respective version. + # Nothing needs to be done for 4.0.x, as compatibility_minimum didn't exist back then. + if [[ "$apiVersion" == "4.2" ]]; then + echo "Update compatibility_minimum in .gdextension files to '$apiVersion'..." + dirs=("itest" "examples") + for dir in "${dirs[@]}"; do + find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' 's/compatibility_minimum = 4\.1/compatibility_minimum = $apiVersion/' {} + + done + + # Apply Cargo.toml patch for godot4-prebuilt crate + else + # Patch only needed if version is not already set + if grep -E 'godot4-prebuilt = { .+ branch = "$VERSION" }' godot-bindings/Cargo.toml; then + echo "Already has version $version; no need for patch." + else + cat << HEREDOC >> Cargo.toml + [patch."https://github.com/godot-rust/godot4-prebuilt"] + godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "$VERSION" } + HEREDOC + echo "Patched Cargo.toml for version $version." + fi + fi + + shell: bash + + # else + - name: "No patch selected" + if: inputs.godot-prebuilt-patch == '' + run: | + echo "No patch selected; use default godot4-prebuilt version." + shell: bash + + - name: "Build gdext (itest)" + env: + RUSTFLAGS: ${{ inputs.rust-env-rustflags }} + TARGET: ${{ inputs.rust-target }} + run: | + cargo build -p godot-ffi ${{ inputs.rust-extra-args }} $targetArgs + echo "OUTCOME=success" >> $GITHUB_ENV shell: bash - name: "Conclusion" - if: failure() + if: always() run: | - echo ":x: Failed to get version" >> $GITHUB_STEP_SUMMARY + echo "Evaluate conclusion: $OUTCOME" + + case $OUTCOME in + "success") + # Do not output success for now, to keep summary focused on warnings/errors + #echo "### :heavy_check_mark: $GODOT_BUILT_FROM" > $GITHUB_STEP_SUMMARY + ;; + + *) + echo "### :x: Build failed" > $GITHUB_STEP_SUMMARY + exit 5 + ;; + esac shell: bash