Skip to content

Commit

Permalink
Merge pull request #540 from meshery/fix/badge
Browse files Browse the repository at this point in the history
Add more specify check for code
  • Loading branch information
Aisuko authored Oct 22, 2023
2 parents 8edcde6 + 7a87d78 commit fa1cbdd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
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/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

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

0 comments on commit fa1cbdd

Please sign in to comment.