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 more specify check for code #540

Merged
merged 1 commit into from
Oct 22, 2023
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
30 changes: 26 additions & 4 deletions .github/workflows/approve-to-run-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
linters-settings:
go-mod-tidy:
enabled: true
gci:
enabled: true
max-len: 120
Expand Down Expand Up @@ -53,6 +55,7 @@ linters:
- testpackage

run:
timeout: 5m
enable-cache: true
skip-dirs:
- vendor
Expand Down
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
.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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
Loading