Skip to content

Update clang-format.yml #9

Update clang-format.yml

Update clang-format.yml #9

Workflow file for this run

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