From 5ea22c64471edbbb015e7dcb80c2b2cafc9df226 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Mon, 24 Feb 2025 20:47:13 +0530 Subject: [PATCH 1/5] feat: add .clang-format Signed-off-by: saurabhraghuvanshii chore: update clang-format Signed-off-by: saurabhraghuvanshii --- .clang-format | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..9cf6437 --- /dev/null +++ b/.clang-format @@ -0,0 +1,79 @@ +--- + +Language: Cpp +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignEscapedNewlines: Left +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: No +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeComma +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: "suppress" +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false # this will help for using // clang-format off // clang-format on +FixNamespaceComments: false +# If this is needed or not +# IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^.*(precomp|pch|stdafx)' + Priority: -1 + - Regex: '^".*"' + Priority: 1 + - Regex: '^<.*>' + Priority: 2 + - Regex: '.*' + Priority: 3 +IndentCaseLabels: false +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +PointerAlignment: Right +ReflowComments: false +SortIncludes: true +SpaceAfterTemplateKeyword: false +SpaceInEmptyBlock : true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never +--- From e99193112fa24ffb172e10666483dc806446fb6f Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Mon, 24 Feb 2025 23:47:59 +0530 Subject: [PATCH 2/5] feat: add clang-format.yaml for CI Signed-off-by: saurabhraghuvanshii --- .github/workflows/clang-format.yaml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/clang-format.yaml diff --git a/.github/workflows/clang-format.yaml b/.github/workflows/clang-format.yaml new file mode 100644 index 0000000..8e4785d --- /dev/null +++ b/.github/workflows/clang-format.yaml @@ -0,0 +1,43 @@ +name: Clang Format Check + +on: + push: + branches: + - master + - 'release/**' + pull_request: + schedule: + - cron: '0 0 * * *' # Runs every night at midnight UTC + +permissions: + contents: read + +jobs: + clang-format-check: + name: Clang Format Check + strategy: + fail-fast: false + matrix: + platform: + - macos-13 + - macos-14 + - macos-15 + runs-on: ${{ matrix.platform }} + timeout-minutes: 10 + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 1 + + - name: Install Clang Format + run: brew install clang-format + + - name: Run Clang Format Check + run: | + git fetch origin master + git clang-format origin/master --diff --quiet + if [ $? -ne 0 ]; then + echo "ERROR: Code is not properly formatted." + echo "Please run clang-format locally and commit the changes." + exit 1 + fi From 4c5a1ea43d6f706b2cb0d01c29ab01be8199f811 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Tue, 25 Feb 2025 22:03:50 +0530 Subject: [PATCH 3/5] chore: add clang-format checks for CI in build Signed-off-by: saurabhraghuvanshii --- .github/workflows/build.yaml | 23 +++++++++++++++ .github/workflows/clang-format.yaml | 43 ----------------------------- 2 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/clang-format.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 37ec0dc..9e6660d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,6 +13,28 @@ permissions: contents: read jobs: + clang-format-check: + name: Clang Format Check + runs-on: macos-15 + timeout-minutes: 10 + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 1 + + - name: Install Clang Format + run: brew install clang-format + + - name: Run Clang Format Check + run: | + git fetch origin master + git clang-format origin/master --diff --quiet + if [ $? -ne 0 ]; then + echo "ERROR: Code is not properly formatted." + echo "Please run clang-format locally and commit the changes." + exit 1 + fi + build: name: Build strategy: @@ -23,6 +45,7 @@ jobs: - macos-14 - macos-15 runs-on: ${{ matrix.platform }} + needs: clang-format-check timeout-minutes: 10 steps: - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 diff --git a/.github/workflows/clang-format.yaml b/.github/workflows/clang-format.yaml deleted file mode 100644 index 8e4785d..0000000 --- a/.github/workflows/clang-format.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: Clang Format Check - -on: - push: - branches: - - master - - 'release/**' - pull_request: - schedule: - - cron: '0 0 * * *' # Runs every night at midnight UTC - -permissions: - contents: read - -jobs: - clang-format-check: - name: Clang Format Check - strategy: - fail-fast: false - matrix: - platform: - - macos-13 - - macos-14 - - macos-15 - runs-on: ${{ matrix.platform }} - timeout-minutes: 10 - steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - with: - fetch-depth: 1 - - - name: Install Clang Format - run: brew install clang-format - - - name: Run Clang Format Check - run: | - git fetch origin master - git clang-format origin/master --diff --quiet - if [ $? -ne 0 ]; then - echo "ERROR: Code is not properly formatted." - echo "Please run clang-format locally and commit the changes." - exit 1 - fi From c1a01f2012efc6b923acf18cdb5bad017ec1f479 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Tue, 25 Feb 2025 22:19:25 +0530 Subject: [PATCH 4/5] chore: remove unwanted things Signed-off-by: saurabhraghuvanshii --- .clang-format | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index 9cf6437..90ac872 100644 --- a/.clang-format +++ b/.clang-format @@ -72,8 +72,5 @@ SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -TabWidth: 4 -UseTab: Never + --- From 880e81730516dd9ed47ea9b84d265f1cd574d7a8 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Wed, 26 Feb 2025 22:08:15 +0530 Subject: [PATCH 5/5] chore: addresses comments changes Signed-off-by: saurabhraghuvanshii --- .github/workflows/build.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9e6660d..aee9941 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,8 +27,7 @@ jobs: - name: Run Clang Format Check run: | - git fetch origin master - git clang-format origin/master --diff --quiet + git clang-format --diff --quiet if [ $? -ne 0 ]; then echo "ERROR: Code is not properly formatted." echo "Please run clang-format locally and commit the changes." @@ -45,7 +44,6 @@ jobs: - macos-14 - macos-15 runs-on: ${{ matrix.platform }} - needs: clang-format-check timeout-minutes: 10 steps: - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1