-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (103 loc) · 4.09 KB
/
Copy paththeme-validation.yml
File metadata and controls
114 lines (103 loc) · 4.09 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
112
113
114
name: Theme Validation
on:
pull_request:
paths:
- 'themes/**'
- 'plugins/**'
push:
branches: [main]
paths:
- 'themes/**'
- 'plugins/**'
jobs:
validate:
runs-on: ubuntu-latest
name: Validate WordPress Themes
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer
- name: Install PHPCS & WordPress Standards
run: |
composer install --no-interaction --prefer-dist
./vendor/bin/phpcs -i
- name: Security Scan
run: |
chmod +x scripts/wordpress/security-scan.sh
ERRORS=0
for theme_dir in themes/*/; do
if [ -d "$theme_dir" ]; then
theme_name=$(basename "$theme_dir")
echo "=== Security scan: $theme_name ==="
find "$theme_dir" -name "*.php" | while read -r f; do
echo "{\"tool_input\":{\"file_path\":\"$f\"}}" | ./scripts/wordpress/security-scan.sh 2>&1 || ERRORS=$((ERRORS + 1))
done
fi
done
exit $ERRORS
- name: WordPress Coding Standards
run: |
for theme_dir in themes/*/; do
if [ -d "$theme_dir" ]; then
theme_name=$(basename "$theme_dir")
echo "=== PHPCS: $theme_name ==="
./vendor/bin/phpcs --standard=WordPress --severity=5 --report=summary "$theme_dir" || true
fi
done
- name: Block Markup Validation
run: |
chmod +x scripts/block-markup-validator/validate-block-markup.sh 2>/dev/null || true
for theme_dir in themes/*/; do
if [ -d "$theme_dir" ]; then
theme_name=$(basename "$theme_dir")
echo "=== Block markup: $theme_name ==="
find "$theme_dir" \( -path "*/templates/*.html" -o -path "*/parts/*.html" \) | while read -r f; do
echo "{\"tool_input\":{\"file_path\":\"$f\"}}" | ./scripts/block-markup-validator/validate-block-markup.sh 2>&1 || true
done
fi
done
- name: Token Compliance
run: |
chmod +x scripts/theme-token-auditor/audit-tokens.sh 2>/dev/null || true
for theme_dir in themes/*/; do
if [ -d "$theme_dir" ]; then
theme_name=$(basename "$theme_dir")
echo "=== Token audit: $theme_name ==="
find "$theme_dir" \( -name "*.php" -o -name "*.css" \) | while read -r f; do
echo "{\"tool_input\":{\"file_path\":\"$f\"}}" | ./scripts/theme-token-auditor/audit-tokens.sh 2>&1 || true
done
fi
done
- name: Required Files Check
run: |
EXIT=0
for theme_dir in themes/*/; do
if [ -d "$theme_dir" ]; then
theme_name=$(basename "$theme_dir")
echo "=== Required files: $theme_name ==="
[ -f "$theme_dir/style.css" ] && echo " style.css: OK" || { echo " style.css: MISSING"; EXIT=1; }
[ -f "$theme_dir/theme.json" ] && echo " theme.json: OK" || { echo " theme.json: MISSING"; EXIT=1; }
[ -f "$theme_dir/templates/index.html" ] && echo " templates/index.html: OK" || { echo " templates/index.html: MISSING"; EXIT=1; }
fi
done
exit $EXIT
- name: Pattern Architecture Check
run: |
for theme_dir in themes/*/; do
if [ -d "$theme_dir/templates" ]; then
theme_name=$(basename "$theme_dir")
echo "=== Pattern architecture: $theme_name ==="
ISSUES=0
find "$theme_dir/templates" -name "*.html" | while read -r f; do
if grep -q '<img' "$f" 2>/dev/null; then
echo " WARNING: Inline <img> in $(basename "$f") (should be in PHP pattern)"
ISSUES=$((ISSUES + 1))
fi
done
[ $ISSUES -eq 0 ] && echo " All templates follow pattern-first architecture"
fi
done