From d0131efb943cbd033d0a3cdfe8b831e86a8f2ec5 Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 6 Jan 2021 01:56:14 +0530 Subject: [PATCH] Setup github actions for linting and go tests --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ .golangci.yml | 10 ++++++++++ controllers/suite_test.go | 3 +-- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml create mode 100644 .golangci.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..24232fdc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Lint and test + +on: [push, pull_request] + +jobs: + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2.3.0 + with: + args: --timeout=5m + + go-test: + name: go tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.15.5' + - name: go-test + run: make test diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..488cd1e0 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,10 @@ +linters: + enable: + - gofmt + - goimports + - unconvert + - gocyclo + - nakedret + - scopelint + - whitespace + - nolintlint diff --git a/controllers/suite_test.go b/controllers/suite_test.go index d3bd8662..872ce093 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -7,7 +7,6 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/envtest/printer" @@ -21,7 +20,7 @@ import ( // These tests use Ginkgo (BDD-style Go testing framework). Refer to // http://onsi.github.io/ginkgo/ to learn more about Ginkgo. -var cfg *rest.Config +// var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment