VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/xmlvalidate.sh
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-12-25 11:35:58 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-12-25 11:35:58 +0100
commit3f8ac7cd516278ccbc15eed47f8520b045d044e3 (patch)
tree4997ac151eec9cbad2080a9c1310e3d9996c30ae /.github/workflows/xmlvalidate.sh
parentca331b8b349cf1a42e6219d8733ae581199961fc (diff)
downloadVeraCrypt-3f8ac7cd516278ccbc15eed47f8520b045d044e3.tar.gz
VeraCrypt-3f8ac7cd516278ccbc15eed47f8520b045d044e3.zip
Add XML validation Github workflow (contributed by Jertzukka github.com/Jertzukka/VeraCrypt/tree/ci)
Diffstat (limited to '.github/workflows/xmlvalidate.sh')
-rw-r--r--.github/workflows/xmlvalidate.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/.github/workflows/xmlvalidate.sh b/.github/workflows/xmlvalidate.sh
new file mode 100644
index 00000000..79d52c16
--- /dev/null
+++ b/.github/workflows/xmlvalidate.sh
@@ -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