Files
sift/Makefile
T
kyle 8e3a6cd339 p1: cap jq output, log refusals, fail contract without SDK
jq results are bounded (10k items / output cap) and return 400 when
exceeded. 401/403 log caller, host, and reason. make contract exits 1
unless firecrawl-py is present (SIFT_CONTRACT_SKIP_SDK=1 to skip).
2026-09-22 22:02:38 -07:00

51 lines
1.7 KiB
Makefile

# Makefile is the source of truth for build flags. The flake's buildGoModule
# uses the same -trimpath / ldflags, and `nix flake check` runs `make test lint`.
PREFIX ?= /usr/local
DESTDIR ?=
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
CGO_ENABLED ?= 0
GO ?= go
STATICCHECK ?= $(shell command -v staticcheck 2>/dev/null)
.PHONY: all build test lint contract install clean
all: build
build:
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -trimpath -ldflags "$(LDFLAGS)" -o bin/sift ./cmd/sift
test:
$(GO) test -race ./...
lint:
$(GO) vet ./...
@if [ -n "$(STATICCHECK)" ]; then $(STATICCHECK) ./...; else echo "staticcheck not found; skipped"; fi
# Hermes 0.19/0.21 SDK harness (firecrawl-py==4.17.0) against a local sifttest binary.
contract:
$(GO) test -count=1 ./internal/api ./internal/auth ./internal/guard
@if command -v python3 >/dev/null 2>&1; then \
$(GO) build -tags sifttest -trimpath -ldflags "$(LDFLAGS)" -o bin/sift-test ./cmd/sift && \
python3 tests/contract/sdk_test.py; \
else \
if [ "$$SIFT_CONTRACT_SKIP_SDK" = "1" ]; then echo "python3 missing; skipped"; \
else echo "python3 required for make contract" >&2; exit 1; fi; \
fi
install: build
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 bin/sift $(DESTDIR)$(PREFIX)/bin/sift
install -d $(DESTDIR)/etc/sift
if [ ! -f $(DESTDIR)/etc/sift/config.toml ]; then \
install -m 644 dist/sift.toml.example $(DESTDIR)/etc/sift/config.toml; \
fi
install -d $(DESTDIR)$(PREFIX)/lib/systemd/system
install -m 644 dist/sift.service $(DESTDIR)$(PREFIX)/lib/systemd/system/sift.service
clean:
rm -rf bin/
rm -f sift *.test