PROJECT_NAME := $(shell basename $(shell pwd)) GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') IMAGE_TAG := $(PROJECT_NAME):$(GIT_BRANCH) AUTHZD_BIN := bin/authzd SPARKLED_BIN := bin/sparkled ZED := bin/zed .PHONY: clean setup build test run db-setup $(AUTHZD_BIN): $(shell find . -name "*.go" 2>/dev/null) go.sum @go build -o $(AUTHZD_BIN) ./cmd/authzd/main.go $(SPARKLED_BIN): $(shell find . -name "*.go" 2>/dev/null) go.sum @go build -o $(SPARKLED_BIN) ./cmd/sparkled/main.go clean: @rm -f $(AUTHZD_BIN) $(SPARKLED_BIN) @go clean -testcache setup: @mise install @mise exec go -- go install github.com/xlgmokha/minit@latest @mise exec go -- go mod tidy @mise exec go -- go mod vendor @mise exec go -- go tool @if command -v brew >/dev/null 2>&1; then \ brew bundle; \ fi @mise exec python -- pip install dumb-init build: $(AUTHZD_BIN) $(SPARKLED_BIN) test-schema: @$(ZED) validate etc/authzd/*.yaml test-unit: @go test -shuffle=on ./... test-race: @CGO_ENABLED=1 go test -race -shuffle=on ./... test-integration: build-image @IMAGE_TAG=$(IMAGE_TAG) go test -tags=integration ./test/integration/... test: clean test-unit test-schema test-integration build-image: @docker build --network=host --no-cache --tag $(IMAGE_TAG) . run: clean build @go tool godotenv -f .env.local,.env go tool minit run-image: clean build-image @docker run --rm --network host --env-file .env.local -p 10000:10000 -p 9901:9901 -p 8080:8080 -it $(IMAGE_TAG) lint: @go tool yamlfmt -lint -exclude vendor . @$(ZED) validate etc/authzd/* tidy: @go get -u ./... @go mod tidy @go mod vendor @go tool yamlfmt -exclude vendor . db-schema-load: @$(ZED) schema write etc/authzd/schema.zed db-seed: @$(ZED) import etc/authzd/relationships.yaml db-setup: db-schema-load db-seed