Skip to content

Commit 2140fbc

Browse files
Add encoding check workflow to ensure all the files having utf-8 encoding
Signed-off-by: Peter Zhu <[email protected]>
1 parent ff36da8 commit 2140fbc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/encoding-check.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Encoding Checker
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
extendedAsciiAndBom:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout repository
10+
uses: actions/checkout@v3
11+
- name: Check for possible file that does not follow utf-8 encoding
12+
run: |
13+
set +e
14+
wget https://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html
15+
IFS=$(echo -en "\n\b")
16+
COUNTER=0
17+
for i in `find . -type f \( -name "*.txt" -o -name "*.md" -o -name "*.markdown" -o -name "*.html" \) | grep -vE "^./.git"`;
18+
do
19+
grep -axv '.*' "$i"
20+
if [ "$?" -eq 0 ]; then
21+
echo -e "######################\n$i\n######################"
22+
COUNTER=$(( COUNTER + 1 ))
23+
fi
24+
done
25+
if [ "$COUNTER" != 0 ]; then
26+
echo "Found files that is not following utf-8 encoding, exit 1"
27+
exit 1
28+
fi

0 commit comments

Comments
 (0)