chore(lint): add golangci-lint configuration
- commit
- 396bb02847576bb9dcc4f8f4449ca5886eae1d18
- author
- brice · · 2026-08-05 04:22 UTC
- committer
- brice · · 2026-08-05 04:42 UTC
- parent
- dae7738
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
5 files · +50 -4
M .github/workflows/ci.yml +17 -0
| @@ -46,3 +46,20 @@ jobs: | |||
| 46 | 46 | ||
| 47 | 47 | - name: go test | |
| 48 | 48 | run: go test -race ./... | |
| 49 | + | ||
| 50 | + | lint: | |
| 51 | + | name: lint | |
| 52 | + | runs-on: ubuntu-latest | |
| 53 | + | steps: | |
| 54 | + | - uses: actions/checkout@v4 | |
| 55 | + | ||
| 56 | + | - name: set up go | |
| 57 | + | uses: actions/setup-go@v7 | |
| 58 | + | with: | |
| 59 | + | go-version: "1.26" | |
| 60 | + | cache: true | |
| 61 | + | ||
| 62 | + | - name: golangci-lint | |
| 63 | + | uses: golangci/golangci-lint-action@v9.3.0 | |
| 64 | + | with: | |
| 65 | + | version: v2.12.2 | |
| @@ -46,3 +46,20 @@ jobs: | |||||
| 46 | 46 | ||||
| 47 | - name: go test | 47 | - name: go test | ||
| 48 | run: go test -race ./... | 48 | run: go test -race ./... | ||
| 49 | + | ||||
| 50 | + | lint: | |||
| 51 | + | name: lint | |||
| 52 | + | runs-on: ubuntu-latest | |||
| 53 | + | steps: | |||
| 54 | + | - uses: actions/checkout@v4 | |||
| 55 | + | ||||
| 56 | + | - name: set up go | |||
| 57 | + | uses: actions/setup-go@v7 | |||
| 58 | + | with: | |||
| 59 | + | go-version: "1.26" | |||
| 60 | + | cache: true | |||
| 61 | + | ||||
| 62 | + | - name: golangci-lint | |||
| 63 | + | uses: golangci/golangci-lint-action@v9.3.0 | |||
| 64 | + | with: | |||
| 65 | + | version: v2.12.2 | |||
A .golangci.yml +19 -0
| @@ -0,0 +1,19 @@ | |||
| 1 | + | version: "2" | |
| 2 | + | ||
| 3 | + | run: | |
| 4 | + | timeout: 5m | |
| 5 | + | relative-path-mode: gomod | |
| 6 | + | modules-download-mode: readonly | |
| 7 | + | ||
| 8 | + | linters: | |
| 9 | + | default: standard | |
| 10 | + | ||
| 11 | + | formatters: | |
| 12 | + | enable: | |
| 13 | + | - gofmt | |
| 14 | + | ||
| 15 | + | issues: | |
| 16 | + | # Keep existing findings from blocking adoption while failing on new issues. | |
| 17 | + | new: true | |
| 18 | + | max-issues-per-linter: 0 | |
| 19 | + | max-same-issues: 0 | |
| @@ -0,0 +1,19 @@ | |||||
| 1 | + | version: "2" | |||
| 2 | + | ||||
| 3 | + | run: | |||
| 4 | + | timeout: 5m | |||
| 5 | + | relative-path-mode: gomod | |||
| 6 | + | modules-download-mode: readonly | |||
| 7 | + | ||||
| 8 | + | linters: | |||
| 9 | + | default: standard | |||
| 10 | + | ||||
| 11 | + | formatters: | |||
| 12 | + | enable: | |||
| 13 | + | - gofmt | |||
| 14 | + | ||||
| 15 | + | issues: | |||
| 16 | + | # Keep existing findings from blocking adoption while failing on new issues. | |||
| 17 | + | new: true | |||
| 18 | + | max-issues-per-linter: 0 | |||
| 19 | + | max-same-issues: 0 | |||
M CONTRIBUTING.md +3 -1
| @@ -75,7 +75,8 @@ make install # install the current checkout with go install | |||
| 75 | 75 | make go-install # install a published module version | |
| 76 | 76 | make test # run all tests with the race detector | |
| 77 | 77 | make test-fast # run all tests without the race detector | |
| 78 | - | make lint # run go vet and verify gofmt | |
| 78 | + | make lint # run golangci-lint, go vet, and verify gofmt | |
| 79 | + | make lint-install # install the pinned golangci-lint version | |
| 79 | 80 | ``` | |
| 80 | 81 | ||
| 81 | 82 | Tests must not depend on real provider credentials, paid model calls, a developer's global zot state, or a specific terminal. Use local HTTP test servers, fixtures, temporary directories, and synthetic credentials. | |
| @@ -133,6 +134,7 @@ Run focused package tests while developing. Before opening a pull request that c | |||
| 133 | 134 | ```sh | |
| 134 | 135 | gofmt -w <changed-go-files> | |
| 135 | 136 | go vet ./... | |
| 137 | + | golangci-lint run ./... | |
| 136 | 138 | go test -race ./... | |
| 137 | 139 | git diff --check | |
| 138 | 140 | ``` | |
| @@ -75,7 +75,8 @@ make install # install the current checkout with go install | |||||
| 75 | make go-install # install a published module version | 75 | make go-install # install a published module version | ||
| 76 | make test # run all tests with the race detector | 76 | make test # run all tests with the race detector | ||
| 77 | make test-fast # run all tests without the race detector | 77 | make test-fast # run all tests without the race detector | ||
| 78 | - | make lint # run go vet and verify gofmt | 78 | + | make lint # run golangci-lint, go vet, and verify gofmt |
| 79 | + | make lint-install # install the pinned golangci-lint version | |||
| 79 | ``` | 80 | ``` | ||
| 80 | 81 | ||||
| 81 | Tests must not depend on real provider credentials, paid model calls, a developer's global zot state, or a specific terminal. Use local HTTP test servers, fixtures, temporary directories, and synthetic credentials. | 82 | Tests must not depend on real provider credentials, paid model calls, a developer's global zot state, or a specific terminal. Use local HTTP test servers, fixtures, temporary directories, and synthetic credentials. | ||
| @@ -133,6 +134,7 @@ Run focused package tests while developing. Before opening a pull request that c | |||||
| 133 | ```sh | 134 | ```sh | ||
| 134 | gofmt -w <changed-go-files> | 135 | gofmt -w <changed-go-files> | ||
| 135 | go vet ./... | 136 | go vet ./... | ||
| 137 | + | golangci-lint run ./... | |||
| 136 | go test -race ./... | 138 | go test -race ./... | ||
| 137 | git diff --check | 139 | git diff --check | ||
| 138 | ``` | 140 | ``` | ||
M Makefile +9 -2
| @@ -9,9 +9,11 @@ BIN_DIR ?= bin | |||
| 9 | 9 | DEV_VERSION ?= 0.0.0-dev | |
| 10 | 10 | VERSION ?= $(DEV_VERSION) | |
| 11 | 11 | GO_INSTALL_VERSION ?= latest | |
| 12 | + | GOLANGCI_LINT ?= golangci-lint | |
| 13 | + | GOLANGCI_LINT_VERSION ?= v2.12.2 | |
| 12 | 14 | LDFLAGS := -s -w -X main.version=$(VERSION) | |
| 13 | 15 | ||
| 14 | - | .PHONY: help build install go-install test test-fast vet lint fmt-check fmt check run clean release | |
| 16 | + | .PHONY: help build install go-install test test-fast vet lint lint-install fmt-check fmt check run clean release | |
| 15 | 17 | ||
| 16 | 18 | help: | |
| 17 | 19 | @printf '%s\n' \ | |
| @@ -21,7 +23,8 @@ help: | |||
| 21 | 23 | 'test run all tests with the race detector' \ | |
| 22 | 24 | 'test-fast run all tests without the race detector' \ | |
| 23 | 25 | 'vet run go vet ./...' \ | |
| 24 | - | 'lint run vet and verify gofmt' \ | |
| 26 | + | 'lint run golangci-lint, vet, and verify gofmt' \ | |
| 27 | + | 'lint-install install golangci-lint $(GOLANGCI_LINT_VERSION)' \ | |
| 25 | 28 | 'fmt format Go source files' \ | |
| 26 | 29 | 'check run test-fast and lint' \ | |
| 27 | 30 | 'run build and run ./bin/zot (pass ARGS="...")' \ | |
| @@ -54,6 +57,10 @@ fmt-check: | |||
| 54 | 57 | if [ -n "$$files" ]; then printf '%s\n' "$$files" >&2; echo "gofmt issues" >&2; exit 1; fi | |
| 55 | 58 | ||
| 56 | 59 | lint: vet fmt-check | |
| 60 | + | $(GOLANGCI_LINT) run ./... | |
| 61 | + | ||
| 62 | + | lint-install: | |
| 63 | + | $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) | |
| 57 | 64 | ||
| 58 | 65 | check: test-fast lint | |
| 59 | 66 | ||
| @@ -9,9 +9,11 @@ BIN_DIR ?= bin | |||||
| 9 | DEV_VERSION ?= 0.0.0-dev | 9 | DEV_VERSION ?= 0.0.0-dev | ||
| 10 | VERSION ?= $(DEV_VERSION) | 10 | VERSION ?= $(DEV_VERSION) | ||
| 11 | GO_INSTALL_VERSION ?= latest | 11 | GO_INSTALL_VERSION ?= latest | ||
| 12 | + | GOLANGCI_LINT ?= golangci-lint | |||
| 13 | + | GOLANGCI_LINT_VERSION ?= v2.12.2 | |||
| 12 | LDFLAGS := -s -w -X main.version=$(VERSION) | 14 | LDFLAGS := -s -w -X main.version=$(VERSION) | ||
| 13 | 15 | ||||
| 14 | - | .PHONY: help build install go-install test test-fast vet lint fmt-check fmt check run clean release | 16 | + | .PHONY: help build install go-install test test-fast vet lint lint-install fmt-check fmt check run clean release |
| 15 | 17 | ||||
| 16 | help: | 18 | help: | ||
| 17 | @printf '%s\n' \ | 19 | @printf '%s\n' \ | ||
| @@ -21,7 +23,8 @@ help: | |||||
| 21 | 'test run all tests with the race detector' \ | 23 | 'test run all tests with the race detector' \ | ||
| 22 | 'test-fast run all tests without the race detector' \ | 24 | 'test-fast run all tests without the race detector' \ | ||
| 23 | 'vet run go vet ./...' \ | 25 | 'vet run go vet ./...' \ | ||
| 24 | - | 'lint run vet and verify gofmt' \ | 26 | + | 'lint run golangci-lint, vet, and verify gofmt' \ |
| 27 | + | 'lint-install install golangci-lint $(GOLANGCI_LINT_VERSION)' \ | |||
| 25 | 'fmt format Go source files' \ | 28 | 'fmt format Go source files' \ | ||
| 26 | 'check run test-fast and lint' \ | 29 | 'check run test-fast and lint' \ | ||
| 27 | 'run build and run ./bin/zot (pass ARGS="...")' \ | 30 | 'run build and run ./bin/zot (pass ARGS="...")' \ | ||
| @@ -54,6 +57,10 @@ fmt-check: | |||||
| 54 | if [ -n "$$files" ]; then printf '%s\n' "$$files" >&2; echo "gofmt issues" >&2; exit 1; fi | 57 | if [ -n "$$files" ]; then printf '%s\n' "$$files" >&2; echo "gofmt issues" >&2; exit 1; fi | ||
| 55 | 58 | ||||
| 56 | lint: vet fmt-check | 59 | lint: vet fmt-check | ||
| 60 | + | $(GOLANGCI_LINT) run ./... | |||
| 61 | + | ||||
| 62 | + | lint-install: | |||
| 63 | + | $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) | |||
| 57 | 64 | ||||
| 58 | check: test-fast lint | 65 | check: test-fast lint | ||
| 59 | 66 | ||||
M README.md +2 -1
| @@ -1043,7 +1043,8 @@ make help # list the important developer commands | |||
| 1043 | 1043 | make build # build ./bin/zot as 0.0.0-dev | |
| 1044 | 1044 | make test # go test -race ./... | |
| 1045 | 1045 | make test-fast # go test ./... | |
| 1046 | - | make lint # go vet + gofmt check | |
| 1046 | + | make lint # golangci-lint + go vet + gofmt check | |
| 1047 | + | make lint-install # install the pinned golangci-lint version | |
| 1047 | 1048 | make fmt # gofmt -w . | |
| 1048 | 1049 | make install # install the current checkout with go install | |
| 1049 | 1050 | make go-install # install the latest published module version | |
| @@ -1043,7 +1043,8 @@ make help # list the important developer commands | |||||
| 1043 | make build # build ./bin/zot as 0.0.0-dev | 1043 | make build # build ./bin/zot as 0.0.0-dev | ||
| 1044 | make test # go test -race ./... | 1044 | make test # go test -race ./... | ||
| 1045 | make test-fast # go test ./... | 1045 | make test-fast # go test ./... | ||
| 1046 | - | make lint # go vet + gofmt check | 1046 | + | make lint # golangci-lint + go vet + gofmt check |
| 1047 | + | make lint-install # install the pinned golangci-lint version | |||
| 1047 | make fmt # gofmt -w . | 1048 | make fmt # gofmt -w . | ||
| 1048 | make install # install the current checkout with go install | 1049 | make install # install the current checkout with go install | ||
| 1049 | make go-install # install the latest published module version | 1050 | make go-install # install the latest published module version | ||