Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (81 loc) · 3.14 KB
/
Copy pathMakefile
File metadata and controls
101 lines (81 loc) · 3.14 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
# tui-secure — build, test and lint.
GO ?= go
BIN ?= bin
TOOL := tui-secure
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
# The screenshot renderer is shared by the whole family and ships with the
# kit, which is already a dependency: ask the module cache where it landed.
KIT = $(shell $(GO) list -m -f '{{.Dir}}' github.com/tui-tools/tui-kit)
.PHONY: manifest readme compat check-exec all build test vet fmt fmt-check lint check demo clean tidy install screenshots
all: check build
## build: compile the tool into $(BIN) as a static binary.
build:
@mkdir -p $(BIN)
CGO_ENABLED=0 $(GO) build -trimpath -ldflags "$(LDFLAGS)" \
-o $(BIN)/$(TOOL) ./cmd/$(TOOL)
## test: run the unit tests.
test:
$(GO) test ./...
## vet: run the standard static checks.
vet:
$(GO) vet ./...
## fmt: rewrite the sources with gofmt.
fmt:
gofmt -w .
## fmt-check: fail when something is not gofmt-clean.
fmt-check:
@out=$$(gofmt -l .); \
if [ -n "$$out" ]; then \
echo "these files need gofmt:"; echo "$$out"; exit 1; \
fi
## lint: fmt-check, vet and the exec boundary. golangci-lint when installed.
lint: fmt-check vet check-exec
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed, skipping"; \
fi
## check: everything CI runs.
check: lint test
## demo: run against the in-memory sample data.
demo:
$(GO) run ./cmd/$(TOOL) --demo
## install: install the tool into GOBIN.
install:
CGO_ENABLED=0 $(GO) install -trimpath -ldflags "$(LDFLAGS)" ./cmd/$(TOOL)
## tidy: prune and refresh go.mod / go.sum.
tidy:
$(GO) mod tidy
## screenshots: re-render the README frames from --demo (needs chrome/chromium).
screenshots: build
python3 $(KIT)/tools/render-screenshots.py \
--bin $(BIN)/$(TOOL) --name $(TOOL) --out docs/screenshots \
--screen main= --screen ssh='jjj\r' --screen updates='jjjj\r' \
--screen fix='jjjjjja' --screen filter='/ssh' \
--screen help=?
## readme: regenerate the generated README sections from tool.json.
readme:
python3 $(KIT)/tools/render-install.py --manifest tool.json --readme README.md
python3 $(KIT)/tools/render-compat.py --manifest tool.json --readme README.md
## compat: harvest the lab logs into compat/results.jsonl and regenerate the
## tested versions in tool.json. Run it after `lab.sh test $(TOOL)`.
compat:
python3 $(KIT)/tools/compat-sync.py --manifest tool.json \
--results compat/results.jsonl \
--from-log $(wildcard ../tui-lab/out/results/*-$(TOOL)/*.log)
## check-exec: assert that only a backend package starts a process.
check-exec:
bash $(KIT)/tools/check-exec.sh .
## manifest: validate tool.json against the family schema in tui-kit.
manifest:
@curl -fsSL --retry 3 -o /tmp/tui-tool.schema.json \
https://raw.githubusercontent.com/tui-tools/tui-kit/main/schema/tool.schema.json
@npx --yes -p ajv-cli@5 -p ajv-formats@3 ajv validate \
--spec=draft2020 -c ajv-formats \
-s /tmp/tui-tool.schema.json -d tool.json
@python3 $(KIT)/tools/check-nfpm.py --manifest tool.json \
--config .goreleaser.yaml
## clean: remove build output.
clean:
rm -rf $(BIN) dist