Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (64 loc) · 2.48 KB
/
Copy pathMakefile
File metadata and controls
77 lines (64 loc) · 2.48 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
SHELL := bash
MODULE := github.com/shippingbytes/metallo
BIN_DIR := bin
CMD := ./cmd/metallod
BINARY := $(BIN_DIR)/metallod
VERSION := $(shell git describe --tags --dirty --always 2>/dev/null || echo dev)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X '$(MODULE)/internal/version.Version=$(VERSION)' \
-X '$(MODULE)/internal/version.Commit=$(COMMIT)' \
-X '$(MODULE)/internal/version.Date=$(DATE)'
.PHONY: all
all: verify
.PHONY: build
build:
@mkdir -p $(BIN_DIR)
go build -trimpath -ldflags "$(LDFLAGS)" -o $(BINARY) $(CMD)
.PHONY: test
test:
CGO_ENABLED=1 go test -race ./...
.PHONY: lint
lint:
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found on PATH; skipping lint (install: https://golangci-lint.run/usage/install/)"; \
fi
# licenses enforces the allowlist in docs/04-build-vs-reuse.md §2: only
# permissive licenses may be linked in-process. GPL programs invoked as
# separate processes (e.g. iPXE) are out of scope for this check since
# they're not linked into the Go binary.
.PHONY: licenses
licenses:
go run github.com/google/go-licenses@latest check ./... \
--allowed_licenses=Apache-2.0,MIT,BSD-2-Clause,BSD-3-Clause,ISC,0BSD \
--ignore $(MODULE)
.PHONY: verify
verify: build test licenses
# e2e runs the full discovery -> inventory -> API/UI loop against the virtual
# rack (hack/e2e/e2e.sh). It self-provisions the lab + Postgres and tears
# everything down on exit, so it must run inside the nix devShell for qemu,
# sushy-emulator, and postgresql_16.
.PHONY: e2e
e2e:
nix develop --command hack/e2e/e2e.sh
# dev is the day-to-day loop: build metallod + metalloctl, start the
# throwaway dev deps (Postgres + dex), and run metallod in the foreground
# with the UI/auth/inspection-engine flags set correctly. No virtual lab —
# use `make demo` when you want BMCs. Ctrl-C stops metallod, dex, and
# Postgres. Re-execs into `nix develop` if run from a plain shell.
.PHONY: dev
dev:
hack/dev/run.sh
# demo is the out-of-the-box experience: dev deps + the N-node virtual lab
# (QEMU BMCs) + metallod with the engine flags that make discovery AND
# inspection work in one command. Ctrl-C tears it all down. Optional node
# count: `make demo N=1`. Re-execs into `nix develop` if run from a plain
# shell.
.PHONY: demo
demo:
hack/demo.sh $(N)
.PHONY: clean
clean:
rm -rf $(BIN_DIR)