From a4dd5d327e4deef247b801493b2a08333b1af9d3 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Thu, 7 Jul 2022 10:41:49 +0800 Subject: [PATCH] chore(clang-format): unify rdsn and Pegasus clang-format (#1022) --- src/.clang-format => .clang-format | 16 +++ .github/workflows/lint_and_test_pegasus.yaml | 4 +- ...lint_and_test_rdsn.yaml => test_rdsn.yaml} | 21 +--- ...s_pass.yaml => test_rdsn_always_pass.yaml} | 8 +- .licenserc.yaml | 5 +- .rat-excludes | 6 - LICENSE | 2 +- README.md | 2 +- rdsn/.clang-format | 119 ------------------ rdsn/README.md | 2 +- rdsn/run.sh | 11 -- rdsn/scripts/linux/run-clang-format.sh | 32 ----- scripts/format_files.sh | 4 +- .../linux => scripts}/run-clang-format.py | 0 scripts/travis.sh | 42 ------- 15 files changed, 27 insertions(+), 247 deletions(-) rename src/.clang-format => .clang-format (77%) rename .github/workflows/{lint_and_test_rdsn.yaml => test_rdsn.yaml} (94%) rename .github/workflows/{lint_and_test_rdsn_always_pass.yaml => test_rdsn_always_pass.yaml} (94%) delete mode 100644 rdsn/.clang-format delete mode 100755 rdsn/scripts/linux/run-clang-format.sh rename {rdsn/scripts/linux => scripts}/run-clang-format.py (100%) delete mode 100755 scripts/travis.sh diff --git a/src/.clang-format b/.clang-format similarity index 77% rename from src/.clang-format rename to .clang-format index fe37108aa1..50a16dbaf4 100644 --- a/src/.clang-format +++ b/.clang-format @@ -1,3 +1,19 @@ +# 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. --- Language: Cpp # BasedOnStyle: LLVM diff --git a/.github/workflows/lint_and_test_pegasus.yaml b/.github/workflows/lint_and_test_pegasus.yaml index 1625c3c7d8..4f904de4e3 100644 --- a/.github/workflows/lint_and_test_pegasus.yaml +++ b/.github/workflows/lint_and_test_pegasus.yaml @@ -56,7 +56,7 @@ jobs: fetch-depth: 1 submodules: true - name: clang-format - run: ./rdsn/scripts/linux/run-clang-format.py --clang-format-executable clang-format-3.9 -e ./src/shell/linenoise -e ./src/shell/sds -e ./rdsn -r ./src + run: ./scripts/run-clang-format.py --clang-format-executable clang-format-3.9 -e ./src/shell/linenoise -e ./src/shell/sds -e ./rdsn/thirdparty -r . test: name: Test @@ -74,7 +74,7 @@ jobs: - name: Unpack prebuilt third-parties run: unzip /root/thirdparties-bin.zip -d ./rdsn/thirdparty - name: Compilation - run: ./run.sh build -c --skip_thirdparty + run: ./run.sh build -c -j $(($(nproc)/2+1)) - name: Packaging Server run: ./run.sh pack_server - name: Packaging Tools diff --git a/.github/workflows/lint_and_test_rdsn.yaml b/.github/workflows/test_rdsn.yaml similarity index 94% rename from .github/workflows/lint_and_test_rdsn.yaml rename to .github/workflows/test_rdsn.yaml index 0514495055..39ac602bef 100644 --- a/.github/workflows/lint_and_test_rdsn.yaml +++ b/.github/workflows/test_rdsn.yaml @@ -21,14 +21,14 @@ # it's recommended to create a PR against the ci-test branch to test if it works # as expected. -name: rdsn Lint and Unit Test +name: rdsn Unit Test on: # run on each pull request pull_request: types: [ synchronize, opened, reopened ] paths: - - .github/workflows/lint_and_test_rdsn.yaml + - .github/workflows/test_rdsn.yaml - rdsn/CMakeLists.txt - rdsn/bin/** - rdsn/compile_thrift.py @@ -51,22 +51,8 @@ defaults: shell: bash jobs: - lint: - name: Lint - runs-on: ubuntu-latest - container: - image: apache/pegasus:clang-format-3.9 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - name: clang-format - working-directory: rdsn - run: ./scripts/linux/run-clang-format.py --clang-format-executable=clang-format-3.9 -r src include - test: name: Test - needs: lint runs-on: ubuntu-latest container: image: apache/pegasus:thirdparties-bin-ubuntu1804 @@ -109,7 +95,6 @@ jobs: test-with-sanitizer-address: name: Test With Sanitizer Address - needs: lint runs-on: ubuntu-latest container: image: apache/pegasus:thirdparties-bin-ubuntu1804 @@ -152,7 +137,6 @@ jobs: test-with-sanitizer-leak: name: Test With Sanitizer Leak - needs: lint runs-on: ubuntu-latest container: image: apache/pegasus:thirdparties-bin-ubuntu1804 @@ -195,7 +179,6 @@ jobs: test-with-sanitizer-undefined: name: Test With Sanitizer Undefined - needs: lint runs-on: ubuntu-latest container: image: apache/pegasus:thirdparties-bin-ubuntu1804 diff --git a/.github/workflows/lint_and_test_rdsn_always_pass.yaml b/.github/workflows/test_rdsn_always_pass.yaml similarity index 94% rename from .github/workflows/lint_and_test_rdsn_always_pass.yaml rename to .github/workflows/test_rdsn_always_pass.yaml index 4caa610ff9..a05bfaa4e2 100644 --- a/.github/workflows/lint_and_test_rdsn_always_pass.yaml +++ b/.github/workflows/test_rdsn_always_pass.yaml @@ -20,7 +20,7 @@ # 'always pass' action to resolve it, see more details: # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks -name: rdsn Lint and Unit Test +name: rdsn Unit Test on: # run on each pull request @@ -46,12 +46,6 @@ on: workflow_dispatch: jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - run: 'echo "No build required" ' - test: name: Test runs-on: ubuntu-latest diff --git a/.licenserc.yaml b/.licenserc.yaml index 61d9de3f7e..eee99b14db 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -26,7 +26,6 @@ header: - '.github/pull_request_template.md' - '.rat-excludes' - 'DISCLAIMER-WIP' - - 'src/.clang-format' # TODO(yingchun): rrdb_types.* files can be automatic generated when build, we can remove them later. - 'src/base/rrdb_types.cpp' - 'src/include/rrdb/rrdb_types.h' @@ -75,7 +74,7 @@ header: - 'rdsn/bin/FindRT.cmake' - 'rdsn/bin/FindDL.cmake' # Copyright (c) 2017 Guillaume Papin - - 'rdsn/scripts/linux/run-clang-format.py' + - 'scripts/run-clang-format.py' # need manual fix - 'rdsn/src/failure_detector/test/gtest.filter' - 'rdsn/src/meta/test/meta_state/gtest.filter' @@ -90,7 +89,6 @@ header: # should be empty, or ignore all comment lines - 'rdsn/src/utils/test/config-empty.ini' # The MIT License (MIT), Copyright (c) 2015 Microsoft Corporation - - 'rdsn/.clang-format' - 'rdsn/.gitignore' - 'rdsn/.licenserc.yaml' - 'rdsn/README.md' @@ -209,7 +207,6 @@ header: - 'rdsn/scripts/linux/clear_zk.sh' - 'rdsn/scripts/linux/install.sh' - 'rdsn/scripts/linux/learn_stat.py' - - 'rdsn/scripts/linux/run-clang-format.sh' - 'rdsn/scripts/linux/start_zk.sh' - 'rdsn/scripts/linux/stop_zk.sh' - 'rdsn/src/aio/aio_provider.cpp' diff --git a/.rat-excludes b/.rat-excludes index 7cd6ebafe5..3fd7af177e 100644 --- a/.rat-excludes +++ b/.rat-excludes @@ -1,9 +1,6 @@ -.*ini .*json .*in -.*md carrot -.clang-format sds/* linenoise/* argh.h @@ -12,8 +9,5 @@ ssh-no-interactive scp-no-interactive get_local_ip DISCLAIMER-WIP -.travis.yml .rat-excludes -.gitmodules -.gitignore apache-rat-0.13.jar diff --git a/LICENSE b/LICENSE index f27e03e832..4ae5059d21 100644 --- a/LICENSE +++ b/LICENSE @@ -558,7 +558,7 @@ RESULTING FROM THE USE OF THIS SOFTWARE. -------------------------------------------------------------------------------- -rdsn/scripts/linux/run-clang-format.py - MIT License +scripts/run-clang-format.py - MIT License MIT License diff --git a/README.md b/README.md index 0545a44e65..069274de1e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ under the License. ![pegasus-logo](https://github.com/apache/incubator-pegasus-website/blob/master/assets/images/pegasus-logo-inv.png) -[![Build Status](https://travis-ci.org/apache/incubator-pegasus.svg?branch=master)](https://travis-ci.org/apache/incubator-pegasus) +[![BuildPegasusRegularly - build pegasus and rdsn on different env every day](https://github.com/apache/incubator-pegasus/actions/workflows/pegasus-regular-build.yml/badge.svg)](https://github.com/apache/incubator-pegasus/actions/workflows/pegasus-regular-build.yml) [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) [![Releases](https://img.shields.io/github/release/apache/incubator-pegasus.svg)][github-release] diff --git a/rdsn/.clang-format b/rdsn/.clang-format deleted file mode 100644 index b920d77833..0000000000 --- a/rdsn/.clang-format +++ /dev/null @@ -1,119 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2015 Microsoft Corporation -# -# -=- Robust Distributed System Nucleus (rDSN) -=- -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterClass: true - AfterControlStatement: false - AfterEnum: true - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - BeforeCatch: false - BeforeElse: false - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 100 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: true -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '$' -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: false -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... - diff --git a/rdsn/README.md b/rdsn/README.md index ec1a7b3166..1e8b9cad62 100644 --- a/rdsn/README.md +++ b/rdsn/README.md @@ -24,7 +24,7 @@ ~ THE SOFTWARE. --> -[![rdsn Lint and Unit Test](https://github.com/apache/incubator-pegasus/actions/workflows/lint_and_test_rdsn.yaml/badge.svg)](https://github.com/apache/incubator-pegasus/actions/workflows/lint_and_test_rdsn.yaml) +[![rdsn Unit Test](https://github.com/apache/incubator-pegasus/actions/workflows/test_rdsn.yaml/badge.svg)](https://github.com/apache/incubator-pegasus/actions/workflows/test_rdsn.yaml) All pull requests please now go to https://github.com/imzhenyu/rdsn for automatic integration with latest version. We will periodically update this repo. Thank you. diff --git a/rdsn/run.sh b/rdsn/run.sh index 064d0f1331..2ca79e668d 100755 --- a/rdsn/run.sh +++ b/rdsn/run.sh @@ -23,7 +23,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. - os=linux scripts_dir=`pwd`/scripts/$os @@ -78,7 +77,6 @@ function usage_build() echo " to enable valgrind memcheck, default no" echo " --use_jemalloc build with jemalloc" echo " --skip_thirdparty whether to skip building thirdparties, default no" - echo " --check whether to perform code check before building" echo " --sanitizer build with sanitizer to check potential problems, type: address|leak|thread|undefined" if [ "$ONLY_BUILD" == "NO" ]; then @@ -107,7 +105,6 @@ function run_build() DISABLE_GPERF=NO USE_JEMALLOC=NO SKIP_THIRDPARTY=NO - CHECK=NO SANITIZER="" TEST_MODULE="" ROCKSDB_PORTABLE=OFF @@ -163,9 +160,6 @@ function run_build() --skip_thirdparty) SKIP_THIRDPARTY=YES ;; - --check) - CHECK=YES - ;; --sanitizer) IS_SANITIZERS=`echo ${SANITIZERS[@]} | grep -w $2` if [[ -z ${IS_SANITIZERS} ]]; then @@ -199,11 +193,6 @@ function run_build() shift done - if [[ ${CHECK} == "YES" ]]; then - ${scripts_dir}/run-clang-format.sh - exit_if_fail $? - fi - if [ "$(uname)" == "Darwin" ]; then MACOS_OPENSSL_ROOT_DIR="/usr/local/opt/openssl" CMAKE_OPTIONS="-DMACOS_OPENSSL_ROOT_DIR=${MACOS_OPENSSL_ROOT_DIR}" diff --git a/rdsn/scripts/linux/run-clang-format.sh b/rdsn/scripts/linux/run-clang-format.sh deleted file mode 100755 index 45c6488ce2..0000000000 --- a/rdsn/scripts/linux/run-clang-format.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# The MIT License (MIT) -# -# Copyright (c) 2015 Microsoft Corporation -# -# -=- Robust Distributed System Nucleus (rDSN) -=- -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") -PROJECT_DIR=$(dirname $(dirname "${SCRIPT_DIR}")) -python ${SCRIPT_DIR}/run-clang-format.py \ - --clang-format-executable=clang-format-3.9 \ - -i \ - -r ${PROJECT_DIR}/src ${PROJECT_DIR}/include diff --git a/scripts/format_files.sh b/scripts/format_files.sh index 3b25c9c844..af477a13aa 100755 --- a/scripts/format_files.sh +++ b/scripts/format_files.sh @@ -25,14 +25,14 @@ sds=./src/shell/sds if [ $# -eq 0 ]; then echo "formating all .h/.cpp files in $root_dir ..." - find . -type f -not \( -wholename "$linenoise/*" -o -wholename "$sds/*" -o -wholename "./rocksdb/*" -o -wholename "./rdsn/*" \) \ + find . -type f -not \( -wholename "$linenoise/*" -o -wholename "$sds/*" \) \ -regextype posix-egrep -regex ".*\.(cpp|h)" | xargs clang-format-3.9 -i -style=file elif [ $1 = "-h" ]; then echo "USAGE: ./format-files.sh [] -- format .h/.cpp files in $root_dir/relative_path" echo " ./format-files.sh means format all .h/.cpp files in $root_dir" else echo "formating all .h/.cpp files in $root_dir/$1 ..." - find ./$1 -type f -not \( -wholename "$linenoise/*" -o -wholename "$sds/*" -o -wholename "./rocksdb/*" -o -wholename "./rdsn/*" \) \ + find ./$1 -type f -not \( -wholename "$linenoise/*" -o -wholename "$sds/*" \) \ -regextype posix-egrep -regex ".*\.(cpp|h)" | xargs clang-format-3.9 -i -style=file fi diff --git a/rdsn/scripts/linux/run-clang-format.py b/scripts/run-clang-format.py similarity index 100% rename from rdsn/scripts/linux/run-clang-format.py rename to scripts/run-clang-format.py diff --git a/scripts/travis.sh b/scripts/travis.sh deleted file mode 100755 index 0dac2d33bb..0000000000 --- a/scripts/travis.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# 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. - -# to project root directory -script_dir=$(cd "$(dirname "$0")" && pwd) -root=$(dirname "$script_dir") -cd "${root}" || exit 1 - -# ensure source files are well formatted -"${root}"/scripts/format_files.sh - -# ignore updates of submodules -modified=$(git status -s --ignore-submodules) -if [ "$modified" ]; then - echo "$modified" - echo "please format the above files before commit" - exit 1 -fi - -source "${root}"/scripts/config_hdfs.sh -"${root}"/run.sh build -c --skip_thirdparty --disable_gperf && ./run.sh test --on_travis -ret=$? -if [ $ret ]; then - echo "travis failed with exit code $ret" -fi - -exit $ret