Skip to content

Commit 1214c2e

Browse files
sherry-yuanpcolberg
authored andcommitted
Add clang-format script and use in workflow
1 parent fc99b92 commit 1214c2e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.github/workflows/clang-format.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ on:
1818
push:
1919
paths:
2020
- '.github/workflows/clang-format.yml'
21+
- 'scripts/clang-format.sh'
2122
- '**.c'
2223
- '**.cpp'
2324
- '**.h'
24-
- '**.hpp'
2525

2626
pull_request:
2727
paths:
2828
- '.github/workflows/clang-format.yml'
29+
- 'scripts/clang-format.sh'
2930
- '**.c'
3031
- '**.cpp'
3132
- '**.h'
32-
- '**.hpp'
3333

3434
jobs:
3535
build:
@@ -46,7 +46,7 @@ jobs:
4646
uses: actions/checkout@v2
4747

4848
- name: run clang-format on source files
49-
run: find . -regex '.*\.\(c\|cpp\|h\|hpp\)' | sort | xargs clang-format --verbose -i
49+
run: ./scripts/clang-format.sh --verbose
5050

5151
- name: ensure source files are unchanged
5252
run: git diff --exit-code

scripts/clang-format.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Copyright (C) 2021 Intel Corporation
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
set -eu -o pipefail
6+
7+
find . -regex '.*\.\(c\|cpp\|h\)' | sort | xargs clang-format -i "$@"

0 commit comments

Comments
 (0)