Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .ci/check-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -u -o pipefail

ret=0

# Check C/C++ files with clang-format
while IFS= read -r -d '' file; do
clang-format-18 -n --Werror "${file}" || ret=1
done < <(git ls-files -z '*.c' '*.cpp' '*.h' ':!:*/submodule/*')

# Check shell scripts with shfmt
while IFS= read -r file; do
diff <(cat "${file}") <(shfmt -i 4 -bn -ci -sr "${file}")
if [ $? -ne 0 ]; then
echo "${file}" "mismatch"
ret=1
fi
done < <(git ls-files '*.sh')

exit ${ret}
19 changes: 19 additions & 0 deletions .ci/check-newline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -e -u -o pipefail

ret=0
show=0
# Reference: https://medium.com/@alexey.inkin/how-to-force-newline-at-end-of-files-and-why-you-should-do-it-fdf76d1d090e
while IFS= read -rd '' f; do
if file --mime-encoding "$f" | grep -qv binary; then
tail -c1 < "$f" | read -r _ || show=1
if [ $show -eq 1 ]; then
echo "Warning: No newline at end of file $f"
ret=1
show=0
fi
fi
done < <(git ls-files -z app kernel lib arch include)

exit $ret
Loading