diff --git a/.github/workflows/approve-to-run-ci.yml b/.github/workflows/approve-to-run-ci.yml index b74d1c9..0431095 100644 --- a/.github/workflows/approve-to-run-ci.yml +++ b/.github/workflows/approve-to-run-ci.yml @@ -17,16 +17,34 @@ jobs: - uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} + cache: true + cache-dependency-path: go.sum - name: Checkout code uses: actions/checkout@master - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: version: latest - args: --timeout=5m + - name: Run golangci-lint + run: make lint + tidy: + name: Go mod tidy + needs: [golangci-lint] + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21.x + cache: true + cache-dependency-path: go.sum + - name: Run go mod tidy + run: make tidy codecov: # golandci-lint need to be run before codecov and succeed - needs: golangci-lint + needs: [golangci-lint, tidy] name: Code Coverage if: github.repository == 'meshery/meshery-operator' runs-on: ubuntu-22.04 @@ -37,10 +55,12 @@ jobs: uses: actions/setup-go@v4 with: go-version: 1.21.x + cache: true + cache-dependency-path: go.sum - name: Set up test-env run: make test-env - name: Run unit tests - run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic + run: make test - name: Upload coverage to Codecov if: github.repository == 'meshery/meshery-operator' uses: codecov/codecov-action@v3 @@ -51,7 +71,7 @@ jobs: # if review comment includes changes requested, do not run the tests # if review comment includes approved or LGTM, run the tests build: - needs: [golangci-lint,codecov] + needs: [golangci-lint, tidy, codecov] name: Build runs-on: ubuntu-22.04 steps: @@ -61,5 +81,7 @@ jobs: uses: actions/setup-go@v4 with: go-version: 1.21.x + cache: true + cache-dependency-path: go.sum - name: Build run: make build diff --git a/.golangci.yml b/.golangci.yml index 897f76f..e76d099 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,6 @@ linters-settings: + go-mod-tidy: + enabled: true gci: enabled: true max-len: 120 @@ -53,6 +55,7 @@ linters: - testpackage run: + timeout: 5m enable-cache: true skip-dirs: - vendor diff --git a/Makefile b/Makefile index 0494032..c93ca0e 100644 --- a/Makefile +++ b/Makefile @@ -107,19 +107,17 @@ vet: ## Run go vet against code. go vet ./... # Run go lint against code -check: golint -golint: get-lint -golint: run-lint +.PHONY: lint +lint: + golangci-lint run -c .golangci.yml -v ./... -run-lint: - go run github.com/golangci/golangci-lint/cmd/golangci-lint run - -get-lint: - go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 +.PHONY: tidy +tidy: ## Run go mod tidy against code. + go mod tidy .PHONY: test test: manifests generate fmt vet ## Run tests. - go test ./... -coverprofile cover.out + go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic ##@ Build diff --git a/README.md b/README.md index e36eca7..2512ca9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/layer5/meshery-operator.svg)](https://hub.docker.com/r/layer5/meshery-operator) [![Go Report Card](https://goreportcard.com/badge/github.com/layer5io/meshery-operator)](https://goreportcard.com/report/github.com/layer5io/meshery-operator) -[![Build Status](https://github.com/meshery/meshery-operator/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/layer5io/meshery-operator/actions) +[![Build Status](https://github.com/meshery/meshery-operator/actions/workflows/build-and-release.yml/badge.svg)](https://github.com/meshery/meshery-operator/actions) [![GitHub](https://img.shields.io/github/license/layer5io/meshery-operator.svg)](LICENSE) [![codecov](https://codecov.io/gh/meshery/meshery-operator/branch/master/graph/badge.svg?token=TJZ2L4JHSA)](https://codecov.io/gh/meshery/meshery-operator) [![Website](https://img.shields.io/website/https/layer5.io/meshery.svg)](https://layer5.io/meshery/)