-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (90 loc) · 4.5 KB
/
Copy pathMakefile
File metadata and controls
111 lines (90 loc) · 4.5 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
102
103
104
105
106
107
108
109
110
111
.PHONY: build test vet lint lint-rules fix schema clean bench integration playground ci regression daemon-verify test-fanotify all install install-completions watch
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS = -s -w -X main.version=$(VERSION)
build:
go build -ldflags "$(LDFLAGS)" -o krit ./cmd/krit/
go build -ldflags "$(LDFLAGS)" -o krit-lsp ./cmd/krit-lsp/
go build -ldflags "$(LDFLAGS)" -o krit-mcp ./cmd/krit-mcp/
go build -ldflags "$(LDFLAGS)" -o krit-daemon ./cmd/krit-daemon/
go build -ldflags "$(LDFLAGS)" -o krit-changelog ./cmd/krit-changelog/
test:
go test ./... -count=1
vet:
go vet ./...
# lint-rules enforces static gates against the rules package (all run
# inside TestRulesPackageHasNoCapabilityDrift via the shared Analyze pass):
# - capability-declaration: ctx.Resolver / .Oracle() needs NeedsResolver / NeedsOracle
# - concurrent-state: go/WaitGroup/MergeCollectors needs NeedsConcurrent
# - fix-drift: Fix != FixNone requires an f.Fix assignment in the Check body
# - opt-in-reason: DefaultActive: false requires an OptInReason classification
# - java-support-coverage: rules declaring NeedsTypeInfo/NeedsResolver must
# carry an explicit Java LanguageSupport entry (existing rules are
# grandfathered; new ones must classify)
# - fix-mode-mutual-exclusion: every registered rule must declare exactly
# one fix mode (autofix XOR suggested), see docs/suggested-fixes.md
lint-rules:
go test ./internal/ruleslinter/ -run 'TestRulesPackageHasNoCapabilityDrift|TestRulesPackageHasNoNewAdHocCaches|TestRulesPackageHasOptInReasons|TestRulesPackageHasNoDefensiveContextGuards' -count=1
go test ./internal/rules/ -run 'TestRulesWithTypeInfoDeclareExplicitJavaSupport|TestRegistryFixModeIsValid|TestRegistryFixModeIsObservable' -count=1
lint: build
./krit .
fix: build
./krit --fix .
schema: build
./krit --generate-schema > schemas/krit-config.schema.json
clean:
rm -f krit krit-lsp krit-mcp krit-daemon krit-changelog
bench:
go test ./internal/... -bench=. -benchmem -count=3 -timeout 120s
integration: build
bash scripts/integration-test.sh
playground: build
./krit -f json playground/kotlin-webservice/ | head -20
./krit -f json playground/android-app/ | head -20
regression: build
bash scripts/regression-check.sh
# daemon-verify runs the divergence harness unit suite, which is the
# correctness oracle for the daemon's resident-cache path. When daemon
# strict-verify mode lands it will also drive the harness across the
# fixture tree and any opt-in corpus pointed at by KRIT_CORPUS_DIR.
daemon-verify:
go test ./internal/daemon/ -run 'TestCompare|TestDiff' -count=1
ci: build vet test integration regression daemon-verify
# test-fanotify exercises the Linux-only fanotify watcher backend
# inside a Docker container with CAP_SYS_ADMIN. macOS / Windows
# developers can't run fanotify locally — this target gives them a
# kernel that supports FAN_REPORT_DFID_NAME (Linux 5.17+). The
# --security-opt unconfined arg is needed so the apparmor profile
# Docker Desktop ships doesn't block fanotify_init.
#
# --tmpfs /tmp is critical: Docker's default /tmp is on overlayfs,
# which doesn't implement the kernel's file-handle export hooks, so
# FAN_MARK_FILESYSTEM fails with EOPNOTSUPP. tmpfs does export
# handles, so t.TempDir() (which uses /tmp) lands on a filesystem
# fanotify can actually mark.
test-fanotify:
docker build -f Dockerfile.fanotify -t krit-fanotify-test .
docker run --rm \
--cap-add=SYS_ADMIN \
--cap-add=DAC_READ_SEARCH \
--security-opt apparmor=unconfined \
--tmpfs /tmp:exec \
krit-fanotify-test
DESTDIR ?=
install: build
install -d $(DESTDIR)/usr/local/bin
install -m 755 krit $(DESTDIR)/usr/local/bin/krit
install -m 755 krit-lsp $(DESTDIR)/usr/local/bin/krit-lsp
install -m 755 krit-mcp $(DESTDIR)/usr/local/bin/krit-mcp
install -m 755 krit-daemon $(DESTDIR)/usr/local/bin/krit-daemon
install-completions:
install -d $(HOME)/.local/share/bash-completion/completions
install -m 644 scripts/completions/krit.bash $(HOME)/.local/share/bash-completion/completions/krit
install -d $(HOME)/.local/share/zsh/site-functions
install -m 644 scripts/completions/krit.zsh $(HOME)/.local/share/zsh/site-functions/_krit
install -d $(HOME)/.config/fish/completions
install -m 644 scripts/completions/krit.fish $(HOME)/.config/fish/completions/krit.fish
watch:
@echo "Watching for changes... (requires fswatch)"
@fswatch -o internal/ cmd/ | xargs -n1 -I{} make test 2>/dev/null || \
echo "Install fswatch: brew install fswatch"
all: build vet test