-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (71 loc) · 2.44 KB
/
Makefile
File metadata and controls
91 lines (71 loc) · 2.44 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
# Default target
.DEFAULT_GOAL := help
# Binary name
BINARY_NAME=stackrox-mcp
# Version can be overridden with VERSION=x.y.z make build (default: extracted from git tags or use dev)
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOFMT=$(GOCMD) fmt
GOCLEAN=$(GOCMD) clean
# Set the container runtime command - prefer podman, fallback to docker
DOCKER_CMD = $(shell command -v podman >/dev/null 2>&1 && echo podman || echo docker)
# Build flags
LDFLAGS=-ldflags "-X github.com/stackrox/stackrox-mcp/internal/server.version=$(VERSION)"
# Coverage files
COVERAGE_OUT=coverage.out
# JUnit files
JUNIT_OUT=junit.xml
# Lint files
LINT_OUT=report.xml
.PHONY: help
help: ## Display this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## Build the binary
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/stackrox-mcp
.PHONY: image
image: ## Build the docker image
$(DOCKER_CMD) build \
--build-arg VERSION=$(VERSION) \
-t quay.io/stackrox-io/mcp:$(VERSION) \
.
.PHONY: dockerfile-lint
dockerfile-lint: ## Run hadolint for Dockerfile
$(DOCKER_CMD) run --rm -i --env HADOLINT_FAILURE_THRESHOLD=info ghcr.io/hadolint/hadolint < Dockerfile
.PHONY: helm-lint
helm-lint: ## Run helm lint for Helm chart
helm lint charts/stackrox-mcp
.PHONY: test
test: ## Run unit tests
$(GOTEST) -v ./...
.PHONY: test-coverage-and-junit
test-coverage-and-junit: ## Run unit tests with coverage and junit output
go install github.com/jstemmer/go-junit-report/v2@v2.1.0
$(GOTEST) -v -cover -race -coverprofile=$(COVERAGE_OUT) ./... 2>&1 | go-junit-report -set-exit-code -iocopy -out $(JUNIT_OUT)
.PHONY: coverage-html
coverage-html: test ## Generate and open HTML coverage report
$(GOCMD) tool cover -html=$(COVERAGE_OUT)
.PHONY: fmt
fmt: ## Format Go code
$(GOFMT) ./...
.PHONY: fmt-check
fmt-check: ## Check if Go code is formatted (fails if not)
@if [ -n "$$(gofmt -l .)" ]; then \
echo "The following files are not formatted:"; \
gofmt -l .; \
exit 1; \
fi
.PHONY: lint
lint: ## Run golangci-lint
go install -v "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6"
golangci-lint run
.PHONY: clean
clean: ## Clean build artifacts and coverage files
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(COVERAGE_OUT)
rm -f $(LINT_OUT)