Skip to content

Commit

Permalink
Update clang-format action
Browse files Browse the repository at this point in the history
Signed-off-by: Ping Xie <pingxie@google.com>
  • Loading branch information
PingXie committed May 27, 2024
1 parent 3399c93 commit eb732e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ jobs:
# Run clang-format and capture the diff
cd src
clang-format -i **/*.c **/*.h
git diff --exit-code
# Capture the diff output
DIFF=$(git diff)
if [ ! -z "$DIFF" ]; then
echo "::set-output name=diff::$DIFF"
fi
shell: bash

- name: Check for formatting changes
if: ${{ failure() }}
if: steps.clang-format.outputs.diff
run: |
echo "Code is not formatted correctly."
echo "Code is not formatted correctly. Here is the diff:"
echo "${{ steps.clang-format.outputs.diff }}"
exit 1
1 change: 0 additions & 1 deletion src/.clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ sha1.*
sha256.*
siphash.c
strl.c
unit/test_files.h
1 change: 1 addition & 0 deletions src/unit/test_files.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Do not modify this file, it's automatically generated from utils/generate-unit-test-header.py */
/* clang-format off */
typedef int unitTestProc(int argc, char **argv, int flags);

typedef struct unitTest {
Expand Down
3 changes: 2 additions & 1 deletion utils/generate-unit-test-header.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
test_suites.append({'file': file, 'tests': tests})
test_suites.sort(key=lambda test_suite: test_suite['file'])
output.write("""/* Do not modify this file, it's automatically generated from utils/generate-unit-test-header.py */
/* clang-format off */
typedef int unitTestProc(int argc, char **argv, int flags);
typedef struct unitTest {
Expand Down Expand Up @@ -56,4 +57,4 @@
""")
for test_suite in test_suites:
output.write(' {{"{0}", __{1}}},\n'.format(test_suite['file'], test_suite['file'].replace('.c', '_c')))
output.write('};\n')
output.write('};\n')

0 comments on commit eb732e1

Please sign in to comment.