Spaces:
Sleeping
Sleeping
File size: 1,655 Bytes
7a23e48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/env bash
# validate-submission.sh — OpenEnv submission validator
# Usage: ./scripts/validate-submission.sh <ping_url> [repo_dir]
set -euo pipefail
PING_URL="${1:-}"
REPO_DIR="${2:-.}"
DOCKER_BUILD_TIMEOUT="${DOCKER_BUILD_TIMEOUT:-600}"
if [[ -z "$PING_URL" ]]; then
echo "Usage: $0 <ping_url> [repo_dir]"
echo "Example: $0 https://my-space.hf.space ."
exit 2
fi
if [[ ! -d "$REPO_DIR" ]]; then
echo "ERROR: repo_dir not found: $REPO_DIR"
exit 2
fi
cd "$REPO_DIR"
echo "==> 1/4 Ping Space root"
ROOT_CODE=$(curl -s -o /tmp/openenv_root.json -w '%{http_code}' "$PING_URL/")
if [[ "$ROOT_CODE" != "200" ]]; then
echo "FAIL: root ping returned $ROOT_CODE"
exit 1
fi
echo "==> 2/4 Ping reset endpoint"
RESET_CODE=$(curl -s -o /tmp/openenv_reset.json -w '%{http_code}' "$PING_URL/reset")
if [[ "$RESET_CODE" != "200" ]]; then
echo "FAIL: reset ping returned $RESET_CODE"
exit 1
fi
if ! grep -q '"observation"' /tmp/openenv_reset.json; then
echo "FAIL: /reset did not return observation"
exit 1
fi
echo "==> 3/4 openenv validate"
openenv validate
echo "==> 4/4 docker build"
if ! command -v docker >/dev/null 2>&1; then
echo "FAIL: docker command not found"
exit 1
fi
if command -v timeout >/dev/null 2>&1; then
if ! timeout "$DOCKER_BUILD_TIMEOUT" docker build -t code-review-env-validate .; then
echo "FAIL: docker build failed or timed out"
exit 1
fi
else
echo "WARN: timeout command not found, running docker build without timeout"
if ! docker build -t code-review-env-validate .; then
echo "FAIL: docker build failed"
exit 1
fi
fi
echo "PASS: submission validator checks completed"
|