Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (42 loc) · 1.92 KB
/
Copy pathMakefile
File metadata and controls
55 lines (42 loc) · 1.92 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
GO ?= go
# golangci-lint must type-check with the Go version it was built against; override when the
# local toolchain is newer, e.g. LINT_GOTOOLCHAIN=go1.26.1.
LINT_GOTOOLCHAIN ?= local
BIN := bin
CMDS := ans-openshell-middleware ans-openshell-interceptor ans-ocsf-hydrator ans-reference-callee
.PHONY: all build proto test cover lint vet demo openshell-smoke openshell-smoke-trust-index clean
all: build
build:
@mkdir -p $(BIN)
@for c in $(CMDS); do echo "building $$c"; $(GO) build -o $(BIN)/$$c ./cmd/$$c; done
# Generated code must match CI byte for byte. protoc-gen-go formats its output with the
# go/format of the toolchain that built it, so the plugins are built with the CI toolchain.
PROTO_GOTOOLCHAIN ?= go1.26.9
PROTOC_GEN_GO_VERSION := v1.36.12
PROTOC_GEN_GO_GRPC_VERSION := v1.6.2
proto:
@mkdir -p $(BIN)
GOBIN=$(abspath $(BIN)) GOTOOLCHAIN=$(PROTO_GOTOOLCHAIN) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO_VERSION)
GOBIN=$(abspath $(BIN)) GOTOOLCHAIN=$(PROTO_GOTOOLCHAIN) $(GO) install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_GRPC_VERSION)
PATH="$(abspath $(BIN)):$$PATH" buf generate
test:
$(GO) test -race ./...
cover:
$(GO) test -race -coverprofile=coverage.out -covermode=atomic ./...
@grep -v -e '/gen/' -e '/cmd/' -e '/examples/' coverage.out > coverage.lib.out
@$(GO) tool cover -func=coverage.lib.out | tail -1
lint:
GOTOOLCHAIN=$(LINT_GOTOOLCHAIN) golangci-lint run ./...
vet:
$(GO) vet ./...
demo:
$(GO) run ./examples/demo
clean:
rm -rf $(BIN) coverage*.out
# End-to-end check against a real OpenShell gateway (Docker). See examples/openshell-smoke/README.md.
openshell-smoke:
examples/openshell-smoke/smoke.sh
# The same run, then its OCSF records scored by the hydrator and imported into a pinned
# agent-trust-discovery. See "Scoring the run's behavior" in the same README.
openshell-smoke-trust-index:
examples/openshell-smoke/smoke.sh --with-trust-index