зеркало из https://github.com/Azure/kubectl-aks.git
lint: Introduce a golang linter
This commit is contained in:
Родитель
cf44911467
Коммит
747ce9aaf9
|
@ -65,6 +65,26 @@ jobs:
|
|||
name: kubectl-aks-${{ matrix.os }}-${{ matrix.arch }}-tar-gz
|
||||
path: kubectl-aks-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
|
||||
|
||||
lint:
|
||||
name: Run linter
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
check-latest: true
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v3.5.0
|
||||
with:
|
||||
# This version number must be kept in sync with Makefile lint one.
|
||||
version: v1.53.2
|
||||
working-directory: /home/runner/work/kubectl-aks/kubectl-aks
|
||||
# Workaround to display the output:
|
||||
# https://github.com/golangci/golangci-lint-action/issues/119#issuecomment-981090648
|
||||
args: "--out-${NO_FUTURE}format colored-line-number"
|
||||
|
||||
unit-tests:
|
||||
name: Run unit tests
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
output:
|
||||
sort-results: true
|
||||
|
||||
run:
|
||||
timeout: 10m
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
max-same-issues: 0
|
||||
max-issues-per-linter: 0
|
||||
exclude-rules:
|
||||
# Ignore check: Packages must have a package comment
|
||||
- text: "ST1000: at least one file in a package should have a package comment"
|
||||
linters:
|
||||
- stylecheck
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- gofumpt
|
||||
- stylecheck
|
||||
- staticcheck
|
||||
- errorlint
|
||||
|
||||
linters-settings:
|
||||
gofumpt:
|
||||
lang-version: "1.17"
|
||||
staticcheck:
|
||||
go: "1.17"
|
||||
checks: ["all"]
|
||||
stylecheck:
|
||||
go: "1.17"
|
||||
checks: ["all"]
|
||||
errorlint:
|
||||
# https://github.com/polyfloyd/go-errorlint
|
||||
# Check whether fmt.Errorf uses the %w verb for formatting errors.
|
||||
errorf: true
|
||||
# Check for plain type assertions and type switches (errors.As must be used).
|
||||
asserts: true
|
||||
# Check for plain error comparisons (errors.Is must be used)
|
||||
comparison: true
|
10
Makefile
10
Makefile
|
@ -12,6 +12,8 @@ else
|
|||
VERSION := $(TAG)-dirty
|
||||
endif
|
||||
|
||||
LINTER_VERSION ?= v1.53.2
|
||||
|
||||
LDFLAGS := "-X github.com/Azure/kubectl-aks/cmd.version=$(VERSION) -extldflags '-static'"
|
||||
|
||||
.DEFAULT_GOAL := kubectl-aks
|
||||
|
@ -49,6 +51,14 @@ kubectl-aks-%: phony_explicit
|
|||
-o kubectl-aks-$${GOOS}-$${GOARCH} \
|
||||
github.com/Azure/kubectl-aks
|
||||
|
||||
# Lint
|
||||
.PHONY: lint
|
||||
lint:
|
||||
docker run --rm --env XDG_CACHE_HOME=/tmp/xdg_home_cache \
|
||||
--env GOLANGCI_LINT_CACHE=/tmp/golangci_lint_cache \
|
||||
--user $(shell id -u):$(shell id -g) -v $(shell pwd):/app -w /app \
|
||||
golangci/golangci-lint:$(LINTER_VERSION) golangci-lint run
|
||||
|
||||
# Install
|
||||
.PHONY: install
|
||||
install: kubectl-aks
|
||||
|
|
Загрузка…
Ссылка в новой задаче