Skip to content

Latest commit

 

History

History
120 lines (108 loc) · 4.67 KB

File metadata and controls

120 lines (108 loc) · 4.67 KB

PHP Quality Checks

A comprehensive PHP quality assurance workflow supporting static analysis, coding standards validation, and testing with coverage reporting across multiple PHP versions.

Features

  • PHPStan static analysis: Configurable levels (1-9) with intelligent configuration detection
  • PHP CodeSniffer: Support for Magento2, PSR12, and PSR2 coding standards
  • PHPUnit testing: Full test suite execution with coverage threshold enforcement
  • Multi-PHP support: Compatible with PHP 8.1, 8.2, and 8.3
  • Smart caching: Optimized Composer and analysis result caching
  • Parallel execution: Concurrent quality checks for maximum efficiency
  • Flexible configuration: Skip individual checks and customize tool behavior

Inputs

Name Required Type Default Description
PHP Configuration
php-version string PHP version to use (8.1, 8.2, 8.3)
memory-limit string 512M PHP memory limit for analysis tools
PHPStan Configuration
phpstan-level string 6 PHPStan analysis level (1-9)
skip-phpstan boolean false Skip PHPStan static analysis
Code Style Configuration
coding-standard string Magento2 Coding standard (Magento2, PSR12, PSR2)
skip-phpcs boolean false Skip PHP CodeSniffer checks
use-custom-config boolean false Use project config files (phpstan.neon, phpcs.xml) directly instead of composer scripts. See below.
Testing Configuration
coverage-threshold string 80 Code coverage threshold percentage (0-100)
skip-tests boolean false Skip PHP unit testing
Composer Configuration
composer-args string Additional composer install arguments
Service Configuration
mariadb-image string mariadb MariaDB Docker image name, combined with mariadb-version as the tag.
mariadb-version string 11.4 MariaDB Docker image tag.
rabbitmq-image string rabbitmq RabbitMQ Docker image name, combined with rabbitmq-version as the tag.
rabbitmq-version string 4.1-management RabbitMQ Docker image tag.
opensearch-image string opensearchproject/opensearch OpenSearch Docker image name, combined with opensearch-version as the tag.
opensearch-version string 2 OpenSearch Docker image tag.
Advanced Configuration
debug boolean false Enable verbose logging and debug output

Example Usage

Basic Quality Checks:

jobs:
  quality-check:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.2"
      phpstan-level: "7"

Magento 2 Project with Custom Standards:

jobs:
  magento-quality:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.1"
      coding-standard: "Magento2"
      phpstan-level: "6"
      coverage-threshold: "75"
      memory-limit: "1G"
      debug: true

Skip Specific Checks:

jobs:
  custom-checks:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.3"
      skip-phpcs: true
      skip-tests: true
      phpstan-level: "9"

Custom Service Images (e.g., OpenSearch with plugins):

jobs:
  magento-quality:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.4"
      opensearch-image: "aligent/bitbucket-opensearch"
      opensearch-version: "3.1.0"

Magento project with pre-commit hook scripts (use-custom-config):

Some projects have composer scripts (check-style, phpstan) designed for local pre-commit hooks that use git diff --cached to scan only staged files. These scripts scan nothing in CI because there are no staged files. Setting use-custom-config: true skips composer script detection and uses project config files (phpstan.neon, phpcs.xml) or vendor binaries with the configured standard directly.

jobs:
  quality-checks:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.3"
      coding-standard: "Magento2"
      skip-tests: true
      skip-composer-validate: true
      use-custom-config: true
    secrets:
      composer-auth: ${{ secrets.COMPOSER_AUTH }}

PSR Standards with High Coverage:

jobs:
  strict-quality:
    uses: aligent/workflows/.github/workflows/php-quality-checks.yml@main
    with:
      php-version: "8.2"
      coding-standard: "PSR12"
      phpstan-level: "8"
      coverage-threshold: "90"
      composer-args: "--no-dev"