|
| 1 | +#!/bin/bash |
| 2 | +# Verify all deployed pages are working and not returning 404/redirect HTML |
| 3 | + |
| 4 | +RED='\033[0;31m' |
| 5 | +GREEN='\033[0;32m' |
| 6 | +YELLOW='\033[0;33m' |
| 7 | +NC='\033[0m' |
| 8 | + |
| 9 | +BASE="https://rbby.dev/gnata-sqlite" |
| 10 | +FAIL=0 |
| 11 | + |
| 12 | +check_page() { |
| 13 | + local url="$1" |
| 14 | + local label="$2" |
| 15 | + |
| 16 | + STATUS=$(curl -sL -o /tmp/verify-page.html -w "%{http_code}" "$url") |
| 17 | + |
| 18 | + # Check for 404 HTML or redirect script |
| 19 | + IS_404=false |
| 20 | + if grep -q 'window.location.replace' /tmp/verify-page.html 2>/dev/null; then |
| 21 | + IS_404=true |
| 22 | + fi |
| 23 | + if grep -q '<title>404</title>' /tmp/verify-page.html 2>/dev/null; then |
| 24 | + IS_404=true |
| 25 | + fi |
| 26 | + # Check if it's the GitHub Pages 404 |
| 27 | + if [ "$STATUS" = "404" ]; then |
| 28 | + IS_404=true |
| 29 | + fi |
| 30 | + # Check if content is suspiciously small (likely 404 redirect) |
| 31 | + SIZE=$(wc -c < /tmp/verify-page.html | tr -d ' ') |
| 32 | + if [ "$SIZE" -lt 500 ]; then |
| 33 | + IS_404=true |
| 34 | + fi |
| 35 | + |
| 36 | + if [ "$IS_404" = true ]; then |
| 37 | + echo -e "${RED}FAIL${NC} [$STATUS] $label ($url) — got 404 or redirect page (${SIZE}B)" |
| 38 | + FAIL=1 |
| 39 | + else |
| 40 | + echo -e "${GREEN}OK${NC} [$STATUS] $label ($url) (${SIZE}B)" |
| 41 | + fi |
| 42 | +} |
| 43 | + |
| 44 | +check_asset() { |
| 45 | + local url="$1" |
| 46 | + local label="$2" |
| 47 | + local expect_type="$3" |
| 48 | + |
| 49 | + STATUS=$(curl -sL -o /dev/null -w "%{http_code}" "$url") |
| 50 | + CTYPE=$(curl -sL -o /dev/null -w "%{content_type}" "$url") |
| 51 | + |
| 52 | + if [ "$STATUS" = "200" ]; then |
| 53 | + if [ -n "$expect_type" ] && ! echo "$CTYPE" | grep -q "$expect_type"; then |
| 54 | + echo -e "${YELLOW}WARN${NC} [$STATUS] $label — wrong content-type: $CTYPE (expected $expect_type)" |
| 55 | + FAIL=1 |
| 56 | + else |
| 57 | + echo -e "${GREEN}OK${NC} [$STATUS] $label ($CTYPE)" |
| 58 | + fi |
| 59 | + else |
| 60 | + echo -e "${RED}FAIL${NC} [$STATUS] $label ($url)" |
| 61 | + FAIL=1 |
| 62 | + fi |
| 63 | +} |
| 64 | + |
| 65 | +echo "=== Checking pages ===" |
| 66 | +check_page "$BASE/" "Docs landing" |
| 67 | +check_page "$BASE/docs" "Docs index" |
| 68 | +check_page "$BASE/docs/tutorials/getting-started" "Getting Started" |
| 69 | +check_page "$BASE/docs/tutorials/react-widget" "React Widget docs" |
| 70 | +check_page "$BASE/docs/explanation/architecture" "Architecture docs" |
| 71 | +check_page "$BASE/playground/" "Playground root" |
| 72 | +check_page "$BASE/playground/gnata" "Playground gnata mode" |
| 73 | +check_page "$BASE/playground/sqlite" "Playground sqlite mode" |
| 74 | + |
| 75 | +echo "" |
| 76 | +echo "=== Checking OG image ===" |
| 77 | +# Extract OG URL from deployed HTML |
| 78 | +OG_URL=$(curl -sL "$BASE/" | python3 -c " |
| 79 | +import re, sys |
| 80 | +html = sys.stdin.read() |
| 81 | +m = re.search(r'og:image\x22 content=\x22([^\x22]+)\x22', html) |
| 82 | +print(m.group(1) if m else '') |
| 83 | +") |
| 84 | + |
| 85 | +if [ -n "$OG_URL" ]; then |
| 86 | + echo "OG URL in HTML: $OG_URL" |
| 87 | + check_asset "$OG_URL" "OG image" "image" |
| 88 | +else |
| 89 | + echo -e "${RED}FAIL${NC} Could not find og:image in HTML" |
| 90 | + FAIL=1 |
| 91 | +fi |
| 92 | + |
| 93 | +echo "" |
| 94 | +echo "=== Checking key assets ===" |
| 95 | +check_asset "$BASE/gnata.wasm" "gnata.wasm" "application/wasm" |
| 96 | +check_asset "$BASE/gnata-lsp.wasm" "gnata-lsp.wasm" "application/wasm" |
| 97 | +check_asset "$BASE/playground/gnata.wasm" "playground gnata.wasm" "application/wasm" |
| 98 | + |
| 99 | +echo "" |
| 100 | +if [ $FAIL -eq 0 ]; then |
| 101 | + echo -e "${GREEN}All checks passed!${NC}" |
| 102 | +else |
| 103 | + echo -e "${RED}Some checks failed.${NC}" |
| 104 | +fi |
| 105 | +exit $FAIL |
0 commit comments