Skip to content

Commit

Permalink
feat: Replace gometalinter with golangci-lint (kubeflow#1081)
Browse files Browse the repository at this point in the history
* feat: Replace gometaliner with golangci-lint

Signed-off-by: Ce Gao <[email protected]>

* fix: Fix go version

Signed-off-by: Ce Gao <[email protected]>

* fix: Update goveralls

Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege authored and k8s-ci-robot committed Sep 11, 2019
1 parent 18aeadc commit 5c0a06b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 51 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
language: go

go:
- "1.10"
- "1.12"

go_import_path: github.com/kubeflow/tf-operator

install:
# get coveralls.io support
- go get github.com/mattn/goveralls
- go get -u github.com/alecthomas/gometalinter
- gometalinter --install
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.18.0
- go install ./vendor/k8s.io/code-generator/cmd/openapi-gen

script:
- hack/verify-codegen.sh
- go build -o tf-operator.v1 github.com/kubeflow/tf-operator/cmd/tf-operator.v1
- go build -o backend github.com/kubeflow/tf-operator/dashboard/backend
- gometalinter --config=linter_config.json --vendor ./...
- golangci-lint run ./...
# We customize the build step because by default
# Travis runs go test -v ./... which will include the vendor
# directory.
# With go 1.9 vendor will be automatically excluded.
# For now though we just run all tests in pkg.
# And we can not use ** because goveralls uses filepath.Match
# to match ignore files and it does not support it.
- goveralls -service=travis-ci -v -package ./pkg/... -ignore "pkg/client/*/*.go,pkg/client/*/*/*.go,pkg/client/*/*/*/*.go,pkg/client/*/*/*/*/*.go,pkg/client/*/*/*/*/*/*.go,pkg/client/*/*/*/*/*/*/*.go,pkg/util/testutil/*.go,pkg/apis/tensorflow/*/zz_generated.*.go,pkg/apis/tensorflow/*/*_generated.go,pkg/apis/common/*/zz_generated.*.go,pkg/apis/common/*/*_generated.go"
- goveralls -service=travis-ci -v -package ./pkg/... -ignore "pkg/client/*/*.go,pkg/client/*/*/*.go,pkg/client/*/*/*/*.go,pkg/client/*/*/*/*/*.go,pkg/client/*/*/*/*/*/*.go,pkg/client/*/*/*/*/*/*/*.go,pkg/util/*.go,pkg/util/*/*.go,pkg/apis/tensorflow/*/zz_generated.*.go,pkg/apis/tensorflow/*/*_generated.go,pkg/apis/common/*/zz_generated.*.go,pkg/apis/common/*/*_generated.go"

notifications:
webhooks: https://www.travisbuddy.com/
Expand Down
37 changes: 0 additions & 37 deletions linter_config.json

This file was deleted.

8 changes: 6 additions & 2 deletions pkg/controller.v1/tensorflow/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ func TestAddTFJob(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run the controller: %v", err)
}
}
go run(stopCh)

Expand Down Expand Up @@ -139,7 +141,9 @@ func TestCopyLabelsAndAnnotation(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run the controller: %v", err)
}
}
go run(stopCh)

Expand Down
16 changes: 10 additions & 6 deletions pkg/controller.v1/tensorflow/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func TestAddPod(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run the controller: %v", err)
}
}
go run(stopCh)

Expand Down Expand Up @@ -166,7 +168,7 @@ func TestRestartPolicy(t *testing.T) {
specRestartPolicy := common.RestartPolicyExitCode
tfJob.Spec.TFReplicaSpecs[tfv1.TFReplicaTypeWorker].RestartPolicy = specRestartPolicy
return tc{
tfJob: tfJob,
tfJob: tfJob,
expectedRestartPolicy: v1.RestartPolicyNever,
expectedType: tfv1.TFReplicaTypeWorker,
}
Expand All @@ -176,7 +178,7 @@ func TestRestartPolicy(t *testing.T) {
specRestartPolicy := common.RestartPolicyNever
tfJob.Spec.TFReplicaSpecs[tfv1.TFReplicaTypeWorker].RestartPolicy = specRestartPolicy
return tc{
tfJob: tfJob,
tfJob: tfJob,
expectedRestartPolicy: v1.RestartPolicyNever,
expectedType: tfv1.TFReplicaTypeWorker,
}
Expand All @@ -186,7 +188,7 @@ func TestRestartPolicy(t *testing.T) {
specRestartPolicy := common.RestartPolicyAlways
tfJob.Spec.TFReplicaSpecs[tfv1.TFReplicaTypeWorker].RestartPolicy = specRestartPolicy
return tc{
tfJob: tfJob,
tfJob: tfJob,
expectedRestartPolicy: v1.RestartPolicyAlways,
expectedType: tfv1.TFReplicaTypeWorker,
}
Expand All @@ -196,7 +198,7 @@ func TestRestartPolicy(t *testing.T) {
specRestartPolicy := common.RestartPolicyOnFailure
tfJob.Spec.TFReplicaSpecs[tfv1.TFReplicaTypeWorker].RestartPolicy = specRestartPolicy
return tc{
tfJob: tfJob,
tfJob: tfJob,
expectedRestartPolicy: v1.RestartPolicyOnFailure,
expectedType: tfv1.TFReplicaTypeWorker,
}
Expand Down Expand Up @@ -249,7 +251,9 @@ func TestExitCode(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run the controller: %v", err)
}
}
go run(stopCh)

Expand Down
4 changes: 3 additions & 1 deletion pkg/controller.v1/tensorflow/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func TestAddService(t *testing.T) {

stopCh := make(chan struct{})
run := func(<-chan struct{}) {
ctr.Run(testutil.ThreadCount, stopCh)
if err := ctr.Run(testutil.ThreadCount, stopCh); err != nil {
t.Errorf("Failed to run the controller: %v", err)
}
}
go run(stopCh)

Expand Down

0 comments on commit 5c0a06b

Please sign in to comment.