fix: protogen scripts were not correctly implemented (#1466)

* Delete local copy of third party proto files

* Update protocgen script and buf yaml files to mirror cosmos-sdk

* Update makefile commands for proto-gen and proto-swagger-gen to correctly use docker

* Commit changed .pb.go files after updating the protogen scripts

* Adjust grep in proto-tools-installer script to look for correct gogoproto replacement

* address reviews - remove unnecessary ignore in buf.yaml and cosmos-sdk download in the protocgen script

* remove proto-update-deps from makefile as we don't store local copies of third party protofiles anymore

* Add changelog entry

* Update protoc-swagger-gen.sh

* Remove third party queries from swagger-ui config (for now)

* fix integrations tests

* fix dead changelog links (markdown-link-check)

Co-authored-by: Freddy Caceres <facs95@gmail.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
MalteHerrmann
2022-11-17 12:35:54 +01:00
committed by GitHub
co-authored by Freddy Caceres Federico Kunze Küllmer
parent 04bdccd42a
commit 6455785c04
121 changed files with 385 additions and 24640 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ f_install_buf() {
f_install_protoc_gen_gocosmos() {
f_print_installing_with_padding protoc-gen-gocosmos
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
if ! grep "github.com/cosmos/gogoproto => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
echo -e "\tPlease run this command from somewhere inside the ethermint folder."
return 1
fi
+14 -14
View File
@@ -2,20 +2,20 @@
set -eo pipefail
# install statik on the docker image
go install github.com/rakyll/statik
# create temporary folder to store intermediate results from `buf generate`
mkdir -p ./tmp-swagger-gen
proto_dirs=$(find ./proto ./third_party/proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
# create swagger files on an individual basis w/ `buf generate` (needed for `swagger-combine`)
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
# generate swagger files (filter query files)
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' -o -name 'service.proto' \))
if [[ ! -z "$query_file" ]]; then
protoc \
-I "proto" \
-I "third_party/proto" \
"$query_file" \
--swagger_out ./tmp-swagger-gen \
--swagger_opt logtostderr=true --swagger_opt fqn_for_swagger_name=true --swagger_opt simple_operation_ids=true
fi
# generate swagger files (filter query files)
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' -o -name 'service.proto' \))
if [[ ! -z "$query_file" ]]; then
buf generate --template proto/buf.gen.swagger.yaml $query_file
fi
done
# combine swagger files
@@ -26,5 +26,5 @@ swagger-combine ./client/docs/config.json -o ./client/docs/swagger-ui/swagger.ya
# clean swagger files
rm -rf ./tmp-swagger-gen
# generate binary for static server
statik -src=./client/docs/swagger-ui -dest=./client/docs
# generate binary for static server (use -f flag to replace current binary)
statik -f -src=./client/docs/swagger-ui -dest=./client/docs
+9 -31
View File
@@ -2,42 +2,20 @@
set -eo pipefail
protoc_gen_gocosmos() {
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
echo -e "\tPlease run this command from somewhere inside the sommelier folder."
return 1
fi
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
}
protoc_gen_doc() {
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc 2>/dev/null
}
protoc_gen_gocosmos
protoc_gen_doc
# get protoc executions
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
echo "Generating gogo proto code"
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
buf protoc \
-I "proto" \
-I "third_party/proto" \
--gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
--grpc-gateway_out=logtostderr=true:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
if grep go_package $file &>/dev/null; then
buf generate --template proto/buf.gen.gogo.yaml $file
fi
done
done
# command to generate docs using protoc-gen-doc
buf protoc \
-I "proto" \
-I "third_party/proto" \
--doc_out=./docs/api \
--doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \
$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')
# go mod tidy
# TODO: command to generate docs using protoc-gen-doc was deleted here
# move proto files to the right places
cp -r github.com/evmos/ethermint/* ./