Skip to content

Commit b4c2225

Browse files
committed
Make make lint optional and non-failing in CI
- Split make lint into separate lint-optional job - Only make lint uses continue-on-error: true - make vet and make fmtcheck remain as required checks
1 parent ac61f78 commit b4c2225

File tree

3 files changed

+153
-6
lines changed

3 files changed

+153
-6
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,26 @@ jobs:
2424
steps:
2525
- name: Checkout Git repo
2626
uses: actions/checkout@v4
27+
- name: Set up Go
28+
uses: actions/setup-go@v4
29+
with:
30+
go-version-file: go.mod
2731
- name: Running ${{ matrix.command }}
2832
run: ${{ matrix.command }}
2933

34+
lint-optional:
35+
runs-on: ubuntu-22.04
36+
steps:
37+
- name: Checkout Git repo
38+
uses: actions/checkout@v4
39+
- name: Set up Go
40+
uses: actions/setup-go@v4
41+
with:
42+
go-version-file: go.mod
43+
- name: Running make lint
44+
continue-on-error: true
45+
run: make lint
46+
3047
prepare-dependencies:
3148
name: Prepare Dependencies
3249
runs-on: ubuntu-22.04

.golangci.yml

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,131 @@
11
# GolangCI-Lint configuration
2-
# Suppress warnings from testcontainers dependencies
2+
# Focused on correctness checks, not style
3+
# Run with: golangci-lint run
4+
5+
version: "2"
6+
7+
run:
8+
# Timeout for analysis
9+
timeout: 5m
10+
# Include test files in analysis
11+
tests: true
12+
# Skip vendor and scripts directories
13+
skip-dirs:
14+
- vendor
15+
- scripts
16+
# Skip generated files
17+
skip-files:
18+
- ".*\\.pb\\.go$"
19+
- ".*\\.gen\\.go$"
20+
21+
# Enable only correctness-focused linters
22+
linters:
23+
# Disable all linters first
24+
disable-all: true
25+
# Enable correctness-focused linters
26+
enable:
27+
# Core correctness checks
28+
- govet # Reports suspicious constructs
29+
- errcheck # Checks for unchecked errors
30+
- staticcheck # Advanced static analysis (includes type checking and gosimple checks)
31+
- ineffassign # Detects ineffectual assignments
32+
- unused # Finds unused code (replaces deadcode, varcheck, structcheck)
33+
- gosec # Security-focused linter
34+
- nilerr # Finds nil errors that should be checked
35+
- unconvert # Detects unnecessary conversions
36+
- unparam # Finds unused function parameters
37+
- gocritic # Advanced linter (correctness-focused checks, includes exportloopref)
38+
- bodyclose # Checks whether HTTP response body is closed
39+
- noctx # Detects http.Request without context
40+
- rowserrcheck # Checks for errors from database row operations
41+
- sqlclosecheck # Checks that sql.DB, sql.Rows, sql.Stmt, sql.Tx are closed
342

443
linters-settings:
5-
gci:
6-
# Suppress warnings from third-party packages
7-
skip-generated: true
44+
# govet settings
45+
govet:
46+
check-shadowing: true
47+
enable-all: true
48+
49+
# errcheck settings
50+
errcheck:
51+
check-type-assertions: true
52+
check-blank: true
53+
ignore: |
54+
fmt:.*
55+
io:Close|Write
56+
bytes:.*
57+
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:Set
58+
database/sql:Rows.Close
59+
database/sql:Row.Scan
60+
61+
# staticcheck settings
62+
staticcheck:
63+
checks: ["all"]
64+
65+
# gosec settings
66+
gosec:
67+
severity: medium
68+
confidence: medium
69+
# Exclude some false positives common in Terraform providers
70+
excludes:
71+
- G101 # Look for hard coded credentials
72+
- G104 # Errors unhandled (we use errcheck for this)
73+
- G307 # Deferring a method which returns an error
74+
75+
# gocritic settings - enable correctness-focused checks
76+
gocritic:
77+
enabled-tags:
78+
- diagnostic
79+
- experimental
80+
- opinionated
81+
disabled-checks:
82+
# Style-focused checks to disable
83+
- dupImport
84+
- importShadow
85+
- ifElseChain
86+
- octalLiteral
87+
- whyNoLint
88+
- wrapperFunc
89+
# Keep correctness-focused checks enabled
90+
91+
# unused settings
92+
unused:
93+
check-exported: false # Don't require exported functions to be used
94+
95+
# unparam settings
96+
unparam:
97+
check-exported: false # Don't require exported functions to use all params
898

999
issues:
100+
# Maximum issues count per one linter
101+
max-issues-per-linter: 0
102+
# Maximum count of issues with the same text
103+
max-same-issues: 0
104+
10105
exclude-rules:
11-
# Suppress warnings from go-m1cpu (testcontainers dependency)
106+
# Exclude scripts directory (contains separate programs)
107+
- path: scripts/.*
108+
109+
# Suppress warnings from testcontainers dependencies
12110
- path: _test\.go
13111
linters:
14112
- gocritic
15113
text: ".*go-m1cpu.*"
114+
115+
# Allow unused parameters in test helpers
116+
- path: _test\.go
117+
linters:
118+
- unparam
119+
text: ".*is unused"
120+
121+
# Suppress some false positives in test files
122+
- path: _test\.go
123+
linters:
124+
- errcheck
125+
text: "Error return value of .* is not checked"
126+
127+
# Allow defer in test cleanup functions
128+
- path: _test\.go
129+
linters:
130+
- gosec
131+
text: ".*defer.*"

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,20 @@ errcheck: ## Run errcheck
224224
exit 1; \
225225
fi
226226

227+
lint: ## Run golangci-lint (correctness-focused linters)
228+
@echo "==> Running golangci-lint..."
229+
@GOPATH_BIN=$$(go env GOPATH)/bin; \
230+
GOLANGCI_LINT=$$GOPATH_BIN/golangci-lint; \
231+
if [ ! -f $$GOLANGCI_LINT ]; then \
232+
echo "==> Installing golangci-lint..."; \
233+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$GOPATH_BIN latest; \
234+
fi; \
235+
$$GOLANGCI_LINT run ./mysql/... ; if [ $$? -eq 1 ]; then \
236+
echo ""; \
237+
echo "Linter found issues. Please review and fix them before submitting code."; \
238+
exit 1; \
239+
fi
240+
227241
vendor-status: ## Show vendor status
228242
@govendor status
229243

@@ -373,4 +387,4 @@ release-local: ## Create a release locally (for testing - use 'make release' for
373387
release: ## Create a release PR branch (tag, push branch and tag, then create PR to merge to default branch)
374388
@go run scripts/make-release.go
375389

376-
.PHONY: help build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test tag format-tag release release-local
390+
.PHONY: help build test testacc vet fmt fmtcheck errcheck lint vendor-status test-compile website website-test tag format-tag release release-local

0 commit comments

Comments
 (0)