Skip to content

Commit 22d0676

Browse files
authored
scripts/deploy.sh: add handmade linter for translation-related json files to check for tabs and odd spaces (#2064)
* scripts/deploy.sh: add handmade linter for translation-related json files to check for tabs and odd spaces
1 parent aa0784d commit 22d0676

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215

216216
steps:
217217
- name: Install dependencies (apk)
218-
run: apk add --no-cache git
218+
run: apk add --no-cache git bash grep
219219

220220
- uses: actions/checkout@v4
221221
with:
@@ -227,4 +227,4 @@ jobs:
227227
run: git config --global --add safe.directory /__w/IronOS/IronOS && git config --global safe.directory "$GITHUB_WORKSPACE"
228228

229229
- name: Check and verify documentation
230-
run: /bin/sh ./scripts/deploy.sh docs
230+
run: ./scripts/deploy.sh docs

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test-md:
149149
@echo ""
150150
@echo "---- Checking documentation... ----"
151151
@echo ""
152-
@/bin/sh ./scripts/deploy.sh docs
152+
@./scripts/deploy.sh docs
153153

154154
# shell style & linter check (github CI version of shellcheck is more recent than alpine one so the latter may not catch some policies)
155155
test-sh:

Translations/translation_UZ.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"menuOptions": {
138138
"DCInCutoff": {
139139
"displayText": "Quvvat\nmanbai",
140-
"description": "Batareya haddan tashqari zaryadsizlanishini oldini olish uchun kuchlanish chegarasini o'rnatish (DC 10V) (S=3.3V har bir yacheyka uchun, quvvat PWR chegarasini o'chirish)"
140+
"description": "Batareya haddan tashqari zaryadsizlanishini oldini olish uchun kuchlanish chegarasini o'rnatish (DC 10V) (S=3.3V har bir yacheyka uchun, quvvat PWR chegarasini o'chirish)"
141141
},
142142
"MinVolCell": {
143143
"displayText": "Minimal\nkuchlanish",

scripts/deploy.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ docs_links()
9595
{
9696
ver_git="$(git tag -l | sort | grep -e "^v" | grep -v "rc" | tail -1)"
9797
md="README.md"
98+
test -f "${md}" || (echo "deploy.sh: docs_links: ERROR with the project directory structure!" && exit 1)
9899
ver_md="$(grep -c "${ver_git}" "${md}")"
99100
ret=0
100-
if [ "${ver_md}" -ne 0 ]; then
101+
if [ "${ver_md}" -eq 0 ]; then
101102
ret=1
102103
echo "Please, update mention & links in ${md} inside Builds section for release builds with version ${ver_git}."
103104
fi;
@@ -108,16 +109,38 @@ docs_links()
108109
build_langs()
109110
{
110111
mk="../source/Makefile"
111-
cd Translations/ || exit 1
112+
cd Translations/ || (echo "deploy.sh: build_langs: ERROR with the project directory structure!" && exit 1)
112113
langs="$(echo "$(find ./*.json | sed -ne 's,^\./translation_,,; s,\.json$,,; /[A-Z]/p' ; sed -ne 's/^ALL_LANGUAGES=//p;' "${mk}")" | sed 's, ,\n,g; s,\r,,g' | sort | uniq -u)"
113-
ret=0
114114
if [ -n "${langs}" ]; then
115-
ret=1
116115
echo "It seems there is mismatch between supported languages and enabled builds."
117116
echo "Please, check files in Translations/ and ALL_LANGUAGES variable in source/Makefile for:"
118117
echo "${langs}"
118+
return 1
119119
fi;
120-
return "${ret}"
120+
cd ..
121+
122+
echo -ne "\n"
123+
grep -nH $'\11' Translations/translation*.json
124+
ret="${?}"
125+
if [ "${ret}" -eq 0 ]; then
126+
echo -ne "\t^^^^\t^^^^\n"
127+
echo "Please, remove any tabs as indention from json file(s) in Translations/ directory (see the exact files & lines in the list above)."
128+
echo "Use spaces only to indent in the future, please."
129+
echo -ne "\n"
130+
return 1
131+
fi;
132+
133+
grep -nEH -e "^( {1}| {3}| {5}| {7}| {9}| {11})[^ ]" Translations/translation*.json
134+
ret="${?}"
135+
if [ "${ret}" -eq 0 ]; then
136+
echo -ne "\t^^^^\t^^^^\n"
137+
echo "Please, remove any odd amount of extra spaces as indention from json file(s) in Translations/ directory (see the exact files & lines in the list above)."
138+
echo "Use even amount of spaces to indent in the future, please (two actual spaces per one indent, not tab)."
139+
echo -ne "\n"
140+
return 1
141+
fi;
142+
143+
return 0
121144
}
122145

123146
# Helper function to check code style using clang-format & grep/sed custom parsers:

0 commit comments

Comments
 (0)