Add protolock to build (#1321)
This commit is contained in:
parent
c598ed034d
commit
5cf89858c2
@ -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
2438
proto.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user