diff options
Diffstat (limited to 'misc/scripts')
-rwxr-xr-x | misc/scripts/clang_format.sh | 2 | ||||
-rw-r--r-- | misc/scripts/gitignore_check.sh | 26 | ||||
-rwxr-xr-x | misc/scripts/header_guards.sh | 2 | ||||
-rw-r--r-- | misc/scripts/mypy.ini | 1 | ||||
-rwxr-xr-x | misc/scripts/validate_extension_api.sh | 43 |
5 files changed, 62 insertions, 12 deletions
diff --git a/misc/scripts/clang_format.sh b/misc/scripts/clang_format.sh index 74a8e1a8a3..40d94d4276 100755 --- a/misc/scripts/clang_format.sh +++ b/misc/scripts/clang_format.sh @@ -21,7 +21,7 @@ fi # Fix copyright headers, but not all files get them. for f in $files; do - if [[ "$f" == *"inc" ]]; then + if [[ "$f" == *"inc" && "$f" != *"compat.inc" ]]; then continue elif [[ "$f" == *"glsl" ]]; then continue diff --git a/misc/scripts/gitignore_check.sh b/misc/scripts/gitignore_check.sh new file mode 100644 index 0000000000..f162e25391 --- /dev/null +++ b/misc/scripts/gitignore_check.sh @@ -0,0 +1,26 @@ +set -uo pipefail +shopt -s globstar + +echo -e ".gitignore validation..." + +# Get a list of files that exist in the repo but are ignored. + +# The --verbose flag also includes files un-ignored via ! prefixes. +# We filter those out with a somewhat awkward `awk` directive. + # (Explanation: Split each line by : delimiters, + # see if the actual gitignore line shown in the third field starts with !, + # if it doesn't, print it.) + +# ignorecase for the sake of Windows users. + +output=$(git -c core.ignorecase=true check-ignore --verbose --no-index **/* | \ + awk -F ':' '{ if ($3 !~ /^!/) print $0 }') + +# Then we take this result and return success if it's empty. +if [ -z "$output" ]; then + exit 0 +else + # And print the result if it isn't. + echo "$output" + exit 1 +fi diff --git a/misc/scripts/header_guards.sh b/misc/scripts/header_guards.sh index 1f8aa6151c..ce0b3f334d 100755 --- a/misc/scripts/header_guards.sh +++ b/misc/scripts/header_guards.sh @@ -19,7 +19,7 @@ for file in $files; do # Skip *.gen.h and *-so_wrap.h, they're generated. if [[ "$file" == *".gen.h" || "$file" == *"-so_wrap.h" ]]; then continue; fi # Has important define before normal header guards. - if [[ "$file" == *"thread.h" || "$file" == *"platform_config.h" ]]; then continue; fi + if [[ "$file" == *"thread.h" || "$file" == *"platform_config.h" || "$file" == *"platform_gl.h" ]]; then continue; fi # Obj-C files don't use header guards. if grep -q "#import " "$file"; then continue; fi diff --git a/misc/scripts/mypy.ini b/misc/scripts/mypy.ini index c1ea695ca5..b3323eacda 100644 --- a/misc/scripts/mypy.ini +++ b/misc/scripts/mypy.ini @@ -9,3 +9,4 @@ warn_unreachable = True namespace_packages = True explicit_package_bases = True +exclude = (?x)(^thirdparty) diff --git a/misc/scripts/validate_extension_api.sh b/misc/scripts/validate_extension_api.sh index e06d52115a..cde7a8574d 100755 --- a/misc/scripts/validate_extension_api.sh +++ b/misc/scripts/validate_extension_api.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -uo pipefail +set -o pipefail if [ ! -f "version.py" ]; then echo "Warning: This script is intended to be run from the root of the Godot repository." @@ -10,7 +10,12 @@ if [ $# != 1 ]; then echo "Usage: @0 <path-to-godot-executable>" fi +api_validation_dir="$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/" + has_problems=0 +warn_extra=0 +reference_tag="" +expected_errors="" make_annotation() { @@ -18,7 +23,7 @@ make_annotation() local body=$2 local type=$3 local file=$4 - if [ ! -v GITHUB_OUTPUT ]; then + if [[ "$GITHUB_OUTPUT" == "" ]]; then echo "$title" echo "$body" else @@ -27,26 +32,44 @@ make_annotation() 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 - reference_tag="$(basename -s .expected "$file")" - wget -qcO "$reference_file" "https://raw.githubusercontent.com/godotengine/godot-cpp/godot-$reference_tag/gdextension/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:/' - < "$file" | sort > "$allowed_errors" + awk '/^Validate extension JSON:/' - < "$expected_errors" | sort > "$allowed_errors" # Differences between the expected and actual errors - new_validation_error="$(comm "$validation_output" "$allowed_errors" -23)" - obsolete_validation_error="$(comm "$validation_output" "$allowed_errors" -13)" + new_validation_error="$(comm -23 "$validation_output" "$allowed_errors")" + obsolete_validation_error="$(comm -13 "$validation_output" "$allowed_errors")" - if [ -n "$obsolete_validation_error" ]; then + 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" fi if [ -n "$new_validation_error" ]; then @@ -54,7 +77,7 @@ while read -r file; do has_problems=1 fi - rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors" -done <<< "$(find "$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/" -name "*.expected")" + rm -f "$reference_file" "$validate" "$validation_output" "$allowed_errors" "$expected_errors" +done <<< "$(find "$api_validation_dir" -name "*.expected")" exit $has_problems |