Skip to content

Commit 53f46d3

Browse files
author
Alex Toker
committed
Bump go and linter to 1.23
1 parent 30f5740 commit 53f46d3

File tree

16 files changed

+276
-108
lines changed

16 files changed

+276
-108
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
name: Lint
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v3
35-
- uses: actions/setup-go@v3
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-go@v5
3636
with:
3737
cache: true
3838
go-version-file: "go.mod"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches: [main, development]
5+
pull_request:
6+
branches: [main, development]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
checks: write
12+
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.23'
23+
24+
- name: golangci-lint
25+
uses: golangci/golangci-lint-action@9fae48acfc02a90574d7c304a1758ef9895495fa # v7.0.1
26+
with:
27+
version: v2.4.0
28+
args: --config .golangci.yml

.golangci.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Iguazio
1+
# Copyright 2025 Iguazio
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,35 +12,54 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
#
15+
version: "2"
16+
17+
run:
18+
timeout: 5m
19+
build-tags:
20+
- test_unit
21+
- test_integration
22+
1523
linters:
16-
disable-all: true
24+
default: none
1725
enable:
18-
- gofmt
19-
- revive
20-
- gosimple
26+
- errcheck
27+
- goconst
28+
- gocritic
29+
- govet
2130
- ineffassign
2231
- misspell
2332
- staticcheck
2433
- unconvert
25-
- vet
26-
- vetshadow
27-
- errcheck
28-
29-
run:
30-
31-
# timeout for analysis
32-
timeout: 10m
33-
34-
skip-dirs:
35-
- hack
36-
- docs
37-
- test
38-
- vendor
34+
- unused
35+
disable: []
36+
# All linters are enabled - using //nolint directives in code instead
37+
38+
exclusions:
39+
paths:
40+
- "docs"
41+
- "hack"
42+
rules:
43+
- linters: [goconst]
44+
path: "_test\\.go"
45+
- path: "(.+)\\.go$"
46+
text: "comment on"
47+
- path: "(.+)\\.go$"
48+
text: "error should be the last"
3949

40-
issues:
50+
settings:
51+
gocritic:
52+
disabled-checks:
53+
- commentFormatting
4154

42-
# List of regexps of issue texts to exclude
43-
exclude:
44-
- "comment on"
45-
- "error should be the last"
46-
- "should have comment"
55+
formatters:
56+
settings:
57+
gci:
58+
sections:
59+
- standard
60+
- "prefix(github.com/v3io/)"
61+
- "prefix(github.com/nuclio/)"
62+
- default
63+
- blank
64+
- dot
65+
custom-order: true

Makefile

Lines changed: 156 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,80 @@
1-
# Copyright 2019 Iguazio
1+
# Copyright 2025 The v3io-go Authors.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
55
# You may obtain a copy of the License at
66
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# http://www.apache.org/licenses/LICENSE-2.0
88
#
99
# Unless required by applicable law or agreed to in writing, software
1010
# distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
GO_VERSION := $(shell go version | cut -d " " -f 3)
16+
GOPATH ?= $(shell go env GOPATH)
17+
SHELL := /bin/bash
18+
19+
# Get default os / arch from go env
20+
V3IO_DEFAULT_OS := $(shell go env GOOS)
21+
V3IO_DEFAULT_ARCH := $(shell go env GOARCH || echo amd64)
22+
23+
V3IO_OS := $(if $(V3IO_OS),$(V3IO_OS),$(V3IO_DEFAULT_OS))
24+
V3IO_ARCH := $(if $(V3IO_ARCH),$(V3IO_ARCH),$(V3IO_DEFAULT_ARCH))
25+
26+
# Version information
27+
V3IO_VERSION_GIT_COMMIT = $(shell git rev-parse HEAD)
28+
V3IO_PATH ?= $(shell pwd)
29+
30+
# Link flags
31+
GO_LINK_FLAGS ?= -s -w
32+
33+
# Go test timeout
34+
V3IO_GO_TEST_TIMEOUT ?= "30m"
35+
36+
#
37+
# Must be first target
38+
#
39+
.PHONY: all
40+
all:
41+
$(error "Please pick a target (run 'make targets' to view targets)")
42+
43+
#
44+
# Linting and formatting
45+
#
46+
.PHONY: fmt
47+
fmt: ensure-golangci-linter
48+
gofmt -s -w .
49+
$(GOLANGCI_LINT_BIN) run --fix
50+
51+
.PHONY: lint
52+
lint: modules ensure-golangci-linter
53+
@echo Linting...
54+
$(GOLANGCI_LINT_BIN) run -v
55+
@echo Done.
56+
57+
58+
GOLANGCI_LINT_VERSION := 2.3.0
59+
GOLANGCI_LINT_BIN := $(CURDIR)/.bin/golangci-lint
60+
GOLANGCI_LINT_INSTALL_COMMAND := GOBIN=$(CURDIR)/.bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)
61+
62+
.PHONY: ensure-golangci-linter
63+
ensure-golangci-linter:
64+
@if ! command -v $(GOLANGCI_LINT_BIN) >/dev/null 2>&1; then \
65+
echo "golangci-lint not found. Installing..."; \
66+
$(GOLANGCI_LINT_INSTALL_COMMAND); \
67+
else \
68+
installed_version=$$($(GOLANGCI_LINT_BIN) version | awk '/version/ {gsub(/^v/, "", $$4); print $$4}'); \
69+
if [ "$$installed_version" != "$(GOLANGCI_LINT_VERSION)" ]; then \
70+
echo "golangci-lint version mismatch ($$installed_version != $(GOLANGCI_LINT_VERSION)). Reinstalling..."; \
71+
$(GOLANGCI_LINT_INSTALL_COMMAND); \
72+
fi \
73+
fi
74+
75+
#
76+
# Environment validation
1477
#
15-
# To setup env locally on your dev box, run:
16-
# $ export $(grep -v '^#' ./hack/test.env | xargs)
1778
.PHONY: check-env
1879
check-env:
1980
ifndef V3IO_DATAPLANE_URL
@@ -39,45 +100,70 @@ ifndef V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD
39100
endif
40101
@echo "All required env vars populated"
41102

103+
#
104+
# Schema generation
105+
#
42106
.PHONY: generate-capnp
43107
generate-capnp:
44-
pushd ./pkg/dataplane/schemas/; ./build; popd
108+
@echo "Generating Cap'n Proto schemas..."
109+
@cd ./pkg/dataplane/schemas/; ./build
110+
@echo "Schema generation complete."
45111

46-
.PHONY: clean
47-
clean:
48-
pushd ./pkg/dataplane/schemas/; ./clean; popd
112+
.PHONY: clean-schemas
113+
clean-schemas:
114+
@echo "Cleaning generated schemas..."
115+
@cd ./pkg/dataplane/schemas/; ./clean
116+
@echo "Schema cleanup complete."
49117

50-
.PHONY: fmt
51-
fmt:
52-
gofmt -s -w .
118+
#
119+
# Building
120+
#
121+
.PHONY: build-lib
122+
build-lib: modules
123+
@echo "Building v3io-go library..."
124+
@go build ./pkg/...
125+
@echo "Library build successful."
53126

54-
.PHONY: lint
55-
lint:
56-
./hack/lint/install.sh
57-
./hack/lint/run.sh
127+
.PHONY: build
128+
build: clean-schemas generate-capnp build-lib lint test
129+
@echo "Full build pipeline complete."
58130

59-
.PHONY: test
60-
test: check-env
61-
go test -race -tags unit -count 1 ./...
131+
#
132+
# Testing
133+
#
134+
.PHONY: test-unit
135+
test-unit: modules ensure-gopath
136+
go test -race -tags=test_unit -v ./pkg/... -short
137+
138+
.PHONY: test-integration
139+
test-integration: modules ensure-gopath
140+
go test -race -tags=test_integration -v ./pkg/... --timeout $(V3IO_GO_TEST_TIMEOUT)
141+
142+
.PHONY: test-coverage
143+
test-coverage:
144+
go test -tags=test_unit -coverprofile=coverage.out ./pkg/... || go tool cover -html=coverage.out
62145

63146
.PHONY: test-controlplane
64-
test-controlplane: check-env
65-
go test -test.v=true -race -tags unit -count 1 ./pkg/controlplane/...
147+
test-controlplane: modules ensure-gopath check-env
148+
go test -test.v=true -race -tags=test_unit -count=1 ./pkg/controlplane/...
66149

67150
.PHONY: test-dataplane
68-
test-dataplane: check-env
69-
go test -test.v=true -race -tags unit -count 1 ./pkg/dataplane/...
151+
test-dataplane: modules ensure-gopath check-env
152+
go test -test.v=true -race -tags=test_unit -count=1 ./pkg/dataplane/...
70153

71154
.PHONY: test-dataplane-simple
72-
test-dataplane-simple: check-env
73-
go test -test.v=true -tags unit -count 1 ./pkg/dataplane/...
155+
test-dataplane-simple: modules ensure-gopath check-env
156+
go test -test.v=true -tags=test_unit -count=1 ./pkg/dataplane/...
74157

75158
.PHONY: test-system
76159
test-system: test-controlplane test-dataplane-simple
77160

161+
.PHONY: test
162+
test: test-unit
163+
78164
.PHONY: build-test-container
79165
build-test-container:
80-
@echo Building test container...
166+
@echo "Building test container..."
81167
docker build \
82168
--file hack/test/docker/Dockerfile \
83169
--tag v3io-go-test:latest \
@@ -87,15 +173,50 @@ build-test-container:
87173
test-system-in-docker: build-test-container
88174
@echo "Running system test in docker container..."
89175
docker run --rm \
90-
--env V3IO_DATAPLANE_URL="${V3IO_DATAPLANE_URL}" \
91-
--env V3IO_DATAPLANE_USERNAME="${V3IO_DATAPLANE_USERNAME}" \
92-
--env V3IO_DATAPLANE_ACCESS_KEY="${V3IO_DATAPLANE_ACCESS_KEY}" \
93-
--env V3IO_CONTROLPLANE_URL="${V3IO_CONTROLPLANE_URL}" \
94-
--env V3IO_CONTROLPLANE_USERNAME="${V3IO_CONTROLPLANE_USERNAME}" \
95-
--env V3IO_CONTROLPLANE_PASSWORD="${V3IO_CONTROLPLANE_PASSWORD}" \
96-
--env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="${V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD}" \
176+
--env V3IO_DATAPLANE_URL="$(V3IO_DATAPLANE_URL)" \
177+
--env V3IO_DATAPLANE_USERNAME="$(V3IO_DATAPLANE_USERNAME)" \
178+
--env V3IO_DATAPLANE_ACCESS_KEY="$(V3IO_DATAPLANE_ACCESS_KEY)" \
179+
--env V3IO_CONTROLPLANE_URL="$(V3IO_CONTROLPLANE_URL)" \
180+
--env V3IO_CONTROLPLANE_USERNAME="$(V3IO_CONTROLPLANE_USERNAME)" \
181+
--env V3IO_CONTROLPLANE_PASSWORD="$(V3IO_CONTROLPLANE_PASSWORD)" \
182+
--env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="$(V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD)" \
97183
v3io-go-test:latest make test-system
98-
@echo Done.
184+
@echo "Docker test complete."
99185

100-
.PHONY: build
101-
build: clean generate-capnp lint test
186+
#
187+
# Go modules and environment
188+
#
189+
.PHONY: ensure-gopath
190+
ensure-gopath:
191+
ifndef GOPATH
192+
$(error GOPATH must be set)
193+
endif
194+
195+
.PHONY: modules
196+
modules: ensure-gopath
197+
@go mod download
198+
199+
.PHONY: tidy
200+
tidy:
201+
@go mod tidy
202+
203+
.PHONY: clean
204+
clean: clean-schemas
205+
@echo "Cleaning build artifacts..."
206+
@go clean -cache
207+
@rm -rf .bin/
208+
@rm -rf coverage.out
209+
@echo "Clean complete."
210+
211+
.PHONY: targets
212+
targets:
213+
@awk -F: '/^[^ \t="]+:/ && !/PHONY/ {print $$1}' Makefile | sort -u
214+
215+
#
216+
# Versioning
217+
#
218+
.PHONY: version
219+
version:
220+
@echo "Git commit: $(V3IO_VERSION_GIT_COMMIT)"
221+
@echo "Go version: $(GO_VERSION)"
222+
@echo "OS/Arch: $(V3IO_OS)/$(V3IO_ARCH)"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/v3io/v3io-go
22

3-
go 1.19
3+
go 1.23
44

55
require (
66
github.com/nuclio/errors v0.0.4

hack/test/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
#
15-
FROM gcr.io/iguazio/golang:1.19
15+
FROM gcr.io/iguazio/golang:1.23
1616

1717
ENV GOPATH=/go
1818
WORKDIR /v3io-go

0 commit comments

Comments
 (0)