Files
redot-engine/misc/scripts/validate_extension_api.sh
Randolph W. Aarseth II d5fc3d1e8c Rebrand Godot to Redot
Add Linux Editor tests workflow matrix
Add Windows Editor w/ Mono workflow matrix
Add Generate Glue Code job to Windows workflow
Add Build GodotSharp job to Windows workflow

Add godot compatibility version references
Add Godot author info
Add Godot version compatibility info
Add Godot donor info
Add Godot authors and donors to editor_about.cpp

Credits:
Co-authored-by: Skogi <skogi.b@gmail.com>
Co-authored-by: Spartan322 <Megacake1234@gmail.com>
Co-authored-by: swashberry <swashdev@pm.me>
Co-authored-by: Christoffer Sundbom <christoffer_karlsson@live.se>
Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com>
Co-authored-by: McDubh <103212704+mcdubhghlas@users.noreply.github.com>
Co-authored-by: Dubhghlas McLaughlin <103212704+mcdubhghlas@users.noreply.github.com>
Co-authored-by: radenthefolf <radenthefolf@gmail.com>
Co-authored-by: John Knight <80524176+Tekisasu-JohnK@users.noreply.github.com>
Co-authored-by: Adam Vondersaar <adam.vondersaar@uphold.com>
Co-authored-by: decryptedchaos <nixgod@gmail.com>
Co-authored-by: zaftnotameni <122100803+zaftnotameni@users.noreply.github.com>
Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com>
Co-authored-by: wesam <108880473+wesamdev@users.noreply.github.com>
Co-authored-by: Mister Puma <MisterPuma80@gmail.com>
Co-authored-by: Aaron Benjamin <lifeartstudios@gmail.com>
Co-authored-by: SingleError <isaaconeoneone@gmail.com>
Co-authored-by: Bioblaze Payne <BioblazePayne@gmail.com>
2024-10-11 02:25:54 -04:00

87 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
set -o pipefail
if [ ! -f "version.py" ]; then
echo "Warning: This script is intended to be run from the root of the Redot repository."
echo "Some of the paths checks may not work as intended from a different folder."
fi
if [ $# != 1 ]; then
echo "Usage: @0 <path-to-godot-executable>"
exit 1
fi
api_validation_dir="$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/"
has_problems=0
warn_extra=0
reference_tag=""
expected_errors=""
make_annotation()
{
local title=$1
local body=$2
local type=$3
local file=$4
if [[ "$GITHUB_OUTPUT" == "" ]]; then
echo "$title"
echo "$body"
else
body="$(awk 1 ORS='%0A' - <<<"$body")"
echo "::$type file=$file,title=$title ::$body"
fi
}
get_expected_output()
{
local parts=()
IFS='_' read -ra parts <<< "$(basename -s .expected "$1")"
if [[ "${#parts[@]}" == "2" ]]; then
cat "$1" >> "$expected_errors"
get_expected_output "$(find "$api_validation_dir" -name "${parts[1]}*.expected")"
reference_tag="${parts[0]}"
warn_extra=0
else
cat "$1" >> "$expected_errors"
reference_tag="${parts[0]}"
warn_extra=1
fi
}
while read -r file; do
reference_file="$(mktemp)"
validate="$(mktemp)"
validation_output="$(mktemp)"
allowed_errors="$(mktemp)"
expected_errors="$(mktemp)"
get_expected_output "$file"
# Download the reference extension_api.json
wget -nv --retry-on-http-error=503 --tries=5 --timeout=60 -cO "$reference_file" "https://raw.githubusercontent.com/godotengine/godot-cpp/godot-$reference_tag/gdextension/extension_api.json" || has_problems=1
# Validate the current API against the reference
"$1" --headless --validate-extension-api "$reference_file" 2>&1 | tee "$validate" | awk '!/^Validate extension JSON:/' - || true
# Collect the expected and actual validation errors
awk '/^Validate extension JSON:/' - < "$validate" | sort > "$validation_output"
awk '/^Validate extension JSON:/' - < "$expected_errors" | sort > "$allowed_errors"
# Differences between the expected and actual errors
new_validation_error="$(comm -23 "$validation_output" "$allowed_errors")"
obsolete_validation_error="$(comm -13 "$validation_output" "$allowed_errors")"
if [ -n "$obsolete_validation_error" ] && [ "$warn_extra" = "1" ]; then
#make_annotation "The following validation errors no longer occur (compared to $reference_tag):" "$obsolete_validation_error" warning "$file"
echo "The following validation errors no longer occur (compared to $reference_tag):"
echo "$obsolete_validation_error"
fi
if [ -n "$new_validation_error" ]; then
make_annotation "Compatibility to $reference_tag is broken in the following ways:" "$new_validation_error" error "$file"
has_problems=1
fi
rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors" "$expected_errors"
done <<< "$(find "$api_validation_dir" -name "*.expected")"
exit $has_problems