From d79c5824b8edb20cd88f13b9f21d844b283ff253 Mon Sep 17 00:00:00 2001 From: FranciscoPombal Date: Mon, 2 Nov 2020 14:57:41 +0000 Subject: [PATCH] Detect .ts file issues with file health workflow Also adjust newlines to improve output --- .github/workflows/file_health.sh | 34 ++++++++++++++++++------------ .github/workflows/file_health.yaml | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/file_health.sh b/.github/workflows/file_health.sh index 682a28b77..1d30b74ce 100755 --- a/.github/workflows/file_health.sh +++ b/.github/workflows/file_health.sh @@ -14,60 +14,68 @@ exclusions_bom='src/base/unicodestrings.h' exclusions_tw='(*.ts)|src/webui/www/private/scripts/lib/mootools-1.2-more.js' exclusions_no_lf='(*.ts)|(.*svg)|compile_commands.json|src/webui/www/private/scripts/lib/mootools-1.2-(core-yc.js|more.js)' -echo -e "*** Detect files not encoded in UTF-8 ***\n" +echo -e "\n*** Detect files not encoded in UTF-8 ***\n" find . -path ./build -prune -false -o -path ./.git -prune -false -o -type f -exec file --mime {} \; | sort \ | grep -v -e "charset=us-ascii" -e "charset=utf-8" | cut -d ":" -f 1 \ | grep -E -v -e "${exclusions_nonutf8}" \ - | tee >(echo -e "\n--> Files not encoded in UTF-8: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> Files not encoded in UTF-8: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' regressions=$((regressions+$?)) -echo -e "*** Detect files encoded in UTF-8 with BOM ***\n" +echo -e "\n*** Detect files encoded in UTF-8 with BOM ***\n" grep --exclude-dir={.git,build} -rIl $'\xEF\xBB\xBF' | sort \ | grep -E -v -e "${exclusions_bom}" \ - | tee >(echo -e "\n--> Files encoded in UTF-8 with BOM: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> Files encoded in UTF-8 with BOM: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' regressions=$((regressions+$?)) -echo -e "*** Detect usage of CR byte ***\n" +echo -e "\n*** Detect usage of CR byte ***\n" grep --exclude-dir={.git,build} -rIlU $'\x0D' | sort \ - | tee >(echo -e "\n--> Usage of CR byte: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> Usage of CR byte: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' regressions=$((regressions+$?)) -echo -e "*** Detect trailing whitespace in lines ***\n" +echo -e "\n*** Detect trailing whitespace in lines ***\n" grep --exclude-dir={.git,build} -rIl "[[:blank:]]$" | sort \ | grep -E -v -e "${exclusions_tw}" \ - | tee >(echo -e "\n--> Trailing whitespace in lines: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> Trailing whitespace in lines: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0'; regressions=$((regressions+$?)) -echo -e "*** Detect too many trailing newlines ***\n" +echo -e "\n*** Detect too many trailing newlines ***\n" find . -path ./build -prune -false -o -path ./.git -prune -false -o -type f -exec file --mime {} \; | sort \ | grep -e "charset=us-ascii" -e "charset=utf-8" | cut -d ":" -f 1 \ | xargs -L1 -I my_input bash -c 'test "$(tail -q -c2 "my_input" | hexdump -C | grep "0a 0a")" && echo "my_input"' \ - | tee >(echo -e "\n--> Too many trailing newlines: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> Too many trailing newlines: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' regressions=$((regressions+$?)) -echo -e "*** Detect no trailing newline ***\n" +echo -e "\n*** Detect no trailing newline ***\n" find . -path ./build -prune -false -o -path ./.git -prune -false -o -type f -exec file --mime {} \; | sort \ | grep -e "charset=us-ascii" -e "charset=utf-8" | cut -d ":" -f 1 \ | grep -E -v -e "${exclusions_no_lf}" \ | xargs -L1 -I my_input bash -c 'test "$(tail -q -c1 "my_input" | hexdump -C | grep "0a")" || echo "my_input"' \ - | tee >(echo -e "\n--> No trailing newline: found" "$(wc -l < /dev/stdin)" "regression(s)") \ + | tee >(echo -e "--> No trailing newline: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ + | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' +regressions=$((regressions+$?)) + +echo -e "\n*** Detect translation closing tag in new line ***\n" + +grep --exclude-dir={.git,build} -nri "^" | sort \ + | cut -d ":" -f 1,2 \ + | tee >(echo -e "--> Translation closing tag in new line: found" "$(wc -l < /dev/stdin)" "regression(s)\n") \ | xargs -I my_input -0 bash -c 'echo "my_input"; test "$(echo -n "my_input" | wc -l)" -eq 0' regressions=$((regressions+$?)) if [ "$regressions" -ne 0 ]; then regressions=1 - echo "File health regressions found. Please fix them (or add them as exclusions)." + echo "\nFile health regressions found. Please fix them (or add them as exclusions)." else echo "All OK, no file health regressions found." fi diff --git a/.github/workflows/file_health.yaml b/.github/workflows/file_health.yaml index 1182341d8..dc659ce27 100644 --- a/.github/workflows/file_health.yaml +++ b/.github/workflows/file_health.yaml @@ -11,7 +11,7 @@ jobs: check_file_health: name: Check file health - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: checkout repository