CI: Add glyphcheck, rework REST server install

This commit is contained in:
Alexander Neumann 2017-04-27 15:53:59 +02:00
parent 548d4eed95
commit e42627d2cb
1 changed files with 35 additions and 5 deletions

View File

@ -74,6 +74,12 @@ func (env *TravisEnvironment) getMinio() error {
return nil
}
if *restServer != "" {
msg("using REST server at %q\n", *restServer)
env.rest = *restServer
return nil
}
tempfile, err := ioutil.TempFile("", "minio-server-")
if err != nil {
return fmt.Errorf("create tempfile for minio download failed: %v\n", err)
@ -176,18 +182,26 @@ func (env *TravisEnvironment) Prepare() error {
msg("preparing environment for Travis CI\n")
for _, pkg := range []string{
pkgs := []string{
"golang.org/x/tools/cmd/cover",
"github.com/pierrre/gotestcover",
"github.com/restic/rest-server",
} {
"github.com/NebulousLabs/glyphcheck",
}
if env.rest == "" {
pkgs = append(pkgs, "github.com/restic/rest-server")
}
for _, pkg := range pkgs {
err := run("go", "get", pkg)
if err != nil {
return err
}
}
env.rest = filepath.Join(os.Getenv("GOPATH"), "bin", "rest-server")
if env.rest == "" {
env.rest = filepath.Join(os.Getenv("GOPATH"), "bin", "rest-server")
}
if err := env.getMinio(); err != nil {
return err
@ -335,7 +349,7 @@ func (env *TravisEnvironment) RunTests() error {
// do not run fuse tests on darwin
if runtime.GOOS == "darwin" {
msg("skip fuse integration tests on %v\n", runtime.GOOS)
os.Setenv("RESTIC_TEST_FUSE", "0")
_ = os.Setenv("RESTIC_TEST_FUSE", "0")
}
cwd, err := os.Getwd()
@ -374,6 +388,10 @@ func (env *TravisEnvironment) RunTests() error {
return err
}
if err = runGlyphcheck(); err != nil {
return err
}
deps, err := findImports()
if err != nil {
return err
@ -529,6 +547,18 @@ func runGofmt() error {
return nil
}
func runGlyphcheck() error {
cmd := exec.Command("glyphcheck", "./...")
cmd.Stderr = os.Stderr
buf, err := cmd.Output()
if err != nil {
return fmt.Errorf("error running glyphcheck: %v\noutput: %s\n", err, buf)
}
return nil
}
func run(command string, args ...string) error {
msg("run %v %v\n", command, strings.Join(args, " "))
return runWithEnv(nil, command, args...)