Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): lint with golangci-lint #726

Merged
merged 6 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: read # Remove along with only-new-issues by 2025
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Determine golangci-lint version
id: golangcilint
run: |
line=$(grep GOLANGCI_LINT_VERSION= GNUmakefile)
version=$(echo ${line} | cut -d = -f2)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
args: --whole-files # Remove along with only-new-issues by 2025
version: ${{ steps.golangcilint.outputs.version }}
only-new-issues: true # Remove along with pull-requests: read permission by 2025
13 changes: 13 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
run:
modules-download-mode: readonly
skip-dirs:
- cmd/migration-tool
linters:
enable:
- errcheck
- goimports
- gosimple
- govet
- ineffassign
- staticcheck
- unused
7 changes: 6 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ ACCTEST_COUNT ?= 1
GOFMT_FILES ?=$$(find . -name '*.go' |grep -v vendor)
PKG_NAME =equinix

GOLANGCI_LINT_VERSION=v1.56
GOLANGCI_LINT=go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}

ifneq ($(origin TESTS_REGEXP), undefined)
TESTARGS = -run='$(TESTS_REGEXP)'
endif
Expand Down Expand Up @@ -45,6 +48,8 @@ clean:
${GOCMD} clean
rm -f ${BINARY}

lint:
${GOLANGCI_LINT} run -v

vet:
@echo "go vet ."
Expand Down Expand Up @@ -117,4 +122,4 @@ tfproviderdocs-check:
echo "Unexpected issues found in code with bflad/tfproviderdocs."; \
exit 1)

.PHONY: test testacc build install clean fmt fmtcheck errcheck test-compile docs-lint docs-lint-fix tfproviderlint tfproviderlint-fix tfproviderdocs-check
.PHONY: test testacc build install clean lint fmt fmtcheck errcheck test-compile docs-lint docs-lint-fix tfproviderlint tfproviderlint-fix tfproviderdocs-check
Loading