Brodey/graph contd #113
Workflow file for this run
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: | |
- pull_request | |
jobs: | |
formatting-check: | |
name: Formatting Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install clang-format | |
run: sudo apt-get install -y clang-format | |
- name: Fetch base branch | |
run: > | |
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} | |
- name: Run clang-format on diff | |
run: > | |
git diff -U0 --name-only origin/${{ github.base_ref }} | grep -E '\.(cpp|h|cu)$' > changed_files.txt || true | |
if [ ! -s changed_files.txt ]; then | |
echo "No files changed, skipping format check." | |
exit 0 | |
fi | |
while read -r file; do | |
echo "Checking $file" | |
# Get diff in unified format | |
git diff -U0 origin/${{ github.base_ref }} -- "$file" | clang-format-diff -p1 -style=file > formatted.diff | |
if [ -s formatted.diff ]; then | |
echo "File $file is not properly formatted. Please run format on your code." | |
cat formatted.diff | |
exit 1 | |
fi | |
done | |
- name: Show success message | |
if: success() | |
run: echo "All files are properly formatted!" |