Fail if formatting is wrong in our CI tests. (#4459)

We didn't fail before, we should helps in avoiding
formatting issues to creep into the codebase.
master
Harshavardhana 8 years ago committed by GitHub
parent 18c4e5d357
commit 432bf7d99e
  1. 2
      .travis.yml
  2. 62
      Makefile
  3. 10
      cmd/admin-handlers_test.go
  4. 5
      cmd/gateway-main.go
  5. 2
      cmd/storage-rpc-client.go
  6. 2
      cmd/xl-v1-metadata_test.go

@ -18,6 +18,8 @@ env:
script: script:
## Run all the tests ## Run all the tests
- make - make
- diff -au <(gofmt -d cmd) <(printf "")
- diff -au <(gofmt -d pkg) <(printf "")
- make test GOFLAGS="-timeout 15m -race -v" - make test GOFLAGS="-timeout 15m -race -v"
- make coverage - make coverage

@ -1,6 +1,7 @@
LDFLAGS := $(shell go run buildscripts/gen-ldflags.go) LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
PWD := $(shell pwd) PWD := $(shell pwd)
GOPATH := $(shell go env GOPATH) GOPATH := $(shell go env GOPATH)
BUILD_LDFLAGS := '$(LDFLAGS)' BUILD_LDFLAGS := '$(LDFLAGS)'
TAG := latest TAG := latest
@ -56,55 +57,43 @@ endif
all: install all: install
checks: checks:
@echo -n "Check deps: " @echo "Check deps"
@(env bash $(PWD)/buildscripts/checkdeps.sh) @(env bash $(PWD)/buildscripts/checkdeps.sh)
@echo "Done." @echo "Checking project is in GOPATH"
@echo -n "Checking project is in GOPATH: "
@(env bash $(PWD)/buildscripts/checkgopath.sh) @(env bash $(PWD)/buildscripts/checkgopath.sh)
@echo "Done."
getdeps: checks getdeps: checks
@echo -n "Installing golint: " && go get -u github.com/golang/lint/golint @echo "Installing golint" && go get -u github.com/golang/lint/golint
@echo "Done." @echo "Installing gocyclo" && go get -u github.com/fzipp/gocyclo
@echo -n "Installing gocyclo: " && go get -u github.com/fzipp/gocyclo @echo "Installing deadcode" && go get -u github.com/remyoudompheng/go-misc/deadcode
@echo "Done." @echo "Installing misspell" && go get -u github.com/client9/misspell/cmd/misspell
@echo -n "Installing deadcode: " && go get -u github.com/remyoudompheng/go-misc/deadcode @echo "Installing ineffassign" && go get -u github.com/gordonklaus/ineffassign
@echo "Done."
@echo -n "Installing misspell: " && go get -u github.com/client9/misspell/cmd/misspell
@echo "Done."
@echo -n "Installing ineffassign: " && go get -u github.com/gordonklaus/ineffassign
@echo "Done."
verifiers: vet fmt lint cyclo spelling verifiers: vet fmt lint cyclo spelling
vet: vet:
@echo -n "Running $@: " @echo "Running $@"
@go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult cmd @go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult cmd
@go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult pkg @go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult pkg
@echo "Done."
fmt: fmt:
@echo -n "Running $@: " @echo "Running $@"
@gofmt -s -l cmd @gofmt -d cmd
@gofmt -s -l pkg @gofmt -d pkg
@echo "Done."
lint: lint:
@echo -n "Running $@: " @echo "Running $@"
@${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/cmd... @${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/cmd...
@${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/pkg... @${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/pkg...
@echo "Done."
ineffassign: ineffassign:
@echo -n "Running $@: " @echo "Running $@"
@${GOPATH}/bin/ineffassign . @${GOPATH}/bin/ineffassign .
@echo "Done."
cyclo: cyclo:
@echo -n "Running $@: " @echo "Running $@"
@${GOPATH}/bin/gocyclo -over 100 cmd @${GOPATH}/bin/gocyclo -over 100 cmd
@${GOPATH}/bin/gocyclo -over 100 pkg @${GOPATH}/bin/gocyclo -over 100 pkg
@echo "Done."
build: getdeps verifiers $(UI_ASSETS) build: getdeps verifiers $(UI_ASSETS)
@ -117,30 +106,30 @@ spelling:
@${GOPATH}/bin/misspell -error `find docs/` @${GOPATH}/bin/misspell -error `find docs/`
test: build test: build
@echo -n "Running all minio testing: " @echo "Running all minio testing"
@go test $(GOFLAGS) . @go test $(GOFLAGS) .
@go test $(GOFLAGS) github.com/minio/minio/cmd... @go test $(GOFLAGS) github.com/minio/minio/cmd...
@go test $(GOFLAGS) github.com/minio/minio/pkg... @go test $(GOFLAGS) github.com/minio/minio/pkg...
@echo "Done."
coverage: build coverage: build
@echo "Running all coverage for minio: " @echo "Running all coverage for minio"
@./buildscripts/go-coverage.sh @./buildscripts/go-coverage.sh
@echo "Done."
gomake-all: build gomake-all: build
@echo -n "Installing minio at $(GOPATH)/bin/minio: " @echo "Installing minio at $(GOPATH)/bin/minio"
@go build --ldflags $(BUILD_LDFLAGS) -o $(GOPATH)/bin/minio @go build --ldflags $(BUILD_LDFLAGS) -o $(GOPATH)/bin/minio
@echo "Done."
pkg-add: pkg-add:
${GOPATH}/bin/govendor add $(PKG) @echo "Adding new package $(PKG)"
@${GOPATH}/bin/govendor add $(PKG)
pkg-update: pkg-update:
${GOPATH}/bin/govendor update $(PKG) @echo "Updating new package $(PKG)"
@${GOPATH}/bin/govendor update $(PKG)
pkg-remove: pkg-remove:
${GOPATH}/bin/govendor remove $(PKG) @echo "Remove new package $(PKG)"
@${GOPATH}/bin/govendor remove $(PKG)
pkg-list: pkg-list:
@$(GOPATH)/bin/govendor list @$(GOPATH)/bin/govendor list
@ -154,8 +143,7 @@ experimental: verifiers
@MINIO_RELEASE=EXPERIMENTAL ./buildscripts/build.sh @MINIO_RELEASE=EXPERIMENTAL ./buildscripts/build.sh
clean: clean:
@echo -n "Cleaning up all the generated files: " @echo "Cleaning up all the generated files"
@find . -name '*.test' | xargs rm -fv @find . -name '*.test' | xargs rm -fv
@rm -rf build @rm -rf build
@rm -rf release @rm -rf release
@echo "Done."

@ -731,7 +731,7 @@ func TestListObjectsHealHandler(t *testing.T) {
} }
defer adminTestBed.TearDown() defer adminTestBed.TearDown()
err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket","") err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket", "")
if err != nil { if err != nil {
t.Fatalf("Failed to make bucket - %v", err) t.Fatalf("Failed to make bucket - %v", err)
} }
@ -859,7 +859,7 @@ func TestHealBucketHandler(t *testing.T) {
} }
defer adminTestBed.TearDown() defer adminTestBed.TearDown()
err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket","") err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket", "")
if err != nil { if err != nil {
t.Fatalf("Failed to make bucket - %v", err) t.Fatalf("Failed to make bucket - %v", err)
} }
@ -936,7 +936,7 @@ func TestHealObjectHandler(t *testing.T) {
// Create an object myobject under bucket mybucket. // Create an object myobject under bucket mybucket.
bucketName := "mybucket" bucketName := "mybucket"
objName := "myobject" objName := "myobject"
err = adminTestBed.objLayer.MakeBucketWithLocation(bucketName,"") err = adminTestBed.objLayer.MakeBucketWithLocation(bucketName, "")
if err != nil { if err != nil {
t.Fatalf("Failed to make bucket %s - %v", bucketName, err) t.Fatalf("Failed to make bucket %s - %v", bucketName, err)
} }
@ -1067,7 +1067,7 @@ func TestHealUploadHandler(t *testing.T) {
// Create an object myobject under bucket mybucket. // Create an object myobject under bucket mybucket.
bucketName := "mybucket" bucketName := "mybucket"
objName := "myobject" objName := "myobject"
err = adminTestBed.objLayer.MakeBucketWithLocation(bucketName,"") err = adminTestBed.objLayer.MakeBucketWithLocation(bucketName, "")
if err != nil { if err != nil {
t.Fatalf("Failed to make bucket %s - %v", bucketName, err) t.Fatalf("Failed to make bucket %s - %v", bucketName, err)
} }
@ -1455,7 +1455,7 @@ func TestListHealUploadsHandler(t *testing.T) {
} }
defer adminTestBed.TearDown() defer adminTestBed.TearDown()
err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket","") err = adminTestBed.objLayer.MakeBucketWithLocation("mybucket", "")
if err != nil { if err != nil {
t.Fatalf("Failed to make bucket - %v", err) t.Fatalf("Failed to make bucket - %v", err)
} }

@ -99,7 +99,7 @@ func mustGetGatewayCredsFromEnv() (accessKey, secretKey string) {
} }
// Set browser setting from environment variables // Set browser setting from environment variables
func mustSetBrowserSettingFromEnv(){ func mustSetBrowserSettingFromEnv() {
if browser := os.Getenv("MINIO_BROWSER"); browser != "" { if browser := os.Getenv("MINIO_BROWSER"); browser != "" {
browserFlag, err := ParseBrowserFlag(browser) browserFlag, err := ParseBrowserFlag(browser)
if err != nil { if err != nil {
@ -112,6 +112,7 @@ func mustSetBrowserSettingFromEnv(){
globalIsBrowserEnabled = bool(browserFlag) globalIsBrowserEnabled = bool(browserFlag)
} }
} }
// Initialize gateway layer depending on the backend type. // Initialize gateway layer depending on the backend type.
// Supported backend types are // Supported backend types are
// //
@ -192,7 +193,7 @@ func gatewayMain(ctx *cli.Context) {
mustSetBrowserSettingFromEnv() mustSetBrowserSettingFromEnv()
// Initialize new gateway config. // Initialize new gateway config.
newGatewayConfig(accessKey, secretKey, globalMinioDefaultRegion) newGatewayConfig(accessKey, secretKey, globalMinioDefaultRegion)
// Get quiet flag from command line argument. // Get quiet flag from command line argument.

@ -28,7 +28,7 @@ import (
) )
type networkStorage struct { type networkStorage struct {
rpcClient *AuthRPCClient rpcClient *AuthRPCClient
} }
const ( const (

@ -113,7 +113,7 @@ func testXLReadMetaParts(obj ObjectLayer, instanceType string, disks []string, t
// objectNames[0]. // objectNames[0].
// uploadIds [0]. // uploadIds [0].
// Create bucket before intiating NewMultipartUpload. // Create bucket before intiating NewMultipartUpload.
err := obj.MakeBucketWithLocation(bucketNames[0] ,"") err := obj.MakeBucketWithLocation(bucketNames[0], "")
if err != nil { if err != nil {
// Failed to create newbucket, abort. // Failed to create newbucket, abort.
t.Fatalf("%s : %s", instanceType, err.Error()) t.Fatalf("%s : %s", instanceType, err.Error())

Loading…
Cancel
Save