Skip to content

Commit a17cc2b

Browse files
Merge pull request #7 from roman-kiselenko/upgrade-linter-ci
Upgrade linter to v2 and add to CI
2 parents c0a089e + fab07cd commit a17cc2b

File tree

6 files changed

+142
-104
lines changed

6 files changed

+142
-104
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "CI"
33
on: [push, pull_request]
44
jobs:
55
build:
6-
name: Build and Test
6+
name: Build Lint Test
77
runs-on: ubuntu-latest
88
steps:
99

@@ -21,8 +21,11 @@ jobs:
2121
- name: Build
2222
run: make build
2323

24+
- name: Lint
25+
run: make lint
26+
2427
- name: Config
2528
run: make config
2629

2730
- name: Test
28-
run: make integration-test
31+
run: make integration-test

.golangci.yml

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
version: "2"
12
run:
2-
skip-dirs:
3-
- (^|/)bin($|/)
4-
- (^|/)tmp($|/)
3+
allow-parallel-runners: true
4+
relative-path-mode: wd
55
linters:
66
enable:
77
- asciicheck
@@ -14,67 +14,89 @@ linters:
1414
- goconst
1515
- gocritic
1616
- gocyclo
17-
- revive
1817
- gosec
1918
- lll
2019
- misspell
2120
- nakedret
2221
- noctx
2322
- prealloc
23+
- revive
2424
- rowserrcheck
25-
- exportloopref
26-
- stylecheck
25+
- staticcheck
2726
- unconvert
2827
- unparam
2928
- whitespace
29+
settings:
30+
funlen:
31+
lines: 168
32+
statements: 50
33+
gocritic:
34+
disabled-checks:
35+
- singleCaseSwitch
36+
lll:
37+
line-length: 193
38+
tab-width: 1
39+
staticcheck:
40+
checks:
41+
- -S1023
42+
- all
43+
exclusions:
44+
generated: lax
45+
presets:
46+
- comments
47+
- common-false-positives
48+
- legacy
49+
- std-error-handling
50+
rules:
51+
- linters:
52+
- bodyclose
53+
- dupl
54+
- funlen
55+
- gochecknoinits
56+
- gocognit
57+
- goconst
58+
- gocyclo
59+
- gosec
60+
- lll
61+
- maligned
62+
- noctx
63+
- revive
64+
- scopelint
65+
- staticcheck
66+
path: _test.go
67+
- linters:
68+
- bodyclose
69+
- dupl
70+
- funlen
71+
- gochecknoinits
72+
- gocognit
73+
- goconst
74+
- gocyclo
75+
- lll
76+
- maligned
77+
- noctx
78+
- revive
79+
- scopelint
80+
- staticcheck
81+
path: _mock.go
82+
paths:
83+
- third_party$
84+
- builtin$
85+
- examples$
86+
output:
87+
formats:
88+
tab:
89+
path: stdout
90+
colors: true
91+
formatters:
92+
enable:
3093
- gofumpt
31-
linters-settings:
32-
lll:
33-
line-length: 193
34-
tab-width: 1
35-
funlen:
36-
lines: 168
37-
statements: 50
38-
gocritic:
39-
disabled-checks:
40-
- singleCaseSwitch
41-
golint:
42-
min-confidence: 0.6
43-
gosimple:
44-
checks: ["all","-S1023"]
45-
gofumpt:
46-
module-path: smolgit
47-
lang-version: "1.22.4"
48-
issues:
49-
exclude-rules:
50-
- path: _test.go
51-
linters:
52-
- funlen
53-
- maligned
54-
- noctx
55-
- scopelint
56-
- bodyclose
57-
- lll
58-
- goconst
59-
- gocognit
60-
- gocyclo
61-
- gochecknoinits
62-
- dupl
63-
- staticcheck
64-
- revive
65-
- gosec
66-
- path: _mock.go
67-
linters:
68-
- funlen
69-
- maligned
70-
- noctx
71-
- scopelint
72-
- bodyclose
73-
- lll
74-
- goconst
75-
- gocognit
76-
- gocyclo
77-
- gochecknoinits
78-
- dupl
79-
- staticcheck
80-
- revive
94+
settings:
95+
gofumpt:
96+
module-path: smolgit
97+
exclusions:
98+
generated: lax
99+
paths:
100+
- third_party$
101+
- builtin$
102+
- examples$

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ WHITE := $(shell tput -Txterm setaf 7)
88
CYAN := $(shell tput -Txterm setaf 6)
99
RESET := $(shell tput -Txterm sgr0)
1010

11-
.PHONY: all test build clean run
12-
1311
PROJECT_NAME := smolgit
12+
LINTER_BIN ?= golangci-lint
13+
14+
.PHONY: all test build clean run lint /bin/$(LINTER_BIN)
1415

1516
all: help
1617

@@ -21,10 +22,17 @@ build: ## Build all the binaries and put the output in bin/
2122
build-docker: ## Build an image
2223
docker build -t $(PROJECT_NAME) .
2324

25+
bin/$(LINTER_BIN):
26+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v2.1.1
27+
2428
## Clean:
2529
clean: ## Remove build related file
2630
@-rm -fr ./bin
2731

32+
## Lint:
33+
lint: ./bin/$(LINTER_BIN) ## Lint sources with golangci-lint
34+
./bin/$(LINTER_BIN) run
35+
2836
## Run:
2937
run: clean build ## Run the smolgit `make run`
3038
./bin/$(PROJECT_NAME) $(ARGS)
@@ -55,4 +63,4 @@ help: ## Show this help.
5563
@awk 'BEGIN {FS = ":.*?## "} { \
5664
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
5765
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
58-
}' $(MAKEFILE_LIST)
66+
}' $(MAKEFILE_LIST)

go.mod

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module smolgit
22

3-
go 1.22.4
3+
go 1.23.0
4+
5+
toolchain go1.24.2
46

57
require (
68
github.com/gin-gonic/gin v1.10.0
@@ -12,7 +14,7 @@ require (
1214
github.com/knadh/koanf/providers/file v1.0.0
1315
github.com/knadh/koanf/v2 v2.1.1
1416
github.com/lmittmann/tint v1.0.4
15-
golang.org/x/crypto v0.23.0
17+
golang.org/x/crypto v0.37.0
1618
)
1719

1820
require (
@@ -34,9 +36,10 @@ require (
3436
github.com/go-playground/locales v0.14.1 // indirect
3537
github.com/go-playground/universal-translator v0.18.1 // indirect
3638
github.com/go-playground/validator/v10 v10.20.0 // indirect
37-
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
39+
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
3840
github.com/goccy/go-json v0.10.2 // indirect
3941
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
42+
github.com/google/go-cmp v0.7.0 // indirect
4043
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
4144
github.com/json-iterator/go v1.1.12 // indirect
4245
github.com/kevinburke/ssh_config v1.2.0 // indirect
@@ -48,20 +51,24 @@ require (
4851
github.com/mitchellh/reflectwalk v1.0.2 // indirect
4952
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5053
github.com/modern-go/reflect2 v1.0.2 // indirect
51-
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
54+
github.com/onsi/gomega v1.36.3 // indirect
55+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
5256
github.com/pjbgf/sha1cd v0.3.0 // indirect
57+
github.com/rogpeppe/go-internal v1.14.1 // indirect
5358
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
5459
github.com/skeema/knownhosts v1.2.2 // indirect
60+
github.com/stretchr/testify v1.10.0 // indirect
5561
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
5662
github.com/ugorji/go/codec v1.2.12 // indirect
5763
github.com/xanzy/ssh-agent v0.3.3 // indirect
5864
golang.org/x/arch v0.8.0 // indirect
59-
golang.org/x/mod v0.12.0 // indirect
60-
golang.org/x/net v0.25.0 // indirect
61-
golang.org/x/sys v0.21.0 // indirect
62-
golang.org/x/text v0.15.0 // indirect
63-
golang.org/x/tools v0.13.0 // indirect
64-
google.golang.org/protobuf v1.34.1 // indirect
65+
golang.org/x/mod v0.24.0 // indirect
66+
golang.org/x/net v0.39.0 // indirect
67+
golang.org/x/sync v0.13.0 // indirect
68+
golang.org/x/sys v0.32.0 // indirect
69+
golang.org/x/text v0.24.0 // indirect
70+
golang.org/x/tools v0.32.0 // indirect
71+
google.golang.org/protobuf v1.36.6 // indirect
6572
gopkg.in/warnings.v0 v0.1.2 // indirect
6673
gopkg.in/yaml.v3 v3.0.1 // indirect
6774
)

0 commit comments

Comments
 (0)