forked from mtusi2026/mtusi2026lab2
54 lines
1.9 KiB
Makefile
54 lines
1.9 KiB
Makefile
PYTHON ?= python3
|
|
BASE_URL ?= http://localhost:8080
|
|
CA_FILE ?=
|
|
ACTION_SCRIPT ?=
|
|
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
|
OPENAPI_SPEC := contracts/openapi.json
|
|
GEN_OUTPUT := service/internal/gen/contracts/types.gen.go
|
|
GEN_PACKAGE := contracts
|
|
OAPI_CODEGEN ?= $(shell go env GOPATH)/bin/oapi-codegen
|
|
|
|
.PHONY: help check validate test load test-persistence openapi-generate certs key-gen
|
|
|
|
help:
|
|
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
|
|
|
check:
|
|
$(PYTHON) scripts/check_contract.py
|
|
|
|
validate:
|
|
$(PYTHON) scripts/validate_openapi.py
|
|
|
|
test:
|
|
$(PYTHON) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
load:
|
|
$(PYTHON) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-persistence:
|
|
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
|
|
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
openapi-generate:
|
|
@mkdir -p $(dir $(GEN_OUTPUT))
|
|
@echo "Generating Go types from $(OPENAPI_SPEC)..."
|
|
@set -o pipefail; \
|
|
jq '(.components.schemas.ChatPage.properties.next_cursor.type, .components.schemas.MessagePage.properties.next_cursor.type) |= "string" | (.components.schemas.ChatPage.properties.next_cursor.nullable, .components.schemas.MessagePage.properties.next_cursor.nullable) = true' $(OPENAPI_SPEC) | \
|
|
$(OAPI_CODEGEN) -generate types -package $(GEN_PACKAGE) -o $(GEN_OUTPUT) /dev/stdin
|
|
|
|
key-gen: create-dir gen-private-key gen-public-key
|
|
|
|
create-dir:
|
|
@mkdir -p certs
|
|
gen-private-key:
|
|
@openssl genrsa -out certs/private_key.pem 2048
|
|
gen-public-key:
|
|
@openssl rsa -in certs/private_key.pem -pubout -outform PEM -out certs/public_key.pem
|
|
|
|
certs: gen-key gen-crt
|
|
|
|
gen-key:
|
|
@openssl genrsa -out ./certs/server.key 2048
|
|
gen-crt:
|
|
@openssl req -new -x509 -key ./certs/server.key -out ./certs/server.crt -days 365
|