@@ -164,6 +164,158 @@ jobs:
164164 filename: .github/ISSUE_TEMPLATE/phpcs-failure.md
165165 update_existing: false
166166
167+ vip-phpcs:
168+ name: WordPress VIP Coding Standards (PHP ${{ matrix.php-version }})
169+ runs-on: ubuntu-latest
170+ strategy:
171+ matrix:
172+ php-version: ['7.4', '8.0', '8.3', '8.4']
173+ fail-fast: false
174+
175+ steps:
176+ - name: Checkout code
177+ uses: actions/checkout@v5
178+
179+ - name: Setup PHP ${{ matrix.php-version }}
180+ uses: shivammathur/setup-php@v2
181+ with:
182+ php-version: ${{ matrix.php-version }}
183+ extensions: mysqli, curl, zip, intl, gd, mbstring, fileinfo, xml
184+ coverage: none
185+ tools: composer:v2, phpcs
186+
187+ - name: Install Composer dependencies
188+ uses: ramsey/composer-install@v3
189+ with:
190+ dependency-versions: highest
191+ composer-options: "--prefer-dist --no-progress"
192+
193+ - name: Install WordPress VIP Coding Standards
194+ run: |
195+ # Install PHPCS and WordPress VIP Coding Standards
196+ composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
197+ composer global require --dev squizlabs/php_codesniffer:"^3.7"
198+ composer global require --dev wp-coding-standards/wpcs:"^3.0"
199+ composer global require --dev automattic/vipwpcs:"^3.0"
200+ composer global require --dev dealerdirect/phpcodesniffer-composer-installer:"^1.0"
201+
202+ # Add composer bin to PATH
203+ echo "$HOME/.composer/vendor/bin" >> $GITHUB_PATH
204+
205+ # Verify installation and show available standards
206+ phpcs -i
207+
208+ # Verify VIP standards are available
209+ phpcs -i | grep -i vip || echo "VIP standards not found, checking installation..."
210+
211+ - name: Create VIP-specific PHPCS configuration
212+ run: |
213+ cat > phpcs-vip.xml << 'EOF'
214+ <?xml version="1.0"?>
215+ <ruleset name="WordPress VIP Go Coding Standards">
216+ <description>WordPress VIP Go coding standards for enterprise-level WordPress development</description>
217+
218+ <!-- Files to check -->
219+ <file>.</file>
220+
221+ <!-- Exclude patterns -->
222+ <exclude-pattern>*/vendor/*</exclude-pattern>
223+ <exclude-pattern>*/node_modules/*</exclude-pattern>
224+ <exclude-pattern>*/tests/*</exclude-pattern>
225+ <exclude-pattern>*/assets/*</exclude-pattern>
226+ <exclude-pattern>*/languages/*</exclude-pattern>
227+ <exclude-pattern>*/.git/*</exclude-pattern>
228+ <exclude-pattern>*/.github/*</exclude-pattern>
229+ <exclude-pattern>*.js</exclude-pattern>
230+ <exclude-pattern>*.css</exclude-pattern>
231+
232+ <!-- Use WordPress VIP Go coding standards -->
233+ <rule ref="WordPress-VIP-Go">
234+ <!-- Allow short array syntax [] instead of array() -->
235+ <exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
236+
237+ <!-- Allow longer lines for readability in some cases -->
238+ <exclude name="Generic.Files.LineLength.TooLong"/>
239+
240+ <!-- Exclude JS-related sniffs to avoid deprecation warnings -->
241+ <exclude name="WordPressVIPMinimum.JS"/>
242+ </rule>
243+
244+ <!-- Add specific WordPressVIPMinimum rules (non-JS) -->
245+ <rule ref="WordPressVIPMinimum.Security"/>
246+ <rule ref="WordPressVIPMinimum.Performance"/>
247+ <rule ref="WordPressVIPMinimum.UserExperience"/>
248+ <rule ref="WordPressVIPMinimum.Functions"/>
249+ <rule ref="WordPressVIPMinimum.Variables"/>
250+ <rule ref="WordPressVIPMinimum.Files"/>
251+ <rule ref="WordPressVIPMinimum.Hooks"/>
252+
253+ <!-- WordPress internationalization with plugin text domain -->
254+ <rule ref="WordPress.WP.I18n">
255+ <properties>
256+ <property name="text_domain" type="array">
257+ <element value="optimizations-ace-mc"/>
258+ </property>
259+ </properties>
260+ </rule>
261+
262+ <!-- Only scan PHP files -->
263+ <arg name="extensions" value="php"/>
264+
265+ <!-- Show progress -->
266+ <arg value="p"/>
267+
268+ <!-- Show sniff codes in all reports -->
269+ <arg value="s"/>
270+
271+ <!-- Use colors in output -->
272+ <arg name="colors"/>
273+
274+ <!-- Set report width for better readability -->
275+ <arg name="report-width" value="120"/>
276+ </ruleset>
277+ EOF
278+
279+ - name: Run WordPress VIP PHPCS
280+ run: |
281+ echo "🚀 Running WordPress VIP Go Coding Standards scan..."
282+ echo "📋 This scan focuses on VIP-specific requirements including:"
283+ echo " • File system operation restrictions"
284+ echo " • Performance and caching best practices"
285+ echo " • Security vulnerabilities specific to VIP platform"
286+ echo " • User experience guidelines for enterprise WordPress"
287+ echo " • Uncached function usage patterns"
288+ echo ""
289+ echo "📦 Using standards: WordPress-VIP-Go, WordPressVIPMinimum"
290+ echo "🎯 Scanning PHP files only (excluding JS/CSS to avoid deprecation warnings)"
291+ echo ""
292+
293+ # Run VIP-specific PHPCS scan using our custom configuration
294+ # Only scan PHP files to avoid JS/CSS deprecation warnings
295+ phpcs --standard=phpcs-vip.xml --extensions=php . || {
296+ echo ""
297+ echo "⚠️ WordPress VIP coding standards issues found."
298+ echo "💡 Note: These are VIP-specific recommendations for enterprise WordPress platforms."
299+ echo "🔧 Many of these may not apply to standard WordPress installations."
300+ echo "📖 For more info: https://docs.wpvip.com/technical-references/code-quality-and-best-practices/"
301+ echo ""
302+ exit 0
303+ }
304+
305+ echo "✅ WordPress VIP coding standards check completed successfully!"
306+
307+ - name: Create issue on VIP PHPCS failure
308+ if: ${{ failure() }}
309+ uses: JasonEtco/create-an-issue@v2
310+ env:
311+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
312+ PHP_VERSION: ${{ matrix.php-version }}
313+ RUN_ID: ${{ github.run_id }}
314+ WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
315+ with:
316+ filename: .github/ISSUE_TEMPLATE/vip-phpcs-failure.md
317+ update_existing: false
318+
167319 phpmd:
168320 name: PHPMD Code Quality Check (PHP ${{ matrix.php-version }})
169321 runs-on: ubuntu-latest
0 commit comments