From c804024e5d11e46efba5f8f0fa6107dddb158a3b Mon Sep 17 00:00:00 2001 From: Pxl Date: Fri, 2 Dec 2022 14:10:29 +0800 Subject: [PATCH] [Chore](workflow) add clang-tidy workflow (#14737) add clang-tidy workflow --- .github/actions/clang-tidy-review | 1 + .github/workflows/be-ut-clang.yml | 3 +- .github/workflows/build-thirdparty.yml | 2 +- .github/workflows/clang-checks.yml | 112 +++++++++++++++++++++++++ .github/workflows/clang-format.yml | 56 ------------- .gitmodules | 3 + build.sh | 14 +++- 7 files changed, 129 insertions(+), 62 deletions(-) create mode 160000 .github/actions/clang-tidy-review create mode 100644 .github/workflows/clang-checks.yml delete mode 100644 .github/workflows/clang-format.yml diff --git a/.github/actions/clang-tidy-review b/.github/actions/clang-tidy-review new file mode 160000 index 0000000000..79d70e7c89 --- /dev/null +++ b/.github/actions/clang-tidy-review @@ -0,0 +1 @@ +Subproject commit 79d70e7c89de1bda6ad68610cde18d2783749852 diff --git a/.github/workflows/be-ut-clang.yml b/.github/workflows/be-ut-clang.yml index aa09e705e5..d6361f98fb 100644 --- a/.github/workflows/be-ut-clang.yml +++ b/.github/workflows/be-ut-clang.yml @@ -62,7 +62,7 @@ jobs: export DEFAULT_DIR='/opt/doris' mkdir "${DEFAULT_DIR}" - wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.12/ldb_toolchain_gen.sh \ + wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.14.2/ldb_toolchain_gen.sh \ -q -O /tmp/ldb_toolchain_gen.sh bash /tmp/ldb_toolchain_gen.sh "${DEFAULT_DIR}/ldb-toolchain" @@ -82,4 +82,3 @@ jobs: export PATH="${DEFAULT_DIR}/ldb-toolchain/bin/:$(pwd)/thirdparty/installed/bin/:${PATH}" DORIS_TOOLCHAIN=clang ./run-be-ut.sh -j "$(nproc)" --run --clean - diff --git a/.github/workflows/build-thirdparty.yml b/.github/workflows/build-thirdparty.yml index 3f6e19dd13..0314fa228d 100644 --- a/.github/workflows/build-thirdparty.yml +++ b/.github/workflows/build-thirdparty.yml @@ -96,7 +96,7 @@ jobs: sudo DEBIAN_FRONTEND=noninteractive apt install --yes "${packages[@]}" mkdir -p "${DEFAULT_DIR}" - wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.12/ldb_toolchain_gen.sh \ + wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.14.2/ldb_toolchain_gen.sh \ -q -O /tmp/ldb_toolchain_gen.sh bash /tmp/ldb_toolchain_gen.sh "${DEFAULT_DIR}/ldb-toolchain" diff --git a/.github/workflows/clang-checks.yml b/.github/workflows/clang-checks.yml new file mode 100644 index 0000000000..be8dde67d4 --- /dev/null +++ b/.github/workflows/clang-checks.yml @@ -0,0 +1,112 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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: BE Code Checks + +on: [push, pull_request] + +jobs: + clang-format: + name: "Clang Formatter" + runs-on: ubuntu-latest + steps: + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" + uses: actions/checkout@v3 + with: + persist-credentials: false + submodules: recursive + + - name: Paths filter + uses: ./.github/actions/paths-filter + id: filter + with: + filters: | + be_changes: + - 'be/src/**' + - 'be/test/**' + + - name: "Format it!" + if: ${{ steps.filter.outputs.be_changes == 'true' }} + uses: ./.github/actions/clang-format-lint-action + id: be_clang_format + with: + source: "be/src be/test" + clangFormatVersion: 15 + inplace: False + + - name: Ignore it! + if: ${{ steps.filter.outputs.be_changes == 'false' }} + run: echo 'No need to check.' + + clang-tidy: + name: "Clang Tidy" + runs-on: ubuntu-22.04 + steps: + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" + uses: actions/checkout@v3 + with: + persist-credentials: false + submodules: recursive + + - name: Paths Filter + uses: ./.github/actions/paths-filter + id: filter + with: + filters: | + be_changes: + - 'be/**' + - 'gensrc/proto/**' + - 'gensrc/thrift/**' + + - name: Generate compile_commands.json + if: ${{ github.event_name == 'pull_request' && steps.filter.outputs.be_changes == 'true'}} + run: | + export DEFAULT_DIR='/opt/doris' + + mkdir "${DEFAULT_DIR}" + wget https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.14.2/ldb_toolchain_gen.sh \ + -q -O /tmp/ldb_toolchain_gen.sh + bash /tmp/ldb_toolchain_gen.sh "${DEFAULT_DIR}/ldb-toolchain" + + sudo apt update + sudo apt upgrade --yes + sudo DEBIAN_FRONTEND=noninteractive apt install --yes tzdata byacc + + # set timezone + sudo ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + sudo dpkg-reconfigure --frontend noninteractive tzdata + + pushd thirdparty + curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-linux-x86_64.tar.xz \ + -o doris-thirdparty-prebuilt-linux-x86_64.tar.xz + tar -xvf doris-thirdparty-prebuilt-linux-x86_64.tar.xz + popd + + export PATH="${DEFAULT_DIR}/ldb-toolchain/bin/:$(pwd)/thirdparty/installed/bin/:${PATH}" + DISABLE_JAVA_UDF=ON DORIS_TOOLCHAIN=clang OUTPUT_BE_BINARY=0 ./build.sh --be + + - name: Run clang-tidy review + if: ${{ github.event_name == 'pull_request' && steps.filter.outputs.be_changes == 'true'}} + uses: ./.github/actions/clang-tidy-review + id: review + with: + build_dir: ./be/build_Release + + - if: steps.review.outputs.total_comments > 0 + run: exit 1 diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml deleted file mode 100644 index df4a75af2e..0000000000 --- a/.github/workflows/clang-format.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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: BE Code Formatter -on: - pull_request: - push: - -jobs: - clang-format: - name: "Clang Formatter" - runs-on: ubuntu-latest - steps: - - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" - uses: actions/checkout@v2 - with: - persist-credentials: false - submodules: recursive - - - name: Paths filter - uses: ./.github/actions/paths-filter - id: filter - with: - filters: | - be_changes: - - 'be/src/**' - - 'be/test/**' - - - name: "Format it!" - if: ${{ steps.filter.outputs.be_changes == 'true' }} - uses: ./.github/actions/clang-format-lint-action - id: be_clang_format - with: - source: 'be/src be/test' - clangFormatVersion: 15 - inplace: False - - - name: Ignore it! - if: ${{ steps.filter.outputs.be_changes == 'false' }} - run: echo 'No need to check.' diff --git a/.gitmodules b/.gitmodules index 7f8c88c5ef..145e050d54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule ".github/actions/action-sh-checker"] path = .github/actions/action-sh-checker url = https://github.com/luizm/action-sh-checker +[submodule ".github/actions/clang-tidy-review"] + path = .github/actions/clang-tidy-review + url = https://github.com/ZedThree/clang-tidy-review.git diff --git a/build.sh b/build.sh index b55aa7a7e1..3578fdaa4c 100755 --- a/build.sh +++ b/build.sh @@ -282,6 +282,10 @@ if [[ -z "${USE_DWARF}" ]]; then USE_DWARF='OFF' fi +if [[ -z "${OUTPUT_BE_BINARY}" ]]; then + OUTPUT_BE_BINARY=${BUILD_BE} +fi + if [[ -z "${DISABLE_JAVA_UDF}" ]]; then DISABLE_JAVA_UDF='OFF' fi @@ -411,8 +415,12 @@ if [[ "${BUILD_BE}" -eq 1 ]]; then -DGLIBC_COMPATIBILITY="${GLIBC_COMPATIBILITY}" \ -DEXTRA_CXX_FLAGS="${EXTRA_CXX_FLAGS}" \ "${DORIS_HOME}/be" - "${BUILD_SYSTEM}" -j "${PARALLEL}" - "${BUILD_SYSTEM}" install + + if [[ "${OUTPUT_BE_BINARY}" -eq 1 ]]; then + "${BUILD_SYSTEM}" -j "${PARALLEL}" + "${BUILD_SYSTEM}" install + fi + cd "${DORIS_HOME}" fi @@ -504,7 +512,7 @@ if [[ "${BUILD_SPARK_DPP}" -eq 1 ]]; then cp -r -p "${DORIS_HOME}/fe/spark-dpp/target"/spark-dpp-*-jar-with-dependencies.jar "${DORIS_OUTPUT}/fe/spark-dpp"/ fi -if [[ "${BUILD_BE}" -eq 1 ]]; then +if [[ "${OUTPUT_BE_BINARY}" -eq 1 ]]; then install -d "${DORIS_OUTPUT}/be/bin" \ "${DORIS_OUTPUT}/be/conf" \ "${DORIS_OUTPUT}/be/lib" \