Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions .github/workflows/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Buf
on:
push:
branches: [master]
paths: ['api/proto/**']
pull_request:
paths: ['api/proto/**']

jobs:
buf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-action@v1
with:
token: ${{ secrets.BUF_TOKEN }}
input: api/proto
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,7 @@ Temporary Items

# End of https://www.toptal.com/developers/gitignore/api/macos,intellij,go

/myshoes*
/myshoes*

# Buf
.buf/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /go/src/github.com/whywaita/myshoes

RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
RUN go install github.com/bufbuild/buf/cmd/buf@latest
RUN apt-get update -y \
&& apt-get install -y protobuf-compiler

Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ build-linux: ## Build for Linux
make build-proto
GOOS=linux GOARCH=amd64 go build -o myshoes-linux-amd64 -ldflags $(BUILD_LDFLAGS) cmd/server/cmd.go

build-proto: ## Build proto file
mkdir -p tmp/proto-go
rm -rf api/proto.go
build-proto: ## Build proto file with buf
cd api/proto && buf generate

protoc -I=api/proto/ --go_out=tmp/proto-go/ --go-grpc_out=tmp/proto-go/ api/proto/**.proto
mv tmp/proto-go/github.com/whywaita/myshoes/api/proto.go api/
rm -rf tmp
lint-proto: ## Lint proto files
cd api/proto && buf lint

test: ## Exec test
go test -v ./...
2 changes: 1 addition & 1 deletion api/proto.go/myshoes.pb.go

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

2 changes: 1 addition & 1 deletion api/proto.go/myshoes_grpc.pb.go

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

11 changes: 11 additions & 0 deletions api/proto/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v2
clean: true
plugins:
- remote: buf.build/protocolbuffers/go
out: ../proto.go
opt:
- paths=source_relative
- remote: buf.build/grpc/go
out: ../proto.go
opt:
- paths=source_relative
17 changes: 17 additions & 0 deletions api/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v2
modules:
- path: .
name: buf.build/whywaita/myshoes
lint:
use:
- STANDARD
except:
- PACKAGE_DIRECTORY_MATCH
- ENUM_ZERO_VALUE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- SERVICE_SUFFIX
- ENUM_VALUE_PREFIX
- ENUM_VALUE_UPPER_SNAKE_CASE
breaking:
use:
- FILE
3 changes: 2 additions & 1 deletion api/proto/myshoes.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package whywaita.myshoes;

option go_package = "github.com/whywaita/myshoes/api/proto.go";

service Shoes {
Expand Down Expand Up @@ -40,4 +41,4 @@ message DeleteInstanceRequest {
repeated string labels = 2;
}

message DeleteInstanceResponse {}
message DeleteInstanceResponse {}