-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Enforce UTF-8 for .cpp/.h/.txt files
- Loading branch information
1 parent
b7da0df
commit 32f4db9
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Misc checks | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check-utf8-encoding: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: ./tools/check-utf8.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
invalid_found=0 | ||
|
||
# We would like to redirect iconv output to /dev/null, but the macOS version of | ||
# iconv has problems with this ("iconv: iconv(): Inappropriate ioctl for | ||
# device", sporadically for particular inputs). So use a regular file instead. | ||
tmpfile=/tmp/check-utf8-temp | ||
trap "rm -f $tmpfile" EXIT | ||
|
||
for file in $(git ls-files | grep -E '\.(cpp|h|txt)$'); do | ||
if ! iconv -f UTF-8 "$file" >$tmpfile; then | ||
echo "Not valid UTF-8: $file" >&2 | ||
invalid_found=1 | ||
fi | ||
done | ||
|
||
[ $invalid_found = 0 ] && echo "All checked files are valid UTF-8" >&2 | ||
|
||
exit $invalid_found |