From 2a419e451705cff0121d67648f475baacb5af74b Mon Sep 17 00:00:00 2001 From: Zhangjian He Date: Wed, 26 Mar 2025 14:53:22 +0800 Subject: [PATCH] ci: add clang format ci Signed-off-by: Zhangjian He --- .github/workflows/clang_format.yml | 34 +++++++++++++++++++ .../opengemini/impl/ClientConfigBuilder.cpp | 8 ++--- 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/clang_format.yml diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml new file mode 100644 index 0000000..f4cce5c --- /dev/null +++ b/.github/workflows/clang_format.yml @@ -0,0 +1,34 @@ +# Copyright 2025 openGemini Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Clang Format +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + clang-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install clang-format + run: sudo apt-get update && sudo apt-get install -y clang-format + - name: Run clang-format + run: find . -name "*.cpp" -o -name "*.h" | xargs clang-format -i + - name: Check for unformatted code + run: git diff --exit-code diff --git a/include/opengemini/impl/ClientConfigBuilder.cpp b/include/opengemini/impl/ClientConfigBuilder.cpp index 4037105..bc5509b 100644 --- a/include/opengemini/impl/ClientConfigBuilder.cpp +++ b/include/opengemini/impl/ClientConfigBuilder.cpp @@ -45,9 +45,7 @@ ClientConfigBuilder& ClientConfigBuilder::AuthCredential(const std::string& username, const std::string& password) { - struct AuthCredential cred { - username, password - }; + struct AuthCredential cred{ username, password }; conf_.authConfig.emplace(std::move(cred)); return *this; } @@ -64,9 +62,7 @@ ClientConfigBuilder& ClientConfigBuilder::BatchConfig(std::chrono::milliseconds interval, std::size_t size) { - struct BatchConfig batch { - interval, size - }; + struct BatchConfig batch{ interval, size }; conf_.batchConfig.emplace(std::move(batch)); return *this; }