chore: add developer make targets

This commit is contained in:
2026-06-16 14:49:22 +02:00
parent ae454a0b4f
commit d3c4d4bd86

63
Makefile Normal file
View File

@@ -0,0 +1,63 @@
SHELL := /bin/sh
CARGO ?= cargo
DOCKER ?= docker
IMAGE ?= pokedex-api
TAG ?= local
BASE_URL ?= http://localhost:8000
POKEMON ?= mewtwo
PLATFORMS ?= linux/amd64,linux/arm64
GIT_SHA ?= $(shell git rev-parse HEAD 2>/dev/null || printf unknown)
.PHONY: help run docker-build docker-run health pokemon translated metrics fmt clippy test check contract-test docker-buildx
help:
@printf 'Available targets:\n'
@printf ' make run Run the API locally with cargo\n'
@printf ' make docker-build Build the Docker image\n'
@printf ' make docker-run Run the Docker image on port 8000\n'
@printf ' make health curl /health\n'
@printf ' make pokemon curl /pokemon/$${POKEMON}\n'
@printf ' make translated curl /pokemon/translated/$${POKEMON}\n'
@printf ' make metrics curl /metrics\n'
@printf ' make check Run fmt, clippy, and tests\n'
@printf ' make contract-test Run ignored external contract tests\n'
@printf ' make docker-buildx Build multi-arch Docker image\n'
run:
$(CARGO) run --bin pokedex-api
docker-build:
$(DOCKER) build -t $(IMAGE) .
docker-run:
$(DOCKER) run --rm -p 8000:8000 $(IMAGE)
health:
curl -fsS $(BASE_URL)/health
pokemon:
curl -fsS $(BASE_URL)/pokemon/$(POKEMON)
translated:
curl -fsS $(BASE_URL)/pokemon/translated/$(POKEMON)
metrics:
curl -fsS $(BASE_URL)/metrics
fmt:
$(CARGO) fmt --all --check
clippy:
$(CARGO) clippy --locked --all-targets -- -D warnings
test:
$(CARGO) test --locked
check: fmt clippy test
contract-test:
$(CARGO) test --locked --test external_contract -- --ignored --test-threads=1
docker-buildx:
$(DOCKER) buildx build --platform $(PLATFORMS) --build-arg GIT_SHA=$(GIT_SHA) -t $(IMAGE):$(TAG) .