generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from meshery/feat/golangci-lint
Add golangci-lint's cconfiguration
- Loading branch information
Showing
8 changed files
with
197 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,3 @@ jobs: | |
docker push ${{ secrets.IMAGE_NAME }}:stable-latest | ||
docker push ${{ secrets.IMAGE_NAME }}:stable-${GITHUB_REF/refs\/tags\//} | ||
docker push ${{ secrets.IMAGE_NAME }}:stable-${GITHUB_SHA::7} | ||
# - name: Docker Hub Description | ||
# if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success() | ||
# uses: peter-evans/[email protected] | ||
# env: | ||
# DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
# DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
# DOCKERHUB_REPOSITORY: ${{ secrets.IMAGE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,60 @@ | ||
name: Meshsync | ||
name: Meshsync CI | ||
|
||
on: | ||
push: | ||
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | ||
# * Matches zero or more characters, but does not match the / character | ||
# ** Matches zero or more of any character | ||
branches: | ||
- '**' | ||
tags: | ||
- 'v*' | ||
branches: [ master ] | ||
pull_request: | ||
branches: | ||
- master | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-22.04 | ||
golangci-lint: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-22.04] | ||
go-version: [1.21.x] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@main | ||
uses: actions/checkout@master | ||
- name: Setup go | ||
uses: actions/setup-go@main | ||
with: | ||
check-latest: 'true' | ||
go-version: '^1.21' | ||
- name: Build check | ||
run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go build -o meshery-meshsync . | ||
go-version: ${{ matrix.go-version }} | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | ||
version: v1.52 | ||
args: --exclude=G107 --timeout=10m ./... | ||
|
||
# Optional: working directory, useful for monorepos | ||
# working-directory: somedir | ||
|
||
# Optional: golangci-lint command line arguments. | ||
# args: --issues-exit-code=0 | ||
|
||
# Optional: show only new issues if it's a pull request. The default value is `false`. | ||
# only-new-issues: true | ||
skip-build-cache: true | ||
version: latest | ||
args: --timeout=5m | ||
codecov: | ||
needs: golangci-lint | ||
name: Code coverage | ||
if: github.repository == 'meshery/meshsync' | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Run unit tests | ||
run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic | ||
- name: Upload coverage to Codecov | ||
if: github.repository == 'meshery/meshsync' | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
file: ./coverage.txt | ||
flags: unittests | ||
build: | ||
needs: [golangci-lint, codecov] | ||
name: Build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@master | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Build | ||
run: make build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
**errorutil_errors_export.json | ||
|
||
.vscode/ | ||
cover.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,62 @@ | ||
linters-settings: | ||
depguard: | ||
list-type: blacklist | ||
packages: | ||
# logging is allowed only by logutils.Log, logrus | ||
# is allowed to use only in logutils package | ||
- github.com/sirupsen/logrus | ||
packages-with-error-message: | ||
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log" | ||
dupl: | ||
threshold: 100 | ||
exhaustive: | ||
default-signifies-exhaustive: false | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
gci: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
enabled: true | ||
max-len: 120 | ||
line-length: 120 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
enabled: true | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- whyNoLint | ||
- wrapperFunc | ||
gocyclo: | ||
min-complexity: 15 | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
golint: | ||
min-confidence: 0 | ||
gomnd: | ||
settings: | ||
mnd: | ||
# don't include the "operation" and "assign" | ||
checks: | ||
- argument | ||
- case | ||
- condition | ||
- return | ||
gosec: | ||
settings: | ||
exclude: -G204,-G107 | ||
enabled: true | ||
disable: | ||
- parallelize | ||
- nesting | ||
- hugeParam | ||
- hugeStruct | ||
- nestParam | ||
- prealloc | ||
govet: | ||
check-shadowing: false | ||
settings: | ||
printf: | ||
funcs: | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
lll: | ||
line-length: 950 | ||
maligned: | ||
suggest-new: true | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
enabled: true | ||
check-shadowing: true | ||
tests: true | ||
golint: | ||
enabled: true | ||
min-confidence: 0.8 | ||
unused: | ||
enabled: true | ||
check-exported: true | ||
check-packages: true | ||
check-generated: true | ||
tests: true | ||
allow-unused-type-export: true | ||
cyclop: | ||
enabled: true | ||
average-strictness: 7 | ||
scopelint: | ||
enabled: true | ||
tests: true | ||
|
||
# Configuration for golangci-lint that is suitable for a Kubernetes operator project built with Golang | ||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
# https://golangci-lint.run/usage/linters/ | ||
disable-all: true | ||
enable: | ||
# TODO: consider continuously if more should be enabled. | ||
# Can also be useful to run with more strict settings before commit locally, i.e. to test for TODOs (godox) | ||
# - bodyclose | ||
# - deadcode | ||
- dogsled | ||
# - dupl | ||
- errcheck | ||
# - exhaustive | ||
# - funlen | ||
# - goconst | ||
# - gocritic | ||
# - gocyclo | ||
- gofmt | ||
- goimports | ||
# - golint | ||
- gomodguard | ||
- gosec | ||
# - gomnd | ||
# - goprintffuncname | ||
- gosimple | ||
enable-all: false | ||
disable-all: false | ||
linters: | ||
- gci | ||
- goconst | ||
- gocritic | ||
- govet | ||
- ineffassign | ||
# - interfacer | ||
- lll | ||
- misspell | ||
# - nakedret | ||
# - nolintlint | ||
# - rowserrcheck | ||
# - scopelint | ||
- staticcheck | ||
# - structcheck | ||
- stylecheck | ||
- typecheck | ||
# - unconvert | ||
# - unparam | ||
- golint | ||
- unused | ||
# - varcheck | ||
- whitespace | ||
- asciicheck | ||
# - gochecknoglobals | ||
# - gocognit | ||
# - godot | ||
# - godox | ||
# - goerr113 | ||
# - maligned | ||
# - nestif | ||
# - prealloc | ||
# - testpackage | ||
# - wsl | ||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
- cyclop | ||
- scopelint | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gomnd | ||
|
||
# https://github.com/go-critic/go-critic/issues/926 | ||
- linters: | ||
- gocritic | ||
text: "unnecessaryDefer:" | ||
- testpackage | ||
|
||
- linters: | ||
- gofmt | ||
text: "lf" | ||
run: | ||
enable-cache: true | ||
skip-dirs: | ||
- vendor | ||
- bundle | ||
- config | ||
- hack | ||
- helpers | ||
- img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.