Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix our proto code and swagger generation. #2167

Merged
merged 13 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,62 +477,44 @@ 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

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

SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved
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
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved

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
Loading