Add protolock to build (#1321)

This commit is contained in:
Michal Niewrzal 2019-02-18 08:43:46 +01:00 committed by GitHub
parent c598ed034d
commit 5cf89858c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2467 additions and 2 deletions

View File

@ -56,11 +56,14 @@ matrix:
- cp go.mod go.mod.backup
- go get github.com/ckaznocha/protoc-gen-lint
- go get golang.org/x/tools/go/packages
# install protolock
- go get github.com/nilslice/protolock/cmd/protolock
- cp go.mod.backup go.mod
script:
- go run ./scripts/check-copyright.go
- go run ./scripts/check-imports.go ./...
- go run ./scripts/protobuf.go --protoc=$HOME/protoc/bin/protoc lint
- protolock status
- golangci-lint run
- ./scripts/check-travis-tidy.sh

2438
proto.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,7 @@ func run(command, root string) error {
"github.com/ckaznocha/protoc-gen-lint@68a05858965b31eb872cbeb8d027507a94011acc",
// See https://github.com/gogo/protobuf#most-speed-and-most-customization
"github.com/gogo/protobuf/protoc-gen-gogo@"+gogoVersion,
"github.com/nilslice/protolock/cmd/protolock",
)
case "generate":
return walkdirs(root, generate)
@ -115,12 +116,26 @@ func install(deps ...string) error {
func generate(dir string, dirs []string, files []string) error {
defer switchdir(dir)()
cmd := exec.Command("protolock", "status")
local, err := os.Getwd()
if err != nil {
panic(err)
}
cmd.Dir = findProtolockDir(local)
out, err := cmd.CombinedOutput()
if len(out) > 0 {
fmt.Println(string(out))
}
if err != nil {
return err
}
args := []string{"--gogo_out=plugins=grpc:.", "--lint_out=."}
args = appendCommonArguments(args, dir, dirs, files)
cmd := exec.Command(*protoc, args...)
cmd = exec.Command(*protoc, args...)
fmt.Println(strings.Join(cmd.Args, " "))
out, err := cmd.CombinedOutput()
out, err = cmd.CombinedOutput()
if len(out) > 0 {
fmt.Println(string(out))
}
@ -235,3 +250,12 @@ func listProtoFiles(root string) ([]string, error) {
return files, err
}
func findProtolockDir(dir string) string {
protolock := filepath.Join(dir, "proto.lock")
if _, err := os.Stat(protolock); err != nil {
return findProtolockDir(filepath.Dir(dir))
}
return dir
}