diff --git a/.clang-format b/.clang-format index dec78f0f78e0..7f662a4fd9f3 100644 --- a/.clang-format +++ b/.clang-format @@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right RawStringFormats: - - Delimiter: pb + - Delimiters: + - pb Language: TextProto BasedOnStyle: google ReflowComments: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35e4705c04c6..e13dba1b850f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,6 +142,8 @@ build, in which case we can fall back on `go mod tidy -v`. We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos-SDK. +For formatting code in `.proto` files, you can run `make proto-format` command. + For linting and checking breaking changes, we use [buf](https://buf.build/). There are two options for linting and to check if your changes will cause a break. The first is that you can install [buf](https://buf.build/docs/installation) locally, the commands for running buf after installing are `make proto-lint` and the breaking changes check will be `make proto-check-breaking`. If you do not want to install buf and have docker installed already then you can use these commands `make proto-lint-docker` and `make proto-check-breaking-docker`. To generate the protobuf stubs you must have `protoc` and `protoc-gen-gocosmos` installed. To install these tools run `make proto-tools`. After this step you will be able to run `make proto-gen` to generate the protobuf stubs. diff --git a/Makefile b/Makefile index b9f0beebca9f..dd21bbf2da95 100644 --- a/Makefile +++ b/Makefile @@ -362,7 +362,11 @@ proto-gen: @./scripts/protocgen.sh proto-format: + @echo "Formatting Protobuf files" + docker run -v $(shell pwd):/workspace \ + --workdir /workspace tendermintdev/docker-build-proto \ find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; +.PHONY: proto-format # This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed proto-gen-any: diff --git a/contrib/devtools/proto-tools-installer.sh b/contrib/devtools/proto-tools-installer.sh index fd287ddd8db3..f8bd2f621b82 100755 --- a/contrib/devtools/proto-tools-installer.sh +++ b/contrib/devtools/proto-tools-installer.sh @@ -119,32 +119,6 @@ f_install_protoc_gen_swagger() { f_print_done } -f_install_clang_format() { - f_print_installing_with_padding clang-format - - if which clang-format &>/dev/null ; then - echo -e "\talready installed. Skipping." - return 0 - fi - - case "${UNAME_S}" in - Linux) - if [ -e /etc/debian_version ]; then - echo -e "\tRun: sudo apt-get install clang-format" >&2 - elif [ -e /etc/fedora-release ]; then - echo -e "\tRun: sudo dnf install clang" >&2 - else - echo -e "\tRun (as root): subscription-manager repos --enable rhel-7-server-devtools-rpms ; yum install llvm-toolset-7" >&2 - fi - ;; - Darwin) - echo "\tRun: brew install clang-format" >&2 - ;; - *) - echo "\tunknown operating system. Skipping." >&2 - esac -} - f_ensure_tools f_ensure_dirs f_install_protoc @@ -152,4 +126,3 @@ f_install_buf f_install_protoc_gen_gocosmos f_install_protoc_gen_grpc_gateway f_install_protoc_gen_swagger -f_install_clang_format