Skip to content

Commit

Permalink
Fix clang-format to specific version (#7350)
Browse files Browse the repository at this point in the history
* Update clang-format install script

* Address PR comments

* Update clang-format install command

* Format makefile

* Use docker for formatting proto

* Comment out delimiter config

* Update contributing.md and .clang-format

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
  • Loading branch information
3 people committed Oct 27, 2020
1 parent 6688382 commit 8014fc6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
RawStringFormats:
- Delimiter: pb
- Delimiters:
- pb
Language: TextProto
BasedOnStyle: google
ReflowComments: true
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 0 additions & 27 deletions contrib/devtools/proto-tools-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,10 @@ 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
f_install_buf
f_install_protoc_gen_gocosmos
f_install_protoc_gen_grpc_gateway
f_install_protoc_gen_swagger
f_install_clang_format

0 comments on commit 8014fc6

Please sign in to comment.