1+ name : Website Tests
2+
3+ on :
4+ pull_request :
5+ branches : [ master ]
6+ push :
7+ branches : [ master ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v4
16+
17+ - name : HTML5 Validation
18+ uses : Cyb3r-Jak3/html5validator-action@v7.2.0
19+ with :
20+ root : ./
21+ css : true
22+
23+ - name : Link Checker
24+ uses : lycheeverse/lychee-action@v1.8.0
25+ with :
26+ args : --verbose --no-progress --accept 200,204,429 './**/*.html'
27+ fail : true
28+
29+ - name : Check for broken PDF links
30+ run : |
31+ echo "Checking for missing PDF files referenced in HTML..."
32+ for file in *.html includes/*.html teach/*.html; do
33+ if [ -f "$file" ]; then
34+ echo "Checking $file..."
35+ # Extract PDF links and check if files exist
36+ grep -oP 'href="[^"]*\.pdf"' "$file" | sed 's/href="//;s/"//' | while read -r link; do
37+ if [[ "$link" =~ ^http ]]; then
38+ echo " External PDF: $link (skipping local check)"
39+ elif [ ! -f "$link" ]; then
40+ echo " ERROR: Missing PDF file: $link"
41+ exit 1
42+ else
43+ echo " OK: $link"
44+ fi
45+ done
46+ fi
47+ done
48+
49+ - name : Check for missing image files
50+ run : |
51+ echo "Checking for missing image files..."
52+ for file in *.html includes/*.html teach/*.html; do
53+ if [ -f "$file" ]; then
54+ echo "Checking images in $file..."
55+ # Extract image src attributes
56+ grep -oP 'src="[^"]*\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF)"' "$file" | sed 's/src="//;s/"//' | while read -r img; do
57+ if [[ "$img" =~ ^http ]]; then
58+ echo " External image: $img (skipping local check)"
59+ elif [ ! -f "$img" ]; then
60+ echo " ERROR: Missing image file: $img"
61+ exit 1
62+ else
63+ echo " OK: $img"
64+ fi
65+ done
66+ fi
67+ done
68+
69+ - name : Check HTML structure consistency
70+ run : |
71+ echo "Checking HTML structure consistency..."
72+ # Check if all HTML files have proper DOCTYPE
73+ for file in *.html includes/*.html teach/*.html; do
74+ if [ -f "$file" ]; then
75+ if ! grep -q "<!DOCTYPE" "$file"; then
76+ echo "ERROR: $file is missing DOCTYPE declaration"
77+ exit 1
78+ fi
79+ fi
80+ done
81+
82+ # Check for consistent navigation menu
83+ echo "Checking navigation menu consistency..."
84+ menu_items=("index.html" "publication.html" "patents.html" "teach.html" "experience.html" "awards.html" "service.html" "talks.html" "students.html")
85+
86+ for file in *.html; do
87+ if [ -f "$file" ] && [ "$file" != "other.html" ]; then
88+ for item in "${menu_items[@]}"; do
89+ if ! grep -q "href=\"$item\"" "$file"; then
90+ echo "WARNING: $file may be missing navigation link to $item"
91+ fi
92+ done
93+ fi
94+ done
95+
96+ - name : Check for potential security issues
97+ run : |
98+ echo "Checking for potential security issues..."
99+ # Check for any potential XSS vulnerabilities (basic check)
100+ if grep -r "javascript:" *.html includes/*.html teach/*.html 2>/dev/null; then
101+ echo "WARNING: Found javascript: URLs which could be security risks"
102+ fi
103+
104+ # Check for any embedded scripts
105+ if grep -r "<script" *.html includes/*.html teach/*.html 2>/dev/null; then
106+ echo "INFO: Found embedded scripts - review for security"
107+ fi
108+
109+ echo "Security check completed"
0 commit comments