Skip to content

Commit

Permalink
chore: Add code coverage test (#560)
Browse files Browse the repository at this point in the history
* chore: Add travis and code coverage

* README: Update

Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege authored and k8s-ci-robot committed May 20, 2019
1 parent 22ac009 commit 65290ca
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 14 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: go

go:
- "1.10"
- "1.11"
- "1.12"

go_import_path: github.com/kubeflow/katib

install:
- curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v1.0.7/kubebuilder_1.0.7_linux_amd64.tar.gz"
- # extract the archive
- tar -zxvf kubebuilder_1.0.7_linux_amd64.tar.gz
- sudo mv kubebuilder_1.0.7_linux_amd64 /usr/local/kubebuilder
- export PATH=$PATH:/usr/local/kubebuilder/bin
# get coveralls.io support
- go get github.com/mattn/goveralls

script:
- make test
- goveralls -coverprofile=coverage.out
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Run tests
.PHONY: test
test:
go test ./pkg/... ./cmd/...
go test ./pkg/... ./cmd/... -coverprofile coverage.out

# Build Katib images
build:
sh scripts/v1alpha1/build.sh
bash scripts/v1alpha1/build.sh

# Deploy katib manifests into a k8s cluster
deploy:
sh scripts/v1alpha1/deploy.sh
bash scripts/v1alpha1/deploy.sh

# Run go fmt against code
fmt:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<br>
</h1>

[![Build Status](https://travis-ci.org/kubeflow/katib.svg?branch=master)](https://travis-ci.org/kubeflow/katib)
[![Coverage Status](https://coveralls.io/repos/github/kubeflow/katib/badge.svg?branch=master)](https://coveralls.io/github/kubeflow/katib?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/kubeflow/katib)](https://goreportcard.com/report/github.com/kubeflow/katib)

Hyperparameter Tuning on Kubernetes.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/common/v1alpha2/katib_manager_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ func GetSuggestions(request *api_pb.GetSuggestionsRequest) (*api_pb.GetSuggestio
defer closeKatibManagerConnection(kcc)
kc := kcc.KatibManagerClient
return kc.GetSuggestions(ctx, request)
}
}
2 changes: 1 addition & 1 deletion pkg/controller/v1alpha1/studyjob/manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"fmt"
"text/template"

common "github.com/kubeflow/katib/pkg/common/v1alpha1"
katibv1alpha1 "github.com/kubeflow/katib/pkg/api/operators/apis/studyjob/v1alpha1"
katibapi "github.com/kubeflow/katib/pkg/api/v1alpha1"
common "github.com/kubeflow/katib/pkg/common/v1alpha1"
"github.com/kubeflow/katib/pkg/manager/v1alpha1/studyjobclient"

"k8s.io/apimachinery/pkg/util/uuid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ data:
- "fakens"
- "-mn"
- "test"`

if expected != actual.String() {
t.Errorf("Expected %s, got %s", expected, actual)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/v1alpha2/trial/trial_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func Add(mgr manager.Manager) error {
// newReconciler returns a new reconcile.Reconciler
func newReconciler(mgr manager.Manager) reconcile.Reconciler {
r := &ReconcileTrial{
Client: mgr.GetClient(),
scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
scheme: mgr.GetScheme(),
ManagerClient: managerclient.New(),
}
r.updateStatusHandler = r.updateStatus
Expand Down

0 comments on commit 65290ca

Please sign in to comment.