Skip to content

Commit

Permalink
Add CI to run the tests for Go (#1440)
Browse files Browse the repository at this point in the history
* add test for Go to CI

Signed-off-by: tenzen-y <[email protected]>

* fix golangci-lint errors

Signed-off-by: tenzen-y <[email protected]>

* fix Go test

* fix coverage report file name

Signed-off-by: tenzen-y <[email protected]>

* use Go 1.17

Signed-off-by: tenzen-y <[email protected]>

* fix error comments

Signed-off-by: tenzen-y <[email protected]>

* fix coverage badge in readme

Signed-off-by: tenzen-y <[email protected]>

* fix e2e test

Signed-off-by: tenzen-y <[email protected]>

* skip testServerImage

Signed-off-by: tenzen-y <[email protected]>

* fix e2e test PATH

Signed-off-by: tenzen-y <[email protected]>
  • Loading branch information
tenzen-y authored Oct 8, 2021
1 parent f45ba08 commit 7cdc253
Show file tree
Hide file tree
Showing 33 changed files with 179 additions and 173 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Go Test

on:
- push
- pull_request

jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}/go
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/kubeflow/training-operator

steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ${{ env.GOPATH }}/src/github.com/kubeflow/training-operator

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17.1

- name: Check Go modules
run: |
go mod tidy && git add go.*
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit1);
- name: Check manifests
run: |
make manifests && git add manifests
git diff --cached --exit-code || (echo 'Please run "make manifests" to generate manifests' && exit1);
- name: Check auto-generated codes
run: |
make generate && git add pkg/apis
git diff --cached --exit-code || (echo 'Please run "make generate" to generate Go codes' && exit1);
- name: Verify gofmt
run: |
make fmt && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit1);
- name: Verify govet
run: |
make vet && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit1);
- name: Run Go test
run: make test
- name: Coveralls report
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: cover.out
working-directory: ${{ env.GOPATH }}/src/github.com/kubeflow/training-operator
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bin/
/tf-operator
vendor/
testbin/*
cover.out

# IDEs
.vscode/
Expand Down
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

GOLANGCI_LINT=$(shell which golangci-lint)
golangci-lint:
ifeq ($(GOLANGCI_LINT),)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.42.1
$(info golangci-lint has been installed)
endif
golangci-lint run --timeout 5m ./...

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate fmt vet ## Run tests.
test: manifests generate fmt vet golangci-lint ## Run tests.
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Kubeflow Training Operator

[![Build Status](https://travis-ci.org/kubeflow/tf-operator.svg?branch=master)](https://travis-ci.org/kubeflow/tf-operator)
[![Coverage Status](https://coveralls.io/repos/github/kubeflow/tf-operator/badge.svg?branch=master)](https://coveralls.io/github/kubeflow/tf-operator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/kubeflow/tf-operator)](https://goreportcard.com/report/github.com/kubeflow/tf-operator)
[![Build Status](https://github.com/kubeflow/training-operator/actions/workflows/test-go.yaml/badge.svg?branch=master)](https://github.com/kubeflow/training-operator/actions/workflows/test-go.yaml?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/kubeflow/training-operator/badge.svg?branch=master)](https://coveralls.io/github/kubeflow/tf-operator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/kubeflow/training-operator)](https://goreportcard.com/report/github.com/kubeflow/training-operator)

## Overview

Expand Down
6 changes: 5 additions & 1 deletion docs/development/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Tf-operator is currently at v1.

## Requirements

- [Go](https://golang.org/) (1.17 or later)

## Building the operator

Create a symbolic link inside your GOPATH to the location you checked out the code
Expand All @@ -16,7 +20,7 @@ ln -sf ${GIT_TRAINING} ${go env GOPATH}/src/github.com/kubeflow/tf-operator
Install dependencies

```sh
GO111MODULE="on" go mod vendor
go mod vendor
```

Build it
Expand Down
74 changes: 71 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module github.com/kubeflow/tf-operator

go 1.14
go 1.17

require (
github.com/go-logr/logr v0.3.0
github.com/go-openapi/spec v0.20.3
github.com/kubeflow/common v0.3.7
github.com/onrik/logrus v0.2.2-0.20181225141908-a09d5cdcdc62
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/prometheus/client_golang v1.10.0
github.com/sirupsen/logrus v1.6.0
k8s.io/api v0.19.9
k8s.io/apiextensions-apiserver v0.19.9
k8s.io/apiextensions-apiserver v0.19.9 // indirect
k8s.io/apimachinery v0.19.9
k8s.io/client-go v0.19.9
k8s.io/code-generator v0.19.9
Expand All @@ -21,3 +20,72 @@ require (
sigs.k8s.io/controller-runtime v0.7.2
volcano.sh/apis v1.2.0-k8s1.19.6
)

require (
cloud.google.com/go v0.51.0 // indirect
github.com/Azure/go-autorest/autorest v0.9.6 // indirect
github.com/Azure/go-autorest/autorest/adal v0.8.2 // indirect
github.com/Azure/go-autorest/autorest/date v0.2.0 // indirect
github.com/Azure/go-autorest/logger v0.1.0 // indirect
github.com/Azure/go-autorest/tracing v0.5.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/zapr v0.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.4 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/googleapis/gnostic v0.5.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.10 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nxadm/tail v1.4.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.18.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
go.uber.org/zap v1.15.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
golang.org/x/tools v0.0.0-20200616133436-c1934b75d054 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/component-base v0.19.9 // indirect
k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14 // indirect
k8s.io/klog/v2 v2.2.0 // indirect
k8s.io/utils v0.0.0-20200912215256-4140de9c8800 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.0.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading

0 comments on commit 7cdc253

Please sign in to comment.