Skip to content

Commit 076a4b0

Browse files
CI: Add clang-format checker
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
1 parent d57408e commit 076a4b0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/clang-format.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Infineon Technologies AG
2+
#
3+
# SPDX-License-Identifier: BSD-2-Clause
4+
5+
name: Clang Format Checker
6+
on:
7+
[push, pull_request]
8+
jobs:
9+
clang-format-checking:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/tpm2-software/ubuntu-24.04
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 1
18+
- name: Run clang-format
19+
run: clang-format -i $(find -name '*.h' -or -name '*.c' | xargs realpath)
20+
- name: Check for diffs
21+
run: git diff --exit-code
22+
- name: failure
23+
if: ${{ failure() }}
24+
run: |
25+
echo "Clang format check failed. Please run clang-format on your code or see the diff in the step above."
26+
echo "docker run -u $UID -v $PWD:$PWD ghcr.io/tpm2-software/ubuntu-24.04 clang-format -i $(find -name '*.h' -or -name '*.c' | xargs realpath)"

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ full text of the DCO is here: https://developercertificate.org/. Contributors
4444
must add a 'Signed-off-by' line to their commits. This indicates the
4545
submitters acceptance of the DCO.
4646

47+
Please note that we now require REUSE and clang-format to also pass on PRs.
48+
You may run
49+
```sh
50+
docker run -u 1000 -v $PWD:$PWD xianpengshen/clang-tools:17 clang-format -i $(find -name '*.c' | xargs realpath)
51+
docker run -u 1000 -v $PWD:$PWD xianpengshen/clang-tools:17 clang-format -i $(find -name '*.h' | xargs realpath)
52+
```
53+
before submitting in order to align with our format requirements.
54+
4755
## Guideline for merging changes
4856

4957
Pull Requests MUST be assigned to an upcoming release tag. If a release milestone does

0 commit comments

Comments
 (0)