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 4 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.14
Jeffwan marked this conversation as resolved.
Show resolved Hide resolved

- 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
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ 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 Down
Loading