Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Move to clang-format version 18 #830

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ Wakaama provides a simple CLI library. It can be enabled with:
- Version control system: Git (and a GitHub account)
- Git commit message linter: gitlint
- Build system: ninja
- C code formatting: clang-format, version 14
- C code formatting: clang-format, version 18
- CMake list files formatting: cmake-format, version 0.6.13
- Unit testing: CUnit

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

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

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

If existing code gets reformatted, this must be done in a separate commit. Its commit id has to be added to the file
`.git-blame-ignore-revs` and committed in yet another commit.
Expand Down
5 changes: 3 additions & 2 deletions tools/ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OPT_BRANCH_SOURCE=
OPT_BRANCH_TARGET=main
OPT_C_EXTENSIONS=""
OPT_C_STANDARD=""
OPT_CLANG_FORMAT="clang-format-14"
OPT_CLANG_FORMAT="clang-format-18"
OPT_SANITIZER=""
OPT_SCAN_BUILD=""
OPT_SONARQUBE=""
Expand Down Expand Up @@ -103,11 +103,12 @@ function run_clang_format() {
# shellcheck disable=SC2064
trap "{ rm -f -- '${patch_file}'; }" EXIT TERM INT

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

if [ -s "${patch_file}" ]; then
cat "${patch_file}"
Expand Down
Loading