diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 9a609db0508..00000000000 --- a/.clang-format +++ /dev/null @@ -1,120 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# clang-format configuration file. Intended for clang-format >= 4. -# -# For more information, see: -# -# Documentation/process/clang-format.rst -# https://clang.llvm.org/docs/ClangFormat.html -# https://clang.llvm.org/docs/ClangFormatStyleOptions.html -# ---- -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: true -#AlignEscapedNewlines: Left # Unknown to clang-format-4.0 -AlignOperands: true -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AllowShortEnumsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - #AfterExternBlock: false # Unknown to clang-format-5.0 - BeforeCatch: false - BeforeElse: false - IndentBraces: false - #SplitEmptyFunction: true # Unknown to clang-format-4.0 - #SplitEmptyRecord: true # Unknown to clang-format-4.0 - #SplitEmptyNamespace: true # Unknown to clang-format-4.0 -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0 -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0 -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: false -ColumnLimit: 0 -CommentPragmas: '^ IWYU pragma:' -#CompactNamespaces: false # Unknown to clang-format-4.0 -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -#FixNamespaceComments: false # Unknown to clang-format-4.0 - -#IncludeBlocks: Preserve # Unknown to clang-format-5.0 -IncludeCategories: - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -#IndentPPDirectives: None # Unknown to clang-format-5.0 -IndentWidth: 8 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0 -ObjCBlockIndentWidth: 8 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true - -# Taken from git's rules -#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0 -PenaltyBreakBeforeFirstCallParameter: 30 -PenaltyBreakComment: 10 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 10 -PenaltyExcessCharacter: 100 -PenaltyReturnTypeOnItsOwnLine: 60 - -PointerAlignment: Right -ReflowComments: false -SortIncludes: false -#SortUsingDeclarations: false # Unknown to clang-format-4.0 -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0 -#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0 -SpaceBeforeParens: ControlStatements -#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0 -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp03 -TabWidth: 8 -UseTab: Always -... diff --git a/.github/workflows/static-checks.yaml b/.github/workflows/static-checks.yaml index 0fdf65693e0..1bb3f27881f 100644 --- a/.github/workflows/static-checks.yaml +++ b/.github/workflows/static-checks.yaml @@ -36,19 +36,6 @@ jobs: make vendor echo "git status --porcelain:" `git status --porcelain` test -z "$(git status --porcelain)" || (echo "Module vendoring checks failed. Please run 'make vendor', and submit your changes"; exit 1) - - name: Build clang-format Docker image - run: | - docker build -f Dockerfile.clang-format -t "isovalent/clang-format:latest" . - - name: Verify clang-format on BPF code - id: clang_format - run: | - set -o pipefail - find bpf -name '*.c' -o -name '*.h' -not -path 'bpf/include/vmlinux.h' \ - -not -path 'bpf/include/api.h' -not -path 'bpf/libbpf/*' | xargs -n 1000 \ - docker run -v $(realpath .):/tetragon "isovalent/clang-format:latest" --Werror -n -style=file - if [ $? != 0 ]; then - echo "clang-format checks failed. Please run 'make format' and submit your changes."; exit 1 - fi - name: Build CLI release binaries run: | make cli-release diff --git a/Dockerfile.clang-format b/Dockerfile.clang-format deleted file mode 100644 index a984373ebb2..00000000000 --- a/Dockerfile.clang-format +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:22.04@sha256:6120be6a2b7ce665d0cbddc3ce6eae60fe94637c6a66985312d1f02f63cc0bcd - -RUN apt-get -y update -RUN apt-get -y install clang-format-14 -RUN ln -s /bin/clang-format-14 /bin/clang-format - -USER 1000 -WORKDIR /tetragon - -ENTRYPOINT ["clang-format"] -CMD ["--help"] diff --git a/Makefile b/Makefile index 0aa4e7c77cd..8da5852620c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ BINDIR ?= /usr/local/bin CONTAINER_ENGINE ?= docker DOCKER_IMAGE_TAG ?= latest LOCAL_CLANG ?= 0 -LOCAL_CLANG_FORMAT ?= 0 FORMAT_FIND_FLAGS ?= -name '*.c' -o -name '*.h' -not -path 'bpf/include/vmlinux.h' -not -path 'bpf/include/api.h' -not -path 'bpf/libbpf/*' NOOPT ?= 0 CLANG_IMAGE = quay.io/cilium/clang:aeaada5cf60efe8d0e772d032fe3cc2bc613739c@sha256:b440ae7b3591a80ffef8120b2ac99e802bbd31dee10f5f15a48566832ae0866f @@ -88,9 +87,8 @@ help: @echo ' generate - generate kubebuilder files' @echo 'Linting and chores:' @echo ' vendor - tidy and vendor Go modules' - @echo ' clang-format - run code formatter on BPF code' @echo ' go-format - run code formatter on Go code' - @echo ' format - convenience alias for clang-format and go-format' + @echo ' format - convenience alias for go-format' @echo 'Documentation:' @echo ' docs - preview documentation website' @@ -327,23 +325,12 @@ copy-golangci-lint: docker cp ${xid}:/usr/bin/golangci-lint bin/golangci-lint docker rm ${xid} -.PHONY: clang-format -ifeq (1,$(LOCAL_CLANG_FORMAT)) -clang-format: - find bpf $(FORMAT_FIND_FLAGS) | xargs -n 1000 clang-format -i -style=file -else -clang-format: - $(CONTAINER_ENGINE) build -f Dockerfile.clang-format -t "cilium/clang-format:${DOCKER_IMAGE_TAG}" . - find bpf $(FORMAT_FIND_FLAGS) | xargs -n 1000 \ - $(CONTAINER_ENGINE) run -v $(shell realpath .):/tetragon "cilium/clang-format:${DOCKER_IMAGE_TAG}" -i -style=file -endif - .PHONY: go-format go-format: find . -name '*.go' -not -path './vendor/*' -not -path './api/vendor/*' -not -path './pkg/k8s/vendor/*' -not -path './api/v1/tetragon/codegen/*' | xargs gofmt -w .PHONY: format -format: go-format clang-format +format: go-format # generate cscope for bpf files cscope: