diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d310128..62e9865 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -27,10 +27,15 @@ jobs: uses: actions/checkout@v2 - name: Get dependencies run: | - go get -v -t -d ./... + make get + - name: Lint Code + run: | + GOBIN=$HOME go install golang.org/x/tools/cmd/goimports + GOBIN=$HOME go install golang.org/x/lint/golint + GOBIN=$HOME make lint - name: Test run: | - go test ./... -v + make test - name: Build Artifacts run: | - go build -ldflags="-s -w" -o gcb-visualizer + make build diff --git a/Makefile b/Makefile index 6931948..1387a94 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,22 @@ +BIN=$(GOBIN) + build: - go build -ldflags="-s -w" + go build -ldflags="-s -w" -o gcb-visualizer -tests: +.PHONY: test +test: go test -count=1 ./... + +get: + go get -v -t -d ./... + +format-lint: + gofmt -l -d . + +import-lint: + ${BIN}/goimports -l -d . + +style-lint: + ${BIN}/golint ./... + +lint: format-lint import-lint style-lint diff --git a/gcb-visualizer.go b/gcb-visualizer.go index ba37b59..4c1d653 100644 --- a/gcb-visualizer.go +++ b/gcb-visualizer.go @@ -2,9 +2,10 @@ package main import ( "fmt" + "os" + "github.com/RyanSiu1995/gcb-visualizer/cmd" log "github.com/sirupsen/logrus" - "os" ) func init() { diff --git a/internal/utils/cloudbuild_test.go b/internal/utils/cloudbuild_test.go index 7242963..4598e5c 100644 --- a/internal/utils/cloudbuild_test.go +++ b/internal/utils/cloudbuild_test.go @@ -3,7 +3,6 @@ package util import ( "bytes" "fmt" - "gopkg.in/yaml.v2" "io/ioutil" "os" "path" @@ -14,6 +13,7 @@ import ( graphviz "github.com/goccy/go-graphviz" "github.com/goccy/go-graphviz/cgraph" "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" ) var supportedFormat = []string{".yaml", ".yml", ".json"}