-
-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (123 loc) Β· 5.69 KB
/
wordpress-standards-check.yml
File metadata and controls
149 lines (123 loc) Β· 5.69 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# WordPress Best Practices Checker using Gemini AI
# Analyzes commits for WordPress coding standards and best practices compliance
name: WordPress Best Practices Check
on:
push:
branches: [ main, develop ]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
# Cancel previous workflow runs for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
wordpress-standards-check:
name: WordPress Standards & Best Practices
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed PHP files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
**/*.php
separator: "\n"
- name: Run WordPress Best Practices Analysis
if: steps.changed-files.outputs.any_changed == 'true'
uses: google-github-actions/run-gemini-cli@v0.1.10
with:
prompt: |
You are a WordPress development expert and WordPress.org plugin reviewer.
WORDPRESS BEST PRACTICES ANALYSIS:
Review the following code changes for WordPress coding standards and best practices:
π CODING STANDARDS (WordPress Coding Standards):
- PSR-4 autoloading compliance
- Proper function and variable naming (snake_case)
- Class naming conventions (PascalCase with underscores)
- File naming conventions (lowercase with hyphens)
- Proper indentation (tabs vs spaces - WordPress uses tabs)
- Line length limits (150 characters max)
- Proper commenting and PHPDoc blocks
ποΈ ARCHITECTURE & STRUCTURE:
- Single responsibility principle
- Proper use of WordPress hooks (actions/filters)
- Singleton pattern implementation
- Plugin structure and organization
- Proper use of WordPress APIs
π§ WORDPRESS-SPECIFIC BEST PRACTICES:
- Proper plugin header format
- Text domain usage and internationalization
- Capability checks and user permissions
- Database interaction using WordPress functions
- Proper enqueueing of scripts and styles
- Use of WordPress constants and globals
- Plugin activation/deactivation hooks
β‘ PERFORMANCE CONSIDERATIONS:
- Efficient database queries
- Proper caching strategies
- Lazy loading where appropriate
- Avoiding resource-heavy operations
- Proper use of transients
π― PLUGIN-SPECIFIC CHECKS:
- WooCommerce integration best practices
- Admin interface conventions
- REST API implementation
- Custom post type registration
- Meta box implementation
π± COMPATIBILITY:
- PHP version compatibility (7.4+)
- WordPress version compatibility (6.5+)
- Plugin conflicts avoidance
- Theme compatibility
For each finding:
1. Specify the file and line number
2. Explain the issue and why it matters
3. Provide the correct WordPress way to implement it
4. Reference relevant WordPress Codex documentation
5. Rate severity: CRITICAL, HIGH, MEDIUM, LOW, or INFO
Focus on improvements that enhance:
- Code maintainability
- WordPress ecosystem compatibility
- Performance and user experience
- Developer experience
FILES TO ANALYZE:
${{ steps.changed-files.outputs.all_changed_files }}
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
- name: Comment on PR with Findings
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
// This would be the output from Gemini CLI
const comment = `
## π― WordPress Best Practices Review
Thank you for your contribution! I've analyzed your code changes for WordPress best practices and coding standards.
### π Analysis Summary
- **Files Analyzed:** ${{ steps.changed-files.outputs.all_changed_files_count }}
- **WordPress Version:** 6.5+ compatible
- **PHP Version:** 7.4+ compatible
### π Key Areas Reviewed
β
WordPress Coding Standards
β
Plugin Architecture
β
Security Best Practices
β
Performance Considerations
β
Internationalization
> **Note:** This is an AI-powered analysis. Please review suggestions carefully and validate against the [WordPress Plugin Developer Handbook](https://developer.wordpress.org/plugins/).
**Workflow Run:** ${context.payload.repository.html_url}/actions/runs/${context.runId}
`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});