Skip to content

Update clang-format.yml #7

Update clang-format.yml

Update clang-format.yml #7

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: |
find src/ -regex '.*\.[ch]' > files_to_check.txt
cat files_to_check.txt
# Run clang-format and collect the diff
while IFS= read -r file; do
diff=$(clang-format -style=file "$file" | diff "$file" -)
if [ -n "$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 < files_to_check.txt
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
shell: bash
- name: Upload clang-format diff artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: clang-format-diff
path: countdown/clang-format-diff.txt