2023-05-16 18:38:46 +02:00
|
|
|
#!/bin/bash
|
2023-08-10 07:46:34 +02:00
|
|
|
set -o pipefail
|
2023-05-16 18:38:46 +02:00
|
|
|
|
|
|
|
if [ ! -f "version.py" ]; then
|
|
|
|
echo "Warning: This script is intended to be run from the root of the Godot 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>"
|
|
|
|
fi
|
|
|
|
|
2023-08-30 18:50:41 +02:00
|
|
|
api_validation_dir="$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/"
|
|
|
|
|
2023-05-16 18:38:46 +02:00
|
|
|
has_problems=0
|
2023-08-30 18:50:41 +02:00
|
|
|
warn_extra=0
|
|
|
|
reference_tag=""
|
|
|
|
expected_errors=""
|
2023-05-16 18:38:46 +02:00
|
|
|
|
|
|
|
make_annotation()
|
|
|
|
{
|
|
|
|
local title=$1
|
|
|
|
local body=$2
|
|
|
|
local type=$3
|
|
|
|
local file=$4
|
2023-08-10 07:46:34 +02:00
|
|
|
if [[ "$GITHUB_OUTPUT" == "" ]]; then
|
2023-05-16 18:38:46 +02:00
|
|
|
echo "$title"
|
|
|
|
echo "$body"
|
|
|
|
else
|
|
|
|
body="$(awk 1 ORS='%0A' - <<<"$body")"
|
|
|
|
echo "::$type file=$file,title=$title ::$body"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-08-30 18:50:41 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-05-16 18:38:46 +02:00
|
|
|
while read -r file; do
|
|
|
|
reference_file="$(mktemp)"
|
|
|
|
validate="$(mktemp)"
|
|
|
|
validation_output="$(mktemp)"
|
|
|
|
allowed_errors="$(mktemp)"
|
2023-08-30 18:50:41 +02:00
|
|
|
expected_errors="$(mktemp)"
|
|
|
|
get_expected_output "$file"
|
2023-05-16 18:38:46 +02:00
|
|
|
|
|
|
|
# Download the reference extension_api.json
|
2023-09-05 14:09:52 +02:00
|
|
|
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
|
2023-05-16 18:38:46 +02:00
|
|
|
# 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"
|
2023-08-30 18:50:41 +02:00
|
|
|
awk '/^Validate extension JSON:/' - < "$expected_errors" | sort > "$allowed_errors"
|
2023-05-16 18:38:46 +02:00
|
|
|
|
|
|
|
# Differences between the expected and actual errors
|
2023-08-10 07:46:34 +02:00
|
|
|
new_validation_error="$(comm -23 "$validation_output" "$allowed_errors")"
|
|
|
|
obsolete_validation_error="$(comm -13 "$validation_output" "$allowed_errors")"
|
2023-05-16 18:38:46 +02:00
|
|
|
|
2023-08-30 18:50:41 +02:00
|
|
|
if [ -n "$obsolete_validation_error" ] && [ "$warn_extra" = "1" ]; then
|
2023-05-16 18:38:46 +02:00
|
|
|
make_annotation "The following validation errors no longer occur (compared to $reference_tag):" "$obsolete_validation_error" warning "$file"
|
|
|
|
fi
|
|
|
|
if [ -n "$new_validation_error" ]; then
|
2023-06-14 15:40:39 +02:00
|
|
|
make_annotation "Compatibility to $reference_tag is broken in the following ways:" "$new_validation_error" error "$file"
|
2023-05-16 18:38:46 +02:00
|
|
|
has_problems=1
|
|
|
|
fi
|
|
|
|
|
2023-08-30 18:50:41 +02:00
|
|
|
rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors" "$expected_errors"
|
|
|
|
done <<< "$(find "$api_validation_dir" -name "*.expected")"
|
2023-05-16 18:38:46 +02:00
|
|
|
|
|
|
|
exit $has_problems
|