mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix UTF-8 validation in static checks
Use isutf8 instead of recode to detect invalid UTF-8 sequences. Also add the necessary dependencies to run the static checks locally using act (https://github.com/nektos/act) with the Medium size image.
This commit is contained in:
parent
6c818da55e
commit
20bf72751c
2 changed files with 22 additions and 9 deletions
4
.github/workflows/static_checks.yml
vendored
4
.github/workflows/static_checks.yml
vendored
|
@ -24,8 +24,8 @@ jobs:
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -qq dos2unix recode clang-format-13 libxml2-utils
|
sudo apt-get install -qq dos2unix recode clang-format-13 libxml2-utils python3-pip moreutils
|
||||||
sudo update-alternatives --remove-all clang-format
|
sudo update-alternatives --remove-all clang-format || true
|
||||||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100
|
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100
|
||||||
sudo pip3 install black==22.3.0 pygments pytest
|
sudo pip3 install black==22.3.0 pygments pytest
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ while IFS= read -rd '' f; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Ensure that files are UTF-8 formatted.
|
# Ensure that files are UTF-8 formatted.
|
||||||
recode UTF-8 "$f" 2> /dev/null
|
isutf8 "$f" >> utf8-validation.txt 2>&1
|
||||||
# Ensure that files have LF line endings and do not contain a BOM.
|
# Ensure that files have LF line endings and do not contain a BOM.
|
||||||
dos2unix "$f" 2> /dev/null
|
dos2unix "$f" 2> /dev/null
|
||||||
# Remove trailing space characters and ensures that files end
|
# Remove trailing space characters and ensures that files end
|
||||||
|
@ -51,15 +51,28 @@ done
|
||||||
|
|
||||||
diff=$(git diff --color)
|
diff=$(git diff --color)
|
||||||
|
|
||||||
# If no diff has been generated all is OK, clean up, and exit.
|
# If no UTF-8 violations were collected and no diff has been
|
||||||
if [ -z "$diff" ] ; then
|
# generated all is OK, clean up, and exit.
|
||||||
|
if [ ! -s utf8-validation.txt ] && [ -z "$diff" ] ; then
|
||||||
printf "Files in this commit comply with the formatting rules.\n"
|
printf "Files in this commit comply with the formatting rules.\n"
|
||||||
|
rm -f utf8-violations.txt
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# A diff has been created, notify the user, clean up, and exit.
|
# Violations detected, notify the user, clean up, and exit.
|
||||||
printf "\n*** The following differences were found between the code "
|
if [ -s utf8-validation.txt ]
|
||||||
printf "and the formatting rules:\n\n"
|
then
|
||||||
echo "$diff"
|
printf "\n*** The following files contain invalid UTF-8 character sequences:\n\n"
|
||||||
|
cat utf8-validation.txt
|
||||||
|
rm -f utf8-validation.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$diff" ]
|
||||||
|
then
|
||||||
|
printf "\n*** The following differences were found between the code "
|
||||||
|
printf "and the formatting rules:\n\n"
|
||||||
|
echo "$diff"
|
||||||
|
fi
|
||||||
|
|
||||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue