Skip to content

Commit

Permalink
fix: swagger generation from buf-defined deps, migrate to json format… (
Browse files Browse the repository at this point in the history
#257)

* fix: swagger generation from buf-defined deps, migrate to json format, nixify some deps

* refactor: use newer proto-builder, adopt buf in gh actions

* fix: disable break-check as master depends on cosmos protos newer than it supposed to

* ci: buf push

* ci: buf push drafts on non-master branches

* ci: buf push even if proto haven't changed

* ci: buf push draft if not in master

* deps: fix ibc deps versions

* deps: fix proto gen
  • Loading branch information
onsails authored Nov 17, 2023
1 parent 8d5d1b3 commit c02701d
Show file tree
Hide file tree
Showing 47 changed files with 25,847 additions and 65,496 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.direnv
.devenv
build
localnet-setup
docker
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use flake
use flake --impure
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ x/**/spec/* linguist-documentation
**/*.pb.go linguist-generated
**/*.pb.gw.go linguist-generated
*.gz filter=lfs diff=lfs merge=lfs -text
flake.lock linguist-generated
21 changes: 21 additions & 0 deletions .github/workflows/proto-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Buf-Push
# Protobuf runs buf (https://buf.build/) push updated proto files to https://buf.build/cosmos/cosmos-sdk
# This workflow is only run when a .proto file has been changed
on:
push:
# branches:
# - master
# paths:
# - "proto/**"

jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-push-action@v1
with:
input: "proto"
buf_token: ${{ secrets.BUF_TOKEN }}
draft: ${{ github.ref_name != 'master'}}
43 changes: 29 additions & 14 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,43 @@ name: Protobuf
# This workflow is only run when a .proto file has been changed
on:
pull_request:
paths:
- "proto/**"

jobs:
lint:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/[email protected]
- uses: technote-space/get-diff-action@v5
- uses: actions/checkout@v4
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/**.proto
- name: lint
run: make proto-lint
**/buf.yaml
buf.work.yaml
buf.gen.yaml
- run: |
make proto-gen
if: env.GIT_DIFF
breakage:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/[email protected]
- uses: technote-space/get-diff-action@v5
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-lint-action@v1
with:
PATTERNS: |
**/**.proto
- name: check-breakage
run: make proto-check-breaking
if: env.GIT_DIFF
input: "proto"

# FIXME: enable after merging
# break-check:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: bufbuild/[email protected]
# - uses: bufbuild/buf-breaking-action@v1
# with:
# input: "proto"
# against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ dependency-graph.png
tests/**/node_modules/*
tests-solidity/**/node_modules/*
node_modules

swagger-proto
tmp-swagger-gen
.devenv
62 changes: 28 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ clean:
rm -rf \
$(BUILDDIR)/ \
artifacts/ \
tmp-swagger-gen/
tmp-swagger-gen/ \
swagger-proto/

all: build

Expand Down Expand Up @@ -207,7 +208,7 @@ endif

ifeq (, $(shell which go-bindata))
@echo "Installing go-bindata..."
@go get github.com/kevinburke/go-bindata/go-bindata
@go install github.com/kevinburke/go-bindata/v4/...@latest
else
@echo "go-bindata already installed; skipping..."
endif
Expand Down Expand Up @@ -446,23 +447,10 @@ format:
### Protobuf ###
###############################################################################

# ------
# NOTE: Link to the tendermintdev/sdk-proto-gen docker images:
# https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags
#
protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
protoImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
# ------
# NOTE: cosmos/proto-builder image is needed because clang-format is not installed
# on the tendermintdev/sdk-proto-gen docker image.
# Link to the cosmos/proto-builder docker images:
# https://github.com/cosmos/cosmos-sdk/pkgs/container/proto-builder
#
protoCosmosVer=0.11.2
protoCosmosName=ghcr.io/cosmos/proto-builder:$(protoCosmosVer)
protoCosmosImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoCosmosName)
# ------
# NOTE: Link to the yoheimuta/protolint docker images:
# https://hub.docker.com/r/yoheimuta/protolint/tags
#
Expand All @@ -476,21 +464,27 @@ proto-gen:
@echo "Generating Protobuf files"
$(protoImage) sh ./scripts/protocgen.sh

SWAGGER_DIR=$(realpath .)/swagger-proto
export THIRD_PARTY_DIR=$(SWAGGER_DIR)/third_party

proto-swagger-download-deps:
@./scripts/proto-swagger-download-deps.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@make proto-swagger-download-deps
@./scripts/protoc-swagger-gen.sh

proto-format:
@echo "Formatting Protobuf files"
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
find ./ -not -path ".//.devenv/*" -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;

proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.15/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.45.1
Expand All @@ -506,30 +500,30 @@ GOGO_PROTO_TYPES = third_party/proto/gogoproto

COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto

proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto
# proto-update-deps:
# @mkdir -p $(GOGO_PROTO_TYPES)
# @curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(COSMOS_PROTO_TYPES)
@curl -sSL $(COSMOS_PROTO_URL)/proto/cosmos_proto/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto
# @mkdir -p $(COSMOS_PROTO_TYPES)
# @curl -sSL $(COSMOS_PROTO_URL)/proto/cosmos_proto/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto

## Importing of tendermint protobuf definitions currently requires the
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
## (which is the standard Buf.build FILE_LAYOUT)
## Issue link: https://github.com/tendermint/tendermint/issues/5021
@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto
# ## Importing of tendermint protobuf definitions currently requires the
# ## use of `sed` in order to build properly with cosmos-sdk's proto file layout
# ## (which is the standard Buf.build FILE_LAYOUT)
# ## Issue link: https://github.com/tendermint/tendermint/issues/5021
# @mkdir -p $(TM_ABCI_TYPES)
# @curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto

@mkdir -p $(TM_TYPES)
@curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
# @mkdir -p $(TM_TYPES)
# @curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto

@mkdir -p $(TM_CRYPTO_TYPES)
@curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto
# @mkdir -p $(TM_CRYPTO_TYPES)
# @curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
# @curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto



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

###############################################################################
### Localnet ###
Expand Down
162 changes: 0 additions & 162 deletions client/docs/config.json

This file was deleted.

8 changes: 5 additions & 3 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit c02701d

Please sign in to comment.