Skip to content

Commit

Permalink
feat: Updated build infrastructure (#36)
Browse files Browse the repository at this point in the history
* chore: updated linter configuration in .golangci.yml

* chore: added Makefile

* * chore: add .golangci.yml to the list of files to trigger linting on push and pull request for .github/workflows/lint.yml

* chore: added target tidy to Makefile to call 'go mod tidy' on all existing go.mod files

* build: bumped version of go to 1.20 in all GitHub worklfows

* build: update GitHub workflow definitions

* bumped default version of golangci_version to 1.55.2 in all GitHub workflows
* removed pull_request trigger from lint.yml workflow

---------

Co-authored-by: Thomas Meckel <[email protected]>
  • Loading branch information
tmeckel and tmeckel authored Jan 26, 2024
1 parent 8948afb commit b4fca4c
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ permissions:
contents: read

env:
GO_VERSION: ${{ vars.golang_version || '1.19' }}
GO_VERSION: ${{ vars.golang_version || '1.20' }}

jobs:
build:
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
77 changes: 52 additions & 25 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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'
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b4fca4c

Please sign in to comment.