Enhance CI/CD workflow with code quality checks and PHPCBF integration

This commit is contained in:
2025-04-21 04:02:27 +01:00
parent 497c44c3c6
commit 5cd2a7d374
6 changed files with 152 additions and 12 deletions

79
.github/workflows/code-quality.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
name: Code Quality - Run automated code quality checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
phpcs:
name: PHP CodeSniffer
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
clean: 'true'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, zip
tools: composer:v2, phpcs
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPCS
run: composer run phpcs
continue-on-error: true
- name: Run PHPCBF (report only)
run: |
echo "Running PHPCBF in dry-run mode to show what would be fixed"
composer run phpcbf -- --dry-run
continue-on-error: true
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
codacy:
name: Codacy Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust the below patterns based on your project structure
gh-code-scanning-compat: true
max-allowed-issues: 2147483647
continue-on-error: true
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
continue-on-error: true

View File

@@ -63,5 +63,12 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress
# - name: Run PHPCS
# run: ./vendor/bin/phpcs --standard=WordPress ./includes ./admin ./wp-plugin-starter-template.php
- name: Run PHPCS
run: composer run phpcs
continue-on-error: true
- name: Run PHPCBF (report only)
run: |
echo "Running PHPCBF in dry-run mode to show what would be fixed"
composer run phpcbf -- --dry-run
continue-on-error: true