Skip to content

Commit

Permalink
Fix our proto generation stuff. (#2167)
Browse files Browse the repository at this point in the history
* [2135]: Update the proto stuff in the makefile. Bump proto image ver to 0.15.1 (from 0.14.0). Clean up the proto-related targets to match the SDK's.

* [2135]: Update the protoc-swagger-gen.sh and protocgen.sh scripts. Add warnings from protoc-swagger.gen about stuff not in the config.

* [2135]: Update proto/buf.gen.swagger.yaml to use openapiv2 instead of swagger.

* [2135]: Further tweaks to protoc-swagger-gen to make it easier to alter for third-party purposes.

* [2135]: Fix typo in protocgen.sh.

* [2135]: run make proto-gen

* [2135]: Add missing ibchooks entry from swagger config.

* [2135]: run make proto-swagger-gen

* [2135]: Add changelog entry.

* [2135]: Switch to = for the tests in [ ] for verbosity.
  • Loading branch information
SpicyLemon authored Oct 7, 2024
1 parent c9ace39 commit 363eb32
Show file tree
Hide file tree
Showing 32 changed files with 1,394 additions and 2,336 deletions.
1 change: 1 addition & 0 deletions .changelog/unreleased/bug-fixes/2135-openapiv2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Make our proto generation stuff work again [#2135](https://github.com/provenance-io/provenance/issues/2135).
47 changes: 14 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ endif

HTTPS_GIT := https://github.com/provenance-io/provenance.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

# The below include contains the tools target.
include contrib/devtools/Makefile
Expand Down Expand Up @@ -478,66 +477,48 @@ proto-all: proto-update-deps proto-format proto-lint proto-check-breaking proto-
proto-checks: proto-update-deps proto-lint proto-check-breaking proto-check-breaking-third-party
proto-regen: proto-format proto-gen proto-swagger-gen proto-doc-gen

containerProtoVer=0.14.0
containerProtoImage=ghcr.io/cosmos/proto-builder:$(containerProtoVer)
containerProtoGen=prov-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=prov-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=prov-proto-fmt-$(containerProtoVer)
protoVer=0.15.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

# The proto gen stuff will update go.mod and go.sum in ways we don't want (due to docker stuff).
# So we need to go mod tidy afterward, but it can't go in the scripts for the same reason that we need it.

proto-gen:
@echo "Generating Protobuf files"
cp go.mod .go.mod.bak
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then \
docker start -a $(containerProtoGen); \
else \
docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protocgen.sh; \
fi
$(protoImage) sh ./scripts/protocgen.sh
mv .go.mod.bak go.mod
$(GO) mod tidy

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then \
docker start -a $(containerProtoGenSwagger); \
else \
docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protoc-swagger-gen.sh; \
fi
$(GO) mod tidy
$(protoImage) sh ./scripts/protoc-swagger-gen.sh

proto-doc-gen:
@echo "Generating Protobuf Markdown"
./scripts/proto-doc-gen.sh

proto-format:
@echo "Formatting Protobuf files"
if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then \
docker start -a $(containerProtoFmt); \
else \
docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find . \
-not -path './third_party/*' \
-not -path './vendor/*' \
-not -path './protoBindings/*' \
-name '*.proto' \
-exec clang-format -i {} \; ; \
fi
$(protoImage) find . \
-not -path './third_party/*' \
-not -path './vendor/*' \
-not -path './protoBindings/*' \
-name '*.proto' \
-exec clang-format -i {} \; ; \

proto-lint:
@echo "Linting Protobuf files"
$(DOCKER_BUF) lint --error-format=json
$(protoImage) buf lint --error-format=json

proto-check-breaking:
@echo "Check breaking Protobuf files"
$(DOCKER_BUF) breaking proto --against '$(HTTPS_GIT)#branch=main,subdir=proto' --error-format=json
$(protoImage) buf breaking proto --against '$(HTTPS_GIT)#branch=main,subdir=proto' --error-format=json

proto-check-breaking-third-party:
@echo "Check breaking 3rd party Protobuf files"
$(DOCKER_BUF) breaking third_party/proto --against '$(HTTPS_GIT)#branch=main,subdir=third_party/proto' --error-format=json
$(protoImage) buf breaking third_party/proto --against '$(HTTPS_GIT)#branch=main,subdir=third_party/proto' --error-format=json

proto-update-check:
@echo "Checking for third_party Protobuf updates"
Expand Down
13 changes: 13 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@
]
}
},
{
"url": "./tmp-swagger-gen/provenance/ibchooks/v1/query.swagger.json",
"tags": {
"add": [
"IBC Hooks"
]
},
"operationIds": {
"rename": {
"Params": "IBCHooksParams"
}
}
},
{
"url": "./client/docs/swagger_third_party.yaml",
"dereference": {
Expand Down
Loading

0 comments on commit 363eb32

Please sign in to comment.