Skip to content

Commit

Permalink
feat: setup golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Feb 13, 2024
1 parent b2b17ac commit dadc323
Show file tree
Hide file tree
Showing 26 changed files with 324 additions and 340 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: proto

---
name: lint
on:
push:
branches:
Expand All @@ -9,7 +9,7 @@ on:
pull_request:

jobs:
lint:
go:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand All @@ -25,4 +25,21 @@ jobs:
- name: go mod vendor
run: make modvendor
- name: lint
run: make lint
run: make lint-proto
proto:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Setup env
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(./script/tools.sh gotoolchain | sed 's/go*//')
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: go mod vendor
run: make modvendor
- name: lint-go
run: make lint-go
38 changes: 38 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
issues:
exclude:
- comment on exported (method|function|type|const|var)
exclude-use-default: true

# Skip generated k8s code
run:
skip-dirs:
- "^go/node/types/v1beta1"
- "^go/node/types/v1beta2"
- "^go/node/market/v1beta3"
skip-files:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
# Skip vendor/ etc
skip-dirs-use-default: true
linters:
disable-all: true
enable:
- unused
- misspell
- gofmt
- gocritic
- goconst
- govet
- ineffassign
- unparam
- staticcheck
- revive
- gosec
- exportloopref
- prealloc
linters-settings:
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ PROTOC_GEN_DOC_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .V
PROTOC_GEN_SWAGGER_VERSION := $(PROTOC_GEN_GRPC_GATEWAY_VERSION)
MODVENDOR_VERSION ?= v0.5.0
MOCKERY_VERSION ?= 2.24.0
GOLANGCI_LINT_VERSION ?= v1.56.1

BUF_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/buf/$(BUF_VERSION)
PROTOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc/$(PROTOC_VERSION)
Expand All @@ -53,6 +54,7 @@ PROTOC_GEN_DOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-do
MODVENDOR_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/modvendor/$(MODVENDOR_VERSION)
GIT_CHGLOG_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/git-chglog/$(GIT_CHGLOG_VERSION)
MOCKERY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/mockery/v$(MOCKERY_VERSION)
GOLANGCI_LINT_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION)

BUF := $(AKASH_DEVCACHE_BIN)/buf
PROTOC := $(AKASH_DEVCACHE_BIN)/protoc
Expand All @@ -67,6 +69,10 @@ MODVENDOR := $(AKASH_DEVCACHE_BIN)/modvendor
GIT_CHGLOG := $(AKASH_DEVCACHE_BIN)/git-chglog
SWAGGER_COMBINE := $(AKASH_DEVCACHE_NODE_BIN)/swagger-combine
MOCKERY := $(AKASH_DEVCACHE_BIN)/mockery
GOLANGCI_LINT := $(AKASH_DEVCACHE_BIN)/golangci-lint

GOLANGCI_LINT_RUN := $(GOLANGCI_LINT) run
GOLINT := $(GOLANGCI_LINT_RUN) ./... --disable-all --deadline=5m --enable

DOCKER_RUN := docker run --rm -v $(shell pwd):/workspace -w /workspace
DOCKER_BUF := $(DOCKER_RUN) bufbuild/buf:$(BUF_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion go/manifest/v2beta2/manifest_cross_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func simpleDeployment(t *testing.T, expose ServiceExposes, count uint32) []dtype
gid := testutil.GroupID(t)
resources := make(dtypes.ResourceUnits, 1)
resources[0] = dtypes.ResourceUnit{
Resources: simpleResourceUnits(expose),
Resources: simpleResources(expose),
Count: count,
Price: sdk.NewInt64DecCoin(tutil.CoinDenom, 1),
}
Expand Down
Loading

0 comments on commit dadc323

Please sign in to comment.