mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 02:58:02 -06:00
Add XML validation Github workflow (contributed by Jertzukka github.com/Jertzukka/VeraCrypt/tree/ci)
This commit is contained in:
42
.github/workflows/xmlvalidate.sh
vendored
Normal file
42
.github/workflows/xmlvalidate.sh
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
fail=false
|
||||
|
||||
# Get all string keys
|
||||
KEYS=$(grep -oP '<entry[\ ]+lang="[^"]+"[\ ]+key="\K[^"]+' "$1"/src/Common/Language.xml)
|
||||
|
||||
for file in {"$1"/Translations/Language.*.xml,"$1"/src/Common/Language.xml}; do
|
||||
echo "$file"
|
||||
passes=true
|
||||
|
||||
# Validate xml
|
||||
output=$(fxparser -V "$file")
|
||||
returnvalue=$?
|
||||
|
||||
if [ "$returnvalue" -ne "0" ]; then
|
||||
passes=false
|
||||
fail=true
|
||||
echo $output
|
||||
fi
|
||||
|
||||
# Ensure each key found in common xml is found in translation xmls
|
||||
for key in $KEYS; do
|
||||
if ! grep -q "$key" "$file"; then
|
||||
echo "Key $key not found in $file"
|
||||
passes=false
|
||||
fail=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$passes" = true ]; then
|
||||
echo -e "\e[32m$file passes xml validation.\e[0m"
|
||||
else
|
||||
echo -e "\e[31m$file fails xml validation.\e[0m"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [ "$fail" = true ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user