Skip to content

Commit e074e3e

Browse files
authored
Merge pull request tokopedia#114 from tokopedia/support_go_package
Force replace go_package declaration
2 parents 7cd9dd5 + b918453 commit e074e3e

File tree

44 files changed

+399
-229
lines changed

Some content is hidden

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

44 files changed

+399
-229
lines changed

.github/workflows/integration-test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,3 @@ jobs:
4242
uses: ./
4343
with:
4444
entrypoint: example/stub-subfolders/entrypoint.sh
45-
- name: Run no go_package example
46-
uses: ./
47-
with:
48-
entrypoint: example/no-gopackage/entrypoint.sh

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ pkged.go
22
gripmock
33
.idea
44
.DS_Store
5-
protogen
5+
protogen/*
6+
!protogen/go.mod
7+
!protogen/example/
8+
temp

Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ RUN mkdir /proto
44

55
RUN mkdir /stubs
66

7-
RUN apk -U --no-cache add git protobuf
7+
RUN apk -U --no-cache add git protobuf bash
88

9-
RUN go get -u -v github.com/golang/protobuf/protoc-gen-go \
10-
google.golang.org/grpc \
11-
google.golang.org/grpc/reflection \
12-
golang.org/x/net/context \
13-
github.com/go-chi/chi \
14-
github.com/lithammer/fuzzysearch/fuzzy \
15-
golang.org/x/tools/imports
9+
RUN go install -v github.com/golang/protobuf/protoc-gen-go@latest
1610

17-
RUN go get github.com/markbates/pkger/cmd/pkger
11+
RUN go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
12+
13+
RUN go install github.com/markbates/pkger/cmd/pkger@latest
1814

1915
# cloning well-known-types
2016
RUN git clone --depth=1 https://github.com/google/protobuf.git /protobuf-repo
@@ -30,6 +26,8 @@ RUN mkdir -p /go/src/github.com/tokopedia/gripmock
3026

3127
COPY . /go/src/github.com/tokopedia/gripmock
3228

29+
RUN ln -s /go/src/github.com/tokopedia/gripmock/fix_gopackage.sh /bin/
30+
3331
WORKDIR /go/src/github.com/tokopedia/gripmock/protoc-gen-gripmock
3432

3533
RUN pkger
@@ -42,6 +40,9 @@ WORKDIR /go/src/github.com/tokopedia/gripmock
4240
# install gripmock
4341
RUN go install -v
4442

43+
# to cache necessary imports
44+
RUN go build ./example/simple/client
45+
4546
# remove all .pb.go generated files
4647
# since generating go file is part of the test
4748
RUN find . -name "*.pb.go" -delete -type f

example/multi-files/client/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import (
55
"log"
66
"time"
77

8-
pb "github.com/tokopedia/gripmock/example/multi-files"
8+
pb "github.com/tokopedia/gripmock/protogen/example/multi-files"
99
"google.golang.org/grpc"
1010
)
1111

12-
//go:generate protoc --go_out=plugins=grpc:${GOPATH}/src -I=.. ../file1.proto ../file2.proto
1312
func main() {
1413
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
1514
defer cancel()

example/multi-package/client/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import (
66
"os"
77
"time"
88

9-
pb "github.com/tokopedia/gripmock/example/multi-package"
10-
multi_package "github.com/tokopedia/gripmock/example/multi-package/bar"
9+
pb "github.com/tokopedia/gripmock/protogen/example/multi-package"
10+
multi_package "github.com/tokopedia/gripmock/protogen/example/multi-package/bar"
1111
"google.golang.org/grpc"
1212
)
1313

14-
//go:generate protoc --go_out=plugins=grpc:${GOPATH}/src -I=.. ../hello.proto ../foo.proto ../bar/bar.proto
1514
func main() {
1615
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
1716
defer cancel()

example/multi-package/foo.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ syntax = "proto3";
44
// but different package
55
package foo;
66

7-
option go_package = "github.com/tokopedia/gripmock/example/multi-package";
7+
// simulating dummy private repo
8+
option go_package = "github.com/my/private/repo/multi-package";
89

910
message Response {
1011
string response = 1;

example/multi-package/hello.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ package multi_package;
55
import "bar/bar.proto";
66
import "foo.proto";
77

8-
// simulate go_package alias with -
9-
option go_package = "github.com/tokopedia/gripmock/example/multi-package";
8+
// simulate no go_package and folder with -
109

1110
service Gripmock {
1211
rpc Greet (bar.Bar) returns (foo.Response);

example/no-gopackage/bar/bar.proto

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/no-gopackage/bar/deep/bar.proto

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/no-gopackage/client/main.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)