-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (76 loc) · 2.69 KB
/
Makefile
File metadata and controls
97 lines (76 loc) · 2.69 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
.PHONY: coverage test inspect install sec-scan lint fmt check shellcheck
.PHONY: tree-hash docker-build docker-push docker-exists docker-promote docker-release docker-list
# Docker configuration with defaults (override with environment variables)
export DOCKER_REGISTRY ?= docker.io
export DOCKER_REPO ?= nomasters/haystack
export DOCKER_PLATFORMS ?= linux/amd64,linux/arm64
export DOCKER_PUSH ?= false
export SKIP_GIT_CHECK ?= false
# Go targets
test:
go test -v ./...
coverage:
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
inspect: coverage
go tool cover -html=coverage.txt
sec-scan:
gosec -fmt=json -out=gosec-report.json -stdout -verbose=text ./...
lint:
go vet ./...
fmt:
go fmt ./...
# Check shell scripts for issues
shellcheck:
@echo "Checking shell scripts with shellcheck..."
@shellcheck scripts/*.sh
check: fmt lint test shellcheck
@echo "All checks passed!"
update-deps:
go get -u && go mod tidy
install:
go install github.com/nomasters/haystack/cmd/haystack
# Docker targets - Local-first hermetic builds
# These commands work identically on your machine and in CI
# Calculate the tree hash of source files
tree-hash:
@./scripts/tree-hash.sh
# Build Docker image (idempotent - only builds if tree hash changed)
# Requires clean git working directory (override with SKIP_GIT_CHECK=true)
docker-build:
@./scripts/docker-build.sh
# Build and push Docker image to registry
docker-push:
@DOCKER_PUSH=true ./scripts/docker-build.sh
# Check if image exists for current tree hash
docker-exists:
@TREE_HASH=$$(./scripts/tree-hash.sh) && \
./scripts/docker-tags.sh exists "tree-$$TREE_HASH"
# Promote current commit's image with additional tags
# Usage: make docker-promote TAGS="v1.0.0"
docker-promote:
@if [ -z "$(TAGS)" ]; then \
echo "Error: TAGS variable required. Usage: make docker-promote TAGS=\"v1.0.0\""; \
exit 1; \
fi
@./scripts/docker-tags.sh release $(TAGS)
# Release workflow - build if needed, then tag
# Usage: make docker-release VERSION=v1.0.0
docker-release: docker-push
@if [ -z "$(VERSION)" ]; then \
echo "Error: VERSION variable required. Usage: make docker-release VERSION=v1.0.0"; \
exit 1; \
fi
@./scripts/docker-tags.sh release $(VERSION)
# List all Docker tags in the registry
docker-list:
@./scripts/docker-tags.sh list
# Clean up local Docker buildx builders
docker-clean:
@docker buildx rm haystack-builder 2>/dev/null || true
# Show current build information
docker-info:
@echo "Tree hash: $$(./scripts/tree-hash.sh)"
@echo "Commit SHA: $$(git rev-parse --short HEAD)"
@echo "Branch: $$(git rev-parse --abbrev-ref HEAD)"
@echo "Registry: $${DOCKER_REGISTRY:-docker.io}"
@echo "Repository: $${DOCKER_REPO:-nomasters/haystack}"