From 3a47e5f54dc9332ce0fbc13e157f0cfb57b249c9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 17 Jan 2024 02:26:05 -0500 Subject: [PATCH 1/3] feat: add golangci-lint file --- .golangci-lint.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .golangci-lint.yml diff --git a/.golangci-lint.yml b/.golangci-lint.yml new file mode 100644 index 000000000..e805f6226 --- /dev/null +++ b/.golangci-lint.yml @@ -0,0 +1,24 @@ +--- +run: + timeout: 5m + +linters: + disable-all: true + + enable: + - errcheck + - goconst + - gocyclo + - gofumpt + - gosec + - gosimple + - govet + - ineffassign + - misspell + - revive + - staticcheck + - typecheck + - unconvert + - unparam + - unused + - whitespace From b8329d76ec0c964e606b26093a9253fb6328575e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 17 Jan 2024 02:28:11 -0500 Subject: [PATCH 2/3] tests: add support for running golangci-lint automatically The plugin paths must be computed at execution because not all plugins contain golang code. --- tests.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests.mk b/tests.mk index 18d9d53b9..9d23ecb7f 100644 --- a/tests.mk +++ b/tests.mk @@ -1,6 +1,7 @@ -SYSTEM := $(shell sh -c 'uname -s 2>/dev/null') DOKKU_SSH_PORT ?= 22 DOKKU_DOMAIN ?= dokku.me +GO_PLUGINS := $(shell sh -c 'find plugins -type f -name "go.mod" -exec dirname "{}" \; | sort -u | sed -e "s/$$/\/.../" | xargs') +SYSTEM := $(shell sh -c 'uname -s 2>/dev/null') bats: ifeq ($(SYSTEM),Darwin) @@ -130,6 +131,9 @@ lint-ci: lint-setup @echo linting... @cat tmp/shellcheck/test-files | xargs shellcheck | tests/shellcheck-to-junit --output test-results/shellcheck/results.xml --files tmp/shellcheck/test-files --exclude $(shell cat tmp/shellcheck/exclude) +lint-golang: + golangci-lint run $(GO_PLUGINS) + lint-shfmt: shfmt # verifying via shfmt # shfmt -l -bn -ci -i 2 -d . From bdee495a0a5eb2824fb6a67f55a9a8b9be09c717 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 17 Jan 2024 02:28:36 -0500 Subject: [PATCH 3/3] feat: add golangci-lint to the development environment --- .devcontainer/bin/setup-dev-env | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/bin/setup-dev-env b/.devcontainer/bin/setup-dev-env index 9c7983cef..066ac45d3 100755 --- a/.devcontainer/bin/setup-dev-env +++ b/.devcontainer/bin/setup-dev-env @@ -3,6 +3,7 @@ install-go-devtools() { go install github.com/go-delve/delve/cmd/dlv@latest go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest } setup-ci() {