Skip to content

Commit dc9acdb

Browse files
ci: Move to clang-format version 18
This makes use of the fact that we have moved CI to Ubuntu 24.04, and are no longer constrained to the old versions offered by Ubuntu 20.04. Please note: clang-format-18 does return an non-zero exit code when changes have been found. For this reason, it gets now run in a subshell which has the pipefail option disabled.
1 parent d28bd14 commit dc9acdb

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ Wakaama provides a simple CLI library. It can be enabled with:
128128
- Version control system: Git (and a GitHub account)
129129
- Git commit message linter: gitlint
130130
- Build system: ninja
131-
- C code formatting: clang-format, version 14
131+
- C code formatting: clang-format, version 18
132132
- CMake list files formatting: cmake-format, version 0.6.13
133133
- Unit testing: CUnit
134134

135-
On Ubuntu 20.04, used in CI, the dependencies can be installed as such:
136-
- `apt install build-essential clang-format clang-format-14 clang-tools-14 cmake gcovr git libcunit1-dev ninja-build python3-pip`
135+
On Ubuntu 24.04, used in CI, the dependencies can be installed as such:
136+
- `apt install build-essential clang-format clang-format-18 clang-tools-18 cmake gcovr git libcunit1-dev ninja-build python3-pip`
137137
- `pip3 install -r tools/requirements-compliance.txt`
138138

139139
For macOS the development dependencies can be installed as such:
@@ -148,9 +148,9 @@ The style is based on the LLVM style, but with 4 instead of 2 spaces indentation
148148
characters per line.
149149

150150
To check if your code matches the expected style, the following commands are helpful:
151-
- `git clang-format-14 --diff`: Show what needs to be changed to match the expected code style
152-
- `git clang-format-14`: Apply all needed changes directly
153-
- `git clang-format-14 --commit main`: Fix code style for all changes since main
151+
- `git clang-format-18 --diff`: Show what needs to be changed to match the expected code style
152+
- `git clang-format-18`: Apply all needed changes directly
153+
- `git clang-format-18 --commit main`: Fix code style for all changes since main
154154

155155
If existing code gets reformatted, this must be done in a separate commit. Its commit id has to be added to the file
156156
`.git-blame-ignore-revs` and committed in yet another commit.

tools/ci/run_ci.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ OPT_BRANCH_SOURCE=
2424
OPT_BRANCH_TARGET=main
2525
OPT_C_EXTENSIONS=""
2626
OPT_C_STANDARD=""
27-
OPT_CLANG_FORMAT="clang-format-14"
27+
OPT_CLANG_FORMAT="clang-format-18"
2828
OPT_SANITIZER=""
2929
OPT_SCAN_BUILD=""
3030
OPT_SONARQUBE=""
@@ -103,11 +103,12 @@ function run_clang_format() {
103103
# shellcheck disable=SC2064
104104
trap "{ rm -f -- '${patch_file}'; }" EXIT TERM INT
105105

106-
"git-${OPT_CLANG_FORMAT}" --diff "${OPT_BRANCH_TARGET}" 2>&1 |
106+
(set +o pipefail; "git-${OPT_CLANG_FORMAT}" --diff "${OPT_BRANCH_TARGET}" 2>&1 |
107107
{ grep -v \
108108
-e 'no modified files to format' \
109109
-e 'clang-format did not modify any files' || true;
110110
} > "${patch_file}"
111+
)
111112

112113
if [ -s "${patch_file}" ]; then
113114
cat "${patch_file}"

0 commit comments

Comments
 (0)