Update ci.yml #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| php-lint-and-standards: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4', '8.2'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| tools: composer | |
| coverage: none | |
| # Composer 2 blocca i plugin: abilitiamo l’installer PHPCS | |
| - name: Allow Composer plugin (PHPCS installer) | |
| run: composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true | |
| # Installa PHPCS + WPCS + PHPCSExtra + PHPCSUtils e registra TUTTI i paths | |
| - name: Install PHPCS + WPCS (+ Extra + Utils) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| composer global require --no-interaction --no-progress \ | |
| squizlabs/php_codesniffer:^3.13 \ | |
| wp-coding-standards/wpcs:^3.0 \ | |
| phpcsstandards/phpcsextra:^1.4 \ | |
| phpcsstandards/phpcsutils:^1.1 | |
| COMPOSER_HOME="$(composer global config home --absolute)" | |
| PHPCS="${COMPOSER_HOME}/vendor/bin/phpcs" | |
| WPCS_PATH="${COMPOSER_HOME}/vendor/wp-coding-standards/wpcs" | |
| EXTRA_PATH="${COMPOSER_HOME}/vendor/phpcsstandards/phpcsextra" | |
| UTILS_PATH="${COMPOSER_HOME}/vendor/phpcsstandards/phpcsutils" | |
| # Pulisci eventuale config “sporca” del runner | |
| "${PHPCS}" --config-delete installed_paths || true | |
| # Registra tutti gli standard richiesti da WPCS 3.x | |
| "${PHPCS}" --config-set installed_paths "${WPCS_PATH},${EXTRA_PATH},${UTILS_PATH}" | |
| - name: Verify PHPCS standards (installed) | |
| shell: bash | |
| run: | | |
| COMPOSER_HOME="$(composer global config home --absolute)" | |
| PHPCS="${COMPOSER_HOME}/vendor/bin/phpcs" | |
| "${PHPCS}" -i | |
| "${PHPCS}" --version | |
| - name: PHP syntax lint (recursive) | |
| run: | | |
| find . -type f -name "*.php" -not -path "./vendor/*" -print0 | xargs -0 -n1 -P4 php -l | |
| - name: PHPCBF (auto-fix) | |
| shell: bash | |
| run: | | |
| COMPOSER_HOME="$(composer global config home --absolute)" | |
| PHPCBF="${COMPOSER_HOME}/vendor/bin/phpcbf" | |
| "${PHPCBF}" --standard=phpcs.xml.dist \ | |
| --ignore=vendor/*,node_modules/* \ | |
| --extensions=php \ | |
| . | |
| - name: PHPCS (project ruleset) | |
| shell: bash | |
| run: | | |
| COMPOSER_HOME="$(composer global config home --absolute)" | |
| PHPCS="${COMPOSER_HOME}/vendor/bin/phpcs" | |
| "${PHPCS}" \ | |
| --standard=phpcs.xml.dist \ | |
| --ignore=vendor/*,node_modules/* \ | |
| --extensions=php \ | |
| . |