Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI to run the tests for Go #1440

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Jeffwan marked this conversation as resolved.
Show resolved Hide resolved

- 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.*
tenzen-y marked this conversation as resolved.
Show resolved Hide resolved
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
tenzen-y marked this conversation as resolved.
Show resolved Hide resolved
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