PROJECT_NAME := $(shell basename $(shell pwd))# {{{}}} GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') IMAGE_TAG := $(PROJECT_NAME):$(GIT_BRANCH) .PHONY: build check test run clean fmt lint doc vendor .PHONY: build-image run-image health-check list-services test-image setup: mise install mise exec go -- go install github.com/mattn/goreman@latest mise exec rustup -- rustup component add clippy rustfmt # Cargo targets build: @cargo build --offline check: @cargo check test: @cargo test run: build @cp target/debug/authzd bin/authzd @goreman -set-ports=false -rpc-server=false -f ./Procfile -exit-on-error=true start clean: @cargo clean fmt: @cargo fmt lint: @cargo clippy doc: @cargo doc --open vendor: @cargo vendor # Docker targets build-image: @docker build --tag $(IMAGE_TAG) . build-image-clean: @docker build --tag $(IMAGE_TAG) . run-image: build-image @docker run --rm -p 10000:10000 -p 9901:9901 --init -it $(IMAGE_TAG) # HTTP and gRPC testing targets health-check: @curl -s http://localhost:10000/health || echo "Service not running" envoy-admin: @curl -s http://localhost:9901/stats/prometheus | head -20 list-services: @grpcurl -plaintext localhost:50051 list test-image: build-image @echo "Starting container..." @docker run -d --name authzd-test -p 10000:10000 -p 9901:9901 $(IMAGE_TAG) @echo "Waiting for services to start..." @sleep 5 @echo "Testing Envoy admin endpoint..." @curl -s http://localhost:9901/stats/prometheus | grep -q "envoy_" && echo "✓ Envoy admin is accessible" || echo "✗ Envoy admin failed" @echo "Testing health endpoint..." @curl -s -o /dev/null -w "%{http_code}" http://localhost:10000/health | grep -q "200" && echo "✓ Health check passed" || echo "✗ Health check failed" @echo "Testing authorization flow..." @curl -s -H "Authorization: Bearer valid-token" http://localhost:10000/ -w "\n%{http_code}" | grep -q "200" && echo "✓ Auth with valid token passed" || echo "✗ Auth with valid token failed" @curl -s http://localhost:10000/ -w "\n%{http_code}" | grep -q "401" && echo "✓ Auth without token correctly rejected" || echo "✗ Auth without token failed" @echo "Cleaning up..." @docker stop authzd-test && docker rm authzd-test