Skip to content

Commit 0ed80a4

Browse files
committed
Add CI workflow for HTML validation
1 parent 8e74450 commit 0ed80a4

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
validate:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Check HTML syntax
21+
run: |
22+
# Find all HTML files and check for basic syntax issues
23+
find . -name "*.html" -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do
24+
echo "Checking $file"
25+
# Check for unclosed tags, basic structure
26+
if ! grep -q "<!DOCTYPE html>" "$file" && ! grep -q "<!doctype html>" "$file"; then
27+
echo "Warning: $file missing DOCTYPE"
28+
fi
29+
done
30+
31+
- name: Check for broken local links
32+
run: |
33+
# Simple check for broken local file references
34+
find . -name "*.html" -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do
35+
dir=$(dirname "$file")
36+
grep -oP 'href="[^"#]*"' "$file" 2>/dev/null | grep -v 'http' | grep -v 'mailto' | while read link; do
37+
target=$(echo "$link" | sed 's/href="//;s/"$//')
38+
if [ -n "$target" ] && [ ! -f "$dir/$target" ]; then
39+
echo "Warning: $file references $target (not found)"
40+
fi
41+
done
42+
done
43+
44+
- name: Validate JSON files
45+
run: |
46+
find . -name "*.json" -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do
47+
echo "Validating $file"
48+
python3 -m json.tool "$file" > /dev/null || echo "Invalid JSON: $file"
49+
done
50+
51+
- name: Check file sizes
52+
run: |
53+
# Warn about large files
54+
find . -type f -not -path "./.git/*" -not -path "./node_modules/*" -size +5M | while read file; do
55+
echo "Warning: Large file detected: $file ($(du -h "$file" | cut -f1))"
56+
done

0 commit comments

Comments
 (0)