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: add commands for generating go types #16

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

## proto-gen-docker: Generate protobuf files. Requires docker.
proto-gen-docker:
@echo "--> Generating Protobuf files"
$(DOCKER_BUF) generate
.PHONY: proto-gen-docker

## proto-gen: Generate protobuf files. Requires buf.
proto-gen:
@echo "--> Generating Protobuf files"
@buf generate
.PHONY: proto-gen
Copy link
Collaborator

@rootulp rootulp Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] do we want to support two different ways to generate the Protobuf files? I think it may be easier to maintain just one option and if that option is used in CI as well as locally. Since the make proto-gen command depends on a locally installed Buf CLI, preference for the Docker approach.

Ideally the Docker approach uses the same version of Buf locally and in CI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably look to enforce it somehow. The docker image also isn't versioned (I actually had a problem where it wasn't working because I had an old image.

I think some people don't like using docker, hence why I added the other option, but it's simple enough that it probably doesn't need a make command so I will remove it

Copy link
Collaborator

@rootulp rootulp Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I think the Docker approach should also be versioned but not blocking on it.


## proto-lint-docker: Lint protobuf files. Requires docker.
proto-lint-docker:
@echo "--> Linting Protobuf files"
@$(DOCKER_BUF) lint
.PHONY: proto-lint
2 changes: 1 addition & 1 deletion merkle/proto/buf.gen.yaml → buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v1
plugins:
- plugin: buf.build/protocolbuffers/go
out: gen
out: .
opt:
- paths=source_relative
6 changes: 3 additions & 3 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: v1
roots:
-proto
name: buf.build/celestiaorg/go-square
breaking:
use:
- FILE
lint:
use:
- DEFAULT
- BASIC

Check failure on line 9 in buf.yaml

View workflow job for this annotation

GitHub Actions / lint / yamllint

9:1 [empty-lines] too many blank lines (1 > 0)
cmwaters marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion merkle/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"errors"
"fmt"

wire "github.com/celestiaorg/go-square/merkle/proto/gen/merkle/v1"
wire "github.com/celestiaorg/go-square/merkle/proto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion merkle/proof_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"

wire "github.com/celestiaorg/go-square/merkle/proto/gen/merkle/v1"
wire "github.com/celestiaorg/go-square/merkle/proto"
)

//----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion merkle/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"testing"

wire "github.com/celestiaorg/go-square/merkle/proto/gen/merkle/v1"
wire "github.com/celestiaorg/go-square/merkle/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
Expand Down
2 changes: 1 addition & 1 deletion merkle/proof_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/sha256"
"fmt"

wire "github.com/celestiaorg/go-square/merkle/proto/gen/merkle/v1"
wire "github.com/celestiaorg/go-square/merkle/proto"
"google.golang.org/protobuf/proto"
)

Expand Down
164 changes: 82 additions & 82 deletions merkle/proto/gen/merkle/v1/proof.pb.go → merkle/proto/proof.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package square.merkle;
package merkle.proto;

option go_package = "github.com/celestiaorg/go-square/merkle";

Expand Down
129 changes: 64 additions & 65 deletions pkg/blob/blob.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package square.blob.v1;
package pkg.blob;

option go_package = "github.com/celestiaorg/go-square/pkg/blob";

Expand Down
6 changes: 0 additions & 6 deletions proto/buf.gen.yaml

This file was deleted.

Loading