Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit e01b473

Browse files
William Douglasbryteise
authored andcommitted
Switch to clang-format as a github action
Instead of having this be a local test, have a format target for the Makefile and use a github action for clang-format to avoid differences between developer systems clang-format and runner clang-format versions. Signed-off-by: William Douglas <[email protected]>
1 parent 19a6b3a commit e01b473

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

.github/workflows/ccpp.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ env:
66
NUM_JOBS: 10
77

88
jobs:
9+
formatting-check:
10+
name: Formatting Check
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Run clang-format style check
15+
uses: jidicula/[email protected]
16+
with:
17+
clang-format-version: '16'
18+
check-path: 'src'
19+
920
unit_and_style:
1021
runs-on: ubuntu-latest
1122
timeout-minutes: 60

Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ distclean-local:
239239
install-exec-hook:
240240
perl $(top_srcdir)/scripts/findstatic.pl */*.o | grep -v Checking ||:
241241

242+
format:
243+
clang-format -i -style=file src/*.[ch] src/lib/*.[ch] src/3rd_party/*.[ch] src/cmds/*.[ch] src/swupd_lib/*.[ch] src/verifytime/*.[ch]
244+
242245
compliant:
243246
test/code_analysis/compliant.bats
244247
test/functional/check_ids.bash

test/code_analysis/compliant.bats

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ check_sort_makefile()
2424
return "$status"
2525
fi
2626

27-
run clang-format -i -style=file src/*.[ch] src/lib/*.[ch] src/3rd_party/*.[ch] src/cmds/*.[ch] src/swupd_lib/*.[ch] src/verifytime/*.[ch]
28-
if [ "$status" -ne 0 ]; then
29-
echo "clang-format failed with status $status. Check if you have clang-format installed"
30-
return "$status"
31-
fi
32-
33-
run git diff --quiet --exit-code src
34-
if [ "$status" -ne 0 ]; then
35-
echo "Code style issues found. Run 'git diff' to view issues."
36-
return "$status"
37-
fi
38-
3927
run git grep if\ \(.*\)$ -- '*.c'
4028
if [ "$status" -eq 0 ]; then
4129
echo "Missing brackets in single line if:"

0 commit comments

Comments
 (0)