-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidate-build.sh
More file actions
executable file
Β·111 lines (98 loc) Β· 2.56 KB
/
validate-build.sh
File metadata and controls
executable file
Β·111 lines (98 loc) Β· 2.56 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Build validation script
# Run this locally to validate your build before pushing
# Usage:
# ./scripts/validate-build.sh # Build and validate
# ./scripts/validate-build.sh --skip-build # Only validate existing build
set -e
# Check if we should skip the build step
SKIP_BUILD=false
if [ "$1" = "--skip-build" ]; then
SKIP_BUILD=true
fi
if [ "$SKIP_BUILD" = false ]; then
echo "π Building site..."
npm run build
fi
echo ""
echo "β
Validating build output..."
echo ""
# Check that _site directory exists and has content
if [ ! -d "_site" ]; then
echo "β Build directory _site does not exist"
exit 1
fi
# Check critical files exist
critical_files=(
"_site/index.html"
"_site/sitemap.xml"
"_site/feed.xml"
"_site/static/robots.txt"
"_site/blog/index.html"
)
echo "Checking critical files..."
for file in "${critical_files[@]}"; do
if [ ! -f "$file" ]; then
echo "β Critical file missing: $file"
exit 1
fi
if [ ! -s "$file" ]; then
echo "β File is empty: $file"
exit 1
fi
echo " β $file"
done
# Count blog posts
blog_count=$(find _site/blog -name "index.html" -type f | wc -l | tr -d ' ')
echo ""
echo "Blog posts: $blog_count"
if [ "$blog_count" -lt 20 ]; then
echo "β Expected at least 20 blog posts, found: $blog_count"
exit 1
fi
# Check sitemap
echo ""
echo "Validating sitemap..."
if ! grep -q "<loc>https://rupertmckay.com/blog/" _site/sitemap.xml; then
echo "β Sitemap does not contain blog post URLs"
exit 1
fi
sitemap_urls=$(grep -c "<loc>" _site/sitemap.xml)
echo " β Sitemap contains $sitemap_urls URLs"
# Check feed
echo ""
echo "Validating RSS feed..."
if ! grep -q "<entry>" _site/feed.xml; then
echo "β RSS feed does not contain entries"
exit 1
fi
feed_entries=$(grep -c "<entry>" _site/feed.xml)
echo " β Feed contains $feed_entries entries"
# Check HTML structure
echo ""
echo "Validating HTML structure..."
invalid_count=0
for html_file in _site/*.html _site/blog/*/index.html; do
if [ -f "$html_file" ]; then
if ! grep -q "<html" "$html_file"; then
echo "β Invalid HTML structure in: $html_file"
invalid_count=$((invalid_count + 1))
fi
fi
done
if [ $invalid_count -gt 0 ]; then
echo "β Found $invalid_count invalid HTML files"
exit 1
fi
echo " β All HTML files have valid structure"
# Summary
total_size=$(du -sh _site | cut -f1)
echo ""
echo "β
Build validation passed!"
echo ""
echo "Summary:"
echo " Total size: $total_size"
echo " Blog posts: $blog_count"
echo " Sitemap URLs: $sitemap_urls"
echo " Feed entries: $feed_entries"
echo ""