Skip to content

Commit 23df68b

Browse files
committed
Code style for whitespace_check.yml
1 parent 42ba11f commit 23df68b

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

.github/workflows/whitespace_checks.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ jobs:
3434
- uses: actions/checkout@v4
3535
# Line endings are already ensured by .gitattributes
3636
- name: Check trailing whitespaces
37-
run: if git ls-files | grep -E '\.txt$|\.md$|\.[ch]$|\.cpp$|\.hpp$|\.sh$|\.cmake$|\.glsl$' | xargs grep -n '\s$'; then echo -e "\033[0;31mFound trailing whitespace"; (exit 1); else (exit 0); fi
37+
run: |
38+
if git ls-files |\
39+
grep -E '\.txt$|\.md$|\.[ch]$|\.cpp$|\.hpp$|\.sh$|\.cmake$|\.glsl$' |\
40+
xargs grep -n '\s$';\
41+
then\
42+
echo -e "\033[0;31mFound trailing whitespace";\
43+
(exit 1);\
44+
else\
45+
(exit 0);\
46+
fi
3847
3948
indent_spaces:
4049
runs-on: ubuntu-latest
@@ -46,28 +55,64 @@ jobs:
4655
# So lines like: "/* */ /*" or "*/ a = 5; /*" will result in error
4756
- name: Check for unsupported multiline comments
4857
run: |
49-
if git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' | xargs grep -n '\*/.*/\*'; then echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line."; (exit 1); else (exit 0); fi
50-
if git ls-files | grep -E '\.lua$' | xargs grep -n -e '\]\].*--\[\['; then echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line."; (exit 1); else (exit 0); fi
58+
if git ls-files |\
59+
grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' |\
60+
xargs grep -n '\*/.*/\*';\
61+
then
62+
echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line.";\
63+
(exit 1);\
64+
else\
65+
(exit 0);\
66+
fi
67+
if git ls-files |\
68+
grep -E '\.lua$' |\
69+
xargs grep -n -e '\]\].*--\[\[';\
70+
then
71+
echo -e "\033[0;31mUnsupported combination of multiline comments. New multiline comment should begin on new line.";\
72+
(exit 1);\
73+
else\
74+
(exit 0);\
75+
fi
5176
# This prepare files for final check
5277
# See python script ./util/ci/indent_tab_preprocess.py for details.
5378
- name: Preprocess files
5479
run: |
55-
git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' | xargs -L 1 -P $(($(nproc) + 1)) python3 ./util/ci/indent_tab_preprocess.py "/*" "*/"
56-
git ls-files | grep -E '\.lua$' | xargs -L 1 -P $(($(nproc) + 1)) python3 ./util/ci/indent_tab_preprocess.py "--[[" "]]"
80+
git ls-files |\
81+
grep -E '^src/.*\.cpp$|^src/.*\.[ch]$' |\
82+
xargs -L 1 -P $(($(nproc) + 1)) \
83+
python3 ./util/ci/indent_tab_preprocess.py "/*" "*/"
84+
git ls-files |\
85+
grep -E '\.lua$' |\
86+
xargs -L 1 -P $(($(nproc) + 1)) \
87+
python3 ./util/ci/indent_tab_preprocess.py "--[[" "]]"
5788
# Check for bad indent.
5889
# This runs over preprocessed files.
5990
# If there is any remaining space on line beginning or after tab,
6091
# error is generated
6192
- name: Check indent spaces
6293
run: |
63-
if git ls-files | grep -E '^src/.*\.cpp$|^src/.*\.[ch]$|\.lua' | xargs grep -n -P '^\t*[ ]'; then echo -e "\033[0;31mFound incorrect indent whitespaces"; (exit 1); else (exit 0); fi
94+
if git ls-files |\
95+
grep -E '^src/.*\.cpp$|^src/.*\.[ch]$|\.lua' |\
96+
xargs grep -n -P '^\t*[ ]';\
97+
then\
98+
echo -e "\033[0;31mFound incorrect indent whitespaces";\
99+
(exit 1);\
100+
else\
101+
(exit 0);\
102+
fi
64103
65104
tabs_lua_api_files:
66105
runs-on: ubuntu-latest
67106
steps:
68107
- uses: actions/checkout@v4
69108
# Some files should not contain tabs
70109
- name: Check tabs in Lua API files
71-
run: if grep -n $'\t' doc/lua_api.md doc/client_lua_api.md; then echo -e "\033[0;31mFound tab in markdown file"; (exit 1); else (exit 0); fi
72-
110+
run: |
111+
if grep -n $'\t' doc/lua_api.md doc/client_lua_api.md;\
112+
then\
113+
echo -e "\033[0;31mFound tab in markdown file";\
114+
(exit 1);\
115+
else\
116+
(exit 0);\
117+
fi
73118

0 commit comments

Comments
 (0)