diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06f954c..08bc39a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ permissions: contents: read env: - GO_VERSION: ${{ vars.golang_version || '1.19' }} + GO_VERSION: ${{ vars.golang_version || '1.20' }} jobs: build: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e6a0a29..cf2fb52 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,19 +10,14 @@ on: - "**.go" - go.mod - go.sum - pull_request: - paths: - - .github/workflows/lint.yml - - "**.go" - - go.mod - - go.sum + - .golangci.yml permissions: contents: read env: - LINT_VERSION: ${{ vars.golangci_version || '1.50.1' }} - GO_VERSION: ${{ vars.golang_version || '1.19' }} + LINT_VERSION: ${{ vars.golangci_version || '1.55.2' }} + GO_VERSION: ${{ vars.golang_version || '1.20' }} jobs: lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cc4ace1..0f4355c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,8 @@ permissions: contents: write env: - LINT_VERSION: ${{ vars.golangci_version || '1.50.1' }} - GO_VERSION: ${{ vars.golang_version || '1.19' }} + LINT_VERSION: ${{ vars.golangci_version || '1.55.2' }} + GO_VERSION: ${{ vars.golang_version || '1.20' }} jobs: goreleaser: diff --git a/.golangci.yml b/.golangci.yml index 4384471..ca06e01 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,41 +1,68 @@ run: - timeout: 60m + tests: true + +output: + print-issued-lines: false -issues: - max-per-linter: 0 - max-same-issues: 0 - exclude-rules: - - linters: - - unparam - text: ".*\\(error\\) is always nil$" - - linters: - - revive - text: "unused-parameter: parameter '[^']+' seems to be unused, consider removing or renaming it as _" linters: - disable-all: true enable: - - asciicheck - - bidichk - - errname + - dupl - errcheck - errorlint + - exhaustive + - goconst - gocritic + - gocyclo + - gofmt - gofumpt - goimports - - gosimple - - govet + - gosec - ineffassign - - loggercheck - misspell - - nilnil - - nolintlint - - reassign + - nilerr + - paralleltest - revive - - staticcheck - - typecheck - - unused + - testifylint - unconvert - unparam + - unused - vet + - paralleltest - vetshadow - - wastedassign + +linters-settings: + vet: + check-shadowing: true + use-installed-packages: true + goconst: + min-len: 8 + min-occurrences: 3 + gocyclo: + min-complexity: 20 + gocritic: + disabled-checks: + - ifElseChain + revive: + rules: + - name: exported + disabled: true + - name: package-comments + disabled: true + gofmt: + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' + - pattern: 'a[b:len(a)]' + replacement: 'a[b:]' + exhaustive: + default-signifies-exhaustive: true + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false + exclude: + # Captured by errcheck. + - "^(G104|G204):" + # Very commonly not checked. + - 'Error return value of .(.*\.Help|.*\.MarkFlagRequired|(os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*Print(f|ln|)|os\.(Un)?Setenv). is not checked' diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..351f7fd --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.DEFAULT_GOAL := help + +ifneq (,$(wildcard ./.env)) + include .env + export +endif + +TIMEOUT ?= 120m +GOMAXPROCS ?= 5 +TESTARGS ?= ./... + +build: ## Build provider + go build cmd/azdo/azdo.go + +dist: ## create new release + goreleaser release --clean --skip publish + +clean: ## Clean repositorty + rm -f azdo + rm -rf dist + +.PHONY: lint +lint: ## lint source + @echo "Check for golangci-lint"; [ -e "$(shell which golangci-lint)" ] + @echo "Executing golangci-lint"; golangci-lint run -v --timeout $(TIMEOUT) + +.PHONY: help +tidy: # call go mod tidy on all existing go.mod files + find . -name go.mod -execdir go mod tidy \; + +.PHONY: help +help: + @grep '^[^#.][A-Za-z._/]\+:\s\+.*#' Makefile | \ + sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \ + expand -t30