forked from kassisol/hbm
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (75 loc) · 2.47 KB
/
Makefile
File metadata and controls
90 lines (75 loc) · 2.47 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
# HBM
.PHONY: all build clean test vendor format lint shellcheck dockerlint doclint help
DOCKER := $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null)
# Default target
all: build
# Build the HBM binary with version info
build:
@./scripts/build-target
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf bin/ dist/
rm -f hbm hbm-test
find . -name '*.test' -delete
# Run tests
test:
@echo "Running Go tests... Don't have any of these..."
go test ./...
# Vendor and clean
vendor:
@echo "Vendoring dependencies"
go mod vendor
@echo "Cleaning"
go mod tidy
@echo "Verify"
go mod verify
# Format Go code
format:
@echo "Formatting Go code..."
@for file in $$(find . -name '*.go' -type f -not -path "./.git/*" -not -path "./vendor/*"); do \
echo "Formatting: $$file"; \
gofmt -l -s -w "$$file"; \
done
# Build distribution packages for all supported platforms
packages: build
@./scripts/build-packages
# Run golangci-lint
lint:
@echo "Running golangci-lint..."
@which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
# Lint shell scripts
shellcheck:
@echo "Linting shell scripts..."
@for file in $$(find . -type f -name '*.sh' -not -path "./.git/*" -not -path "./vendor/*"); do \
echo "Checking: $$file"; \
$(DOCKER) run --rm -v "$$PWD:/mnt:ro" koalaman/shellcheck -e SC2086 -e SC2046 -e SC1090 "$$file" || true; \
done
# Lint Dockerfiles
dockerlint:
@echo "Linting Dockerfiles..."
@for file in $$(find . -name 'Dockerfile*' -not -name '*.dapper'); do \
echo "Checking: $$file"; \
$(DOCKER) run -i --rm hadolint/hadolint hadolint --ignore DL3018 --ignore DL3013 - < "$$file" || true; \
done
# Lint Markdown documentation
doclint:
@echo "Linting Markdown docs..."
$(DOCKER) run --rm -v "$$PWD:/workdir:ro" davidanson/markdownlint-cli2 "docs/**/*.md" "*.md"
# Show help
help:
@echo "HBM"
@echo ""
@echo "Targets:"
@echo " make build - Build HBM binary with version info"
@echo " make clean - Remove build artifacts"
@echo " make test - Run Go unit tests"
@echo " make format - Format Go code with gofmt"
@echo " make packages - Build RPM/DEB packages for all platforms"
@echo " make lint - Run golint"
@echo " make shellcheck - Lint shell scripts"
@echo " make dockerlint - Lint Dockerfiles"
@echo " make doclint - Lint Markdown documentation"
@echo " make help - Show this help"
.DEFAULT_GOAL := build