Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
cache: true
go-version-file: "go.mod"
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches: [main, development]
pull_request:
branches: [main, development]

permissions:
contents: read
pull-requests: read
checks: write

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: golangci-lint
uses: golangci/golangci-lint-action@9fae48acfc02a90574d7c304a1758ef9895495fa # v7.0.1
with:
version: v2.4.0
args: --config .golangci.yml
69 changes: 44 additions & 25 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 Iguazio
# Copyright 2025 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,35 +12,54 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: "2"

run:
timeout: 5m
build-tags:
- test_unit
- test_integration

linters:
disable-all: true
default: none
enable:
- gofmt
- revive
- gosimple
- errcheck
- goconst
- gocritic
- govet
- ineffassign
- misspell
- staticcheck
- unconvert
- vet
- vetshadow
- errcheck

run:

# timeout for analysis
timeout: 10m

skip-dirs:
- hack
- docs
- test
- vendor
- unused
disable: []
# All linters are enabled - using //nolint directives in code instead

exclusions:
paths:
- "docs"
- "hack"
rules:
- linters: [goconst]
path: "_test\\.go"
- path: "(.+)\\.go$"
text: "comment on"
- path: "(.+)\\.go$"
text: "error should be the last"

issues:
settings:
gocritic:
disabled-checks:
- commentFormatting

# List of regexps of issue texts to exclude
exclude:
- "comment on"
- "error should be the last"
- "should have comment"
formatters:
settings:
gci:
sections:
- standard
- "prefix(github.com/v3io/)"
- "prefix(github.com/nuclio/)"
- default
- blank
- dot
custom-order: true
191 changes: 156 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,80 @@
# Copyright 2019 Iguazio
# Copyright 2025 The v3io-go Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

GO_VERSION := $(shell go version | cut -d " " -f 3)
GOPATH ?= $(shell go env GOPATH)
SHELL := /bin/bash

# Get default os / arch from go env
V3IO_DEFAULT_OS := $(shell go env GOOS)
V3IO_DEFAULT_ARCH := $(shell go env GOARCH || echo amd64)

V3IO_OS := $(if $(V3IO_OS),$(V3IO_OS),$(V3IO_DEFAULT_OS))
V3IO_ARCH := $(if $(V3IO_ARCH),$(V3IO_ARCH),$(V3IO_DEFAULT_ARCH))

# Version information
V3IO_VERSION_GIT_COMMIT = $(shell git rev-parse HEAD)
V3IO_PATH ?= $(shell pwd)

# Link flags
GO_LINK_FLAGS ?= -s -w

# Go test timeout
V3IO_GO_TEST_TIMEOUT ?= "30m"

#
# Must be first target
#
.PHONY: all
all:
$(error "Please pick a target (run 'make targets' to view targets)")

#
# Linting and formatting
#
.PHONY: fmt
fmt: ensure-golangci-linter
gofmt -s -w .
$(GOLANGCI_LINT_BIN) run --fix

.PHONY: lint
lint: modules ensure-golangci-linter
@echo Linting...
$(GOLANGCI_LINT_BIN) run -v
@echo Done.


GOLANGCI_LINT_VERSION := 2.3.0
GOLANGCI_LINT_BIN := $(CURDIR)/.bin/golangci-lint
GOLANGCI_LINT_INSTALL_COMMAND := GOBIN=$(CURDIR)/.bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION)

.PHONY: ensure-golangci-linter
ensure-golangci-linter:
@if ! command -v $(GOLANGCI_LINT_BIN) >/dev/null 2>&1; then \
echo "golangci-lint not found. Installing..."; \
$(GOLANGCI_LINT_INSTALL_COMMAND); \
else \
installed_version=$$($(GOLANGCI_LINT_BIN) version | awk '/version/ {gsub(/^v/, "", $$4); print $$4}'); \
if [ "$$installed_version" != "$(GOLANGCI_LINT_VERSION)" ]; then \
echo "golangci-lint version mismatch ($$installed_version != $(GOLANGCI_LINT_VERSION)). Reinstalling..."; \
$(GOLANGCI_LINT_INSTALL_COMMAND); \
fi \
fi

#
# Environment validation
#
# To setup env locally on your dev box, run:
# $ export $(grep -v '^#' ./hack/test.env | xargs)
.PHONY: check-env
check-env:
ifndef V3IO_DATAPLANE_URL
Expand All @@ -39,45 +100,70 @@ ifndef V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD
endif
@echo "All required env vars populated"

#
# Schema generation
#
.PHONY: generate-capnp
generate-capnp:
pushd ./pkg/dataplane/schemas/; ./build; popd
@echo "Generating Cap'n Proto schemas..."
@cd ./pkg/dataplane/schemas/; ./build
@echo "Schema generation complete."

.PHONY: clean
clean:
pushd ./pkg/dataplane/schemas/; ./clean; popd
.PHONY: clean-schemas
clean-schemas:
@echo "Cleaning generated schemas..."
@cd ./pkg/dataplane/schemas/; ./clean
@echo "Schema cleanup complete."

.PHONY: fmt
fmt:
gofmt -s -w .
#
# Building
#
.PHONY: build-lib
build-lib: modules
@echo "Building v3io-go library..."
@go build ./pkg/...
@echo "Library build successful."

.PHONY: lint
lint:
./hack/lint/install.sh
./hack/lint/run.sh
.PHONY: build
build: clean-schemas generate-capnp build-lib lint test
@echo "Full build pipeline complete."

.PHONY: test
test: check-env
go test -race -tags unit -count 1 ./...
#
# Testing
#
.PHONY: test-unit
test-unit: modules ensure-gopath
go test -race -tags=test_unit -v ./pkg/... -short

.PHONY: test-integration
test-integration: modules ensure-gopath
go test -race -tags=test_integration -v ./pkg/... --timeout $(V3IO_GO_TEST_TIMEOUT)

.PHONY: test-coverage
test-coverage:
go test -tags=test_unit -coverprofile=coverage.out ./pkg/... || go tool cover -html=coverage.out

.PHONY: test-controlplane
test-controlplane: check-env
go test -test.v=true -race -tags unit -count 1 ./pkg/controlplane/...
test-controlplane: modules ensure-gopath check-env
go test -test.v=true -race -tags=test_unit -count=1 ./pkg/controlplane/...

.PHONY: test-dataplane
test-dataplane: check-env
go test -test.v=true -race -tags unit -count 1 ./pkg/dataplane/...
test-dataplane: modules ensure-gopath check-env
go test -test.v=true -race -tags=test_unit -count=1 ./pkg/dataplane/...

.PHONY: test-dataplane-simple
test-dataplane-simple: check-env
go test -test.v=true -tags unit -count 1 ./pkg/dataplane/...
test-dataplane-simple: modules ensure-gopath check-env
go test -test.v=true -tags=test_unit -count=1 ./pkg/dataplane/...

.PHONY: test-system
test-system: test-controlplane test-dataplane-simple

.PHONY: test
test: test-unit

.PHONY: build-test-container
build-test-container:
@echo Building test container...
@echo "Building test container..."
docker build \
--file hack/test/docker/Dockerfile \
--tag v3io-go-test:latest \
Expand All @@ -87,15 +173,50 @@ build-test-container:
test-system-in-docker: build-test-container
@echo "Running system test in docker container..."
docker run --rm \
--env V3IO_DATAPLANE_URL="${V3IO_DATAPLANE_URL}" \
--env V3IO_DATAPLANE_USERNAME="${V3IO_DATAPLANE_USERNAME}" \
--env V3IO_DATAPLANE_ACCESS_KEY="${V3IO_DATAPLANE_ACCESS_KEY}" \
--env V3IO_CONTROLPLANE_URL="${V3IO_CONTROLPLANE_URL}" \
--env V3IO_CONTROLPLANE_USERNAME="${V3IO_CONTROLPLANE_USERNAME}" \
--env V3IO_CONTROLPLANE_PASSWORD="${V3IO_CONTROLPLANE_PASSWORD}" \
--env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="${V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD}" \
--env V3IO_DATAPLANE_URL="$(V3IO_DATAPLANE_URL)" \
--env V3IO_DATAPLANE_USERNAME="$(V3IO_DATAPLANE_USERNAME)" \
--env V3IO_DATAPLANE_ACCESS_KEY="$(V3IO_DATAPLANE_ACCESS_KEY)" \
--env V3IO_CONTROLPLANE_URL="$(V3IO_CONTROLPLANE_URL)" \
--env V3IO_CONTROLPLANE_USERNAME="$(V3IO_CONTROLPLANE_USERNAME)" \
--env V3IO_CONTROLPLANE_PASSWORD="$(V3IO_CONTROLPLANE_PASSWORD)" \
--env V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD="$(V3IO_CONTROLPLANE_IGZ_ADMIN_PASSWORD)" \
v3io-go-test:latest make test-system
@echo Done.
@echo "Docker test complete."

.PHONY: build
build: clean generate-capnp lint test
#
# Go modules and environment
#
.PHONY: ensure-gopath
ensure-gopath:
ifndef GOPATH
$(error GOPATH must be set)
endif

.PHONY: modules
modules: ensure-gopath
@go mod download

.PHONY: tidy
tidy:
@go mod tidy

.PHONY: clean
clean: clean-schemas
@echo "Cleaning build artifacts..."
@go clean -cache
@rm -rf .bin/
@rm -rf coverage.out
@echo "Clean complete."

.PHONY: targets
targets:
@awk -F: '/^[^ \t="]+:/ && !/PHONY/ {print $$1}' Makefile | sort -u

#
# Versioning
#
.PHONY: version
version:
@echo "Git commit: $(V3IO_VERSION_GIT_COMMIT)"
@echo "Go version: $(GO_VERSION)"
@echo "OS/Arch: $(V3IO_OS)/$(V3IO_ARCH)"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/v3io/v3io-go

go 1.19
go 1.23

require (
github.com/nuclio/errors v0.0.4
Expand Down
2 changes: 1 addition & 1 deletion hack/test/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
FROM gcr.io/iguazio/golang:1.19
FROM gcr.io/iguazio/golang:1.23

ENV GOPATH=/go
WORKDIR /v3io-go
Expand Down
Loading