diff --git a/scripts/verify.sh b/scripts/verify.sh new file mode 100644 index 0000000..0800f78 --- /dev/null +++ b/scripts/verify.sh @@ -0,0 +1,31 @@ +#!/bin/sh +set -eu +ruff format --check . +ruff check . +mypy app +pytest + +docker build -t endpoint-monitor:verify . +container="$(docker run -d -p 127.0.0.1:18000:8000 endpoint-monitor:verify)" +trap 'docker rm -f "$container" >/dev/null 2>&1 || true' EXIT +tries=0 +until python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:18000/health/ready', timeout=1)"; do + tries=$((tries + 1)) + [ "$tries" -lt 20 ] || exit 1 + sleep 0.5 +done +python - <<'PY' +import json +import urllib.request +base = "http://127.0.0.1:18000" +assert json.load(urllib.request.urlopen(base + "/health/live")) == {"status": "ok"} +request = urllib.request.Request( + base + "/monitors", + data=b'{"name":"smoke","url":"https://example.com"}', + headers={"content-type": "application/json"}, + method="POST", +) +created = json.load(urllib.request.urlopen(request)) +assert created["name"] == "smoke" +assert len(json.load(urllib.request.urlopen(base + "/monitors"))) == 1 +PY