-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (114 loc) · 3.94 KB
/
Copy pathMakefile
File metadata and controls
143 lines (114 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
.PHONY: all build build-plugin clean test docker-build docker-push lint lint-fix test-coverage test-e2e test-e2e-nfs test-e2e-nvmeof test-e2e-iscsi test-e2e-smb test-e2e-scale test-e2e-snapclone changelog
DRIVER_NAME=tns-csi-driver
PLUGIN_NAME=kubectl-tns_csi
IMAGE_NAME=bfenski/tns-csi
REGISTRY?=docker.io
# Version information - derived from git tags
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo "dev")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOLANGCI_LINT=golangci-lint
# Build parameters with version injection
LDFLAGS=-ldflags "-s -w \
-X main.version=$(VERSION) \
-X main.gitCommit=$(GIT_COMMIT) \
-X main.buildDate=$(BUILD_DATE)"
BUILD_DIR=bin
all: build
build:
@echo "Building $(DRIVER_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(DRIVER_NAME) ./cmd/tns-csi-driver
build-plugin:
@echo "Building $(PLUGIN_NAME)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(GIT_COMMIT)" \
-o $(BUILD_DIR)/$(PLUGIN_NAME) ./cmd/kubectl-tns-csi
@echo "Plugin built: $(BUILD_DIR)/$(PLUGIN_NAME)"
@echo "Install with: cp $(BUILD_DIR)/$(PLUGIN_NAME) /usr/local/bin/"
clean:
@echo "Cleaning..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
test:
@echo "Running tests..."
$(GOTEST) -v ./...
lint:
@echo "Running golangci-lint..."
$(GOLANGCI_LINT) run --config .golangci.yml ./...
lint-fix:
@echo "Running golangci-lint with auto-fix..."
$(GOLANGCI_LINT) run --config .golangci.yml --fix ./...
lint-verbose:
@echo "Running golangci-lint (verbose)..."
$(GOLANGCI_LINT) run --config .golangci.yml -v ./...
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
docker-build:
@echo "Building Docker image $(IMAGE_NAME):$(VERSION)..."
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_NAME):$(VERSION) .
docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
docker-push:
@echo "Pushing Docker image $(IMAGE_NAME):$(VERSION)..."
docker push $(IMAGE_NAME):$(VERSION)
docker push $(IMAGE_NAME):latest
install:
@echo "Installing $(DRIVER_NAME)..."
$(GOBUILD) $(LDFLAGS) -o $(GOPATH)/bin/$(DRIVER_NAME) ./cmd/tns-csi-driver
# Sanity tests
test-sanity:
@echo "Running CSI sanity tests..."
./tests/sanity/test-sanity.sh
test-unit:
@echo "Running unit tests..."
$(GOTEST) -v -short ./pkg/...
test-coverage:
@echo "Running tests with coverage (for SonarQube)..."
$(GOTEST) -v -short -coverprofile=coverage.out -covermode=atomic ./pkg/...
$(GOTEST) -v -short -json ./pkg/... > test-report.json || true
@echo "Coverage report: coverage.out"
@echo "Test report: test-report.json"
test-all: test-unit test-sanity
@echo "All tests completed"
# E2E tests (requires Ginkgo CLI and TrueNAS connection)
test-e2e:
@echo "Running all E2E tests..."
ginkgo -v --timeout=60m ./tests/e2e/...
test-e2e-nfs:
@echo "Running NFS E2E tests..."
ginkgo -v --timeout=25m ./tests/e2e/nfs/...
test-e2e-nvmeof:
@echo "Running NVMe-oF E2E tests..."
ginkgo -v --timeout=40m ./tests/e2e/nvmeof/...
test-e2e-iscsi:
@echo "Running iSCSI E2E tests..."
ginkgo -v --timeout=40m ./tests/e2e/iscsi/...
test-e2e-smb:
@echo "Running SMB E2E tests..."
ginkgo -v --timeout=25m ./tests/e2e/smb/...
test-e2e-scale:
@echo "Running Scale E2E tests (CSI operations with non-CSI noise data)..."
ginkgo -v --timeout=30m ./tests/e2e/scale/...
test-e2e-snapclone:
@echo "Running Snapshot/Clone Stress E2E tests..."
ginkgo -v --timeout=120m ./tests/e2e/snapclone/...
# Changelog generation (requires git-cliff: cargo install git-cliff)
changelog:
@echo "Generating changelog..."
git-cliff -o CHANGELOG.md
changelog-unreleased:
@echo "Generating unreleased changelog..."
git-cliff --unreleased