mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-21 04:03:20 +02:00
Add friendsofphp/php-cs-fixer as a committed Composer dev dependency (src/vendor/, same model as PHPStan — no composer install on deploy). - .php-cs-fixer.dist.php: deliberately NARROW ruleset — no_unused_imports, ordered_imports, no_leading_import_slash, single_line_after_imports, blank_line_after_namespace, no_extra_blank_lines[use]. NO @PSR12 / indentation rules: the codebase is tab-indented legacy and a full reformat would be unreviewable. Indent forced to tabs, LF endings. Excludes vendor, the bundled Modules/tmdb/lib, tmp/, backups/. - Makefile: 'make cs' (dry-run, fails on diff — CI) and 'make cs-fix' (apply). - CI: new 'Code Style (PHP-CS-Fixer)' job running 'make cs' on PHP 8.3. - .gitignore: ignore .php-cs-fixer.cache.
131 lines
3.8 KiB
YAML
131 lines
3.8 KiB
YAML
name: CI
|
|
|
|
# Quality gate: runs on every push and pull request.
|
|
# Tests run via the committed PHAR (tools/.bin/phpunit.phar). Class loading uses
|
|
# the committed Composer PSR-4 autoloader (src/vendor/) first, with the legacy
|
|
# src/autoload.php scanner as an end-of-queue fallback. The deploy path ships
|
|
# vendor/ as-is and never runs `composer install`.
|
|
|
|
on:
|
|
push:
|
|
branches: ['**']
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
lint:
|
|
name: PHP Syntax Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.1'
|
|
coverage: none
|
|
|
|
- name: Check syntax
|
|
run: bash tools/php_syntax_check.sh
|
|
|
|
phpstan:
|
|
name: PHPStan (static analysis)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
# Matches phpVersion (80300) the analysis targets.
|
|
php-version: '8.3'
|
|
coverage: none
|
|
|
|
# Downloads the pinned PHPStan PHAR (no Composer) and analyses against the
|
|
# committed baseline — fails only on NEW issues introduced by the change.
|
|
- name: Run PHPStan
|
|
run: make phpstan
|
|
|
|
code-style:
|
|
name: Code Style (PHP-CS-Fixer)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.3'
|
|
coverage: none
|
|
|
|
# PHP-CS-Fixer ships via the committed src/vendor/ (Composer dev dep), like
|
|
# PHPStan — no download, no `composer install`. Narrow ruleset: import /
|
|
# namespace hygiene only (see .php-cs-fixer.dist.php). Dry-run fails on diff.
|
|
- name: Run PHP-CS-Fixer
|
|
run: make cs
|
|
|
|
composer-audit:
|
|
name: Composer Security Audit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.1'
|
|
coverage: none
|
|
tools: composer:v2
|
|
|
|
# Audits the committed install set (src/vendor/composer/installed.json)
|
|
# against the Packagist advisory database. Does NOT run `composer install`
|
|
# (vendor/ is committed and shipped) and does NOT use --locked
|
|
# (composer.lock is gitignored, never committed). A no-op while every
|
|
# dependency is path-mapped/vendored without metadata, but gates real
|
|
# installed packages the moment any are added.
|
|
- name: Composer audit
|
|
run: |
|
|
count=$(php -r '$f="src/vendor/composer/installed.json";$d=is_file($f)?json_decode(file_get_contents($f),true):[];echo is_array($d["packages"]??null)?count($d["packages"]):0;')
|
|
if [ "$count" -eq 0 ]; then
|
|
echo "No installed Composer packages — nothing to audit."
|
|
else
|
|
composer audit --no-interaction --working-dir=src
|
|
fi
|
|
|
|
test:
|
|
name: PHPUnit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.1'
|
|
coverage: pcov
|
|
|
|
- name: Run unit tests
|
|
run: php tools/.bin/phpunit.phar -c tests/phpunit.xml.dist
|
|
|
|
- name: Coverage report
|
|
run: |
|
|
php tools/.bin/phpunit.phar -c tests/phpunit.xml.dist \
|
|
--coverage-text \
|
|
--coverage-clover coverage.xml
|
|
continue-on-error: true
|
|
|
|
- name: Upload coverage artifact
|
|
if: always()
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: coverage
|
|
path: coverage.xml
|
|
if-no-files-found: ignore
|