Update clang-format.yml #9
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
name: Clang Format Check | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
jobs: | |
clang-format-check: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up clang-format | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang-format | |
- name: Download Linux kernel .clang-format | |
run: | | |
curl -o .clang-format https://raw.githubusercontent.com/torvalds/linux/master/.clang-format | |
- name: Run clang-format and check code style | |
run: | | |
for file in $(ls src/*.[ch]); do | |
diff=$(clang-format -style=file "$file" | diff "$file" -) | |
echo "DIFF $diff" | |
if [ ! -z "$diff" ]; then | |
echo "Style issues in $file:" >> clang-format-diff.txt | |
clang-format -style=file "$file" | diff -u "$file" - >> clang-format-diff.txt | |
fi | |
done | |
echo "CIAOOA" | |
if [ -f clang-format-diff.txt ]; then | |
echo "ERROR in format" | |
echo "\nThe following files have style issues:" && cat clang-format-diff.txt | |
echo "\nRun clang-format -i src/*.[ch] in order to fix" >> $GITHUB_OUTPUT | |
exit 1 | |
else | |
echo "NO ERRORS" | |
fi | |
- name: Upload clang-format diff artifact | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: clang-format-diff | |
path: countdown/clang-format-diff.txt |