Skip to content

chore(ci): Bump actions/cache from 4 to 5 (#9) #14

chore(ci): Bump actions/cache from 4 to 5 (#9)

chore(ci): Bump actions/cache from 4 to 5 (#9) #14

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ──────────────────────────────────────────────────────────────────
# Static Analysis — PHPStan
# ──────────────────────────────────────────────────────────────────
phpstan:
name: "PHPStan (level 8)"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-php8.2-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-${{ runner.os }}-php8.2-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Run PHPStan
run: vendor/bin/phpstan analyse --error-format=github
# ──────────────────────────────────────────────────────────────────
# Test Matrix — PHP 8.2, 8.3, 8.4 × latest deps / lowest deps
# ──────────────────────────────────────────────────────────────────
tests:
name: "PHPUnit (${{ matrix.php }}, ${{ matrix.deps }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ "8.2", "8.3", "8.4" ]
deps: [ "latest", "lowest" ]
exclude:
# lowest deps with bleeding-edge PHP is noisy — skip it
- php: "8.4"
deps: "lowest"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pcntl, posix
coverage: ${{ matrix.php == '8.3' && matrix.deps == 'latest' && 'xdebug' || 'none' }}
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.deps }}-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-${{ runner.os }}-php${{ matrix.php }}-
- name: Install latest dependencies
if: matrix.deps == 'latest'
run: composer install --no-interaction --prefer-dist --no-progress
- name: Install lowest dependencies
if: matrix.deps == 'lowest'
run: composer update --no-interaction --prefer-dist --no-progress --prefer-lowest
- name: Run tests (with coverage)
if: matrix.php == '8.3' && matrix.deps == 'latest'
run: vendor/bin/phpunit --coverage-clover=build/coverage/clover.xml
- name: Run tests (no coverage)
if: matrix.php != '8.3' || matrix.deps != 'latest'
run: vendor/bin/phpunit --no-coverage
- name: Upload coverage to Codecov
if: matrix.php == '8.3' && matrix.deps == 'latest'
uses: codecov/codecov-action@v6
with:
files: build/coverage/clover.xml
fail_ci_if_error: false
# ──────────────────────────────────────────────────────────────────
# Code Style — PHP CS Fixer (future gate, currently informational)
# ──────────────────────────────────────────────────────────────────
codestyle:
name: "Code Style (dry-run)"
runs-on: ubuntu-latest
continue-on-error: true # informational until .php-cs-fixer.php is added
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
coverage: none
tools: composer:v2, cs2pr
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Check if php-cs-fixer is installed
id: check-fixer
run: |
if [ -f vendor/bin/php-cs-fixer ]; then
echo "installed=true" >> $GITHUB_OUTPUT
else
echo "installed=false" >> $GITHUB_OUTPUT
fi
- name: Run PHP CS Fixer (dry-run)
if: steps.check-fixer.outputs.installed == 'true'
run: vendor/bin/php-cs-fixer fix --dry-run --diff --format=checkstyle | cs2pr
# ──────────────────────────────────────────────────────────────────
# Security Audit
# ──────────────────────────────────────────────────────────────────
security:
name: "Security Audit"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Composer audit
run: composer audit --no-interaction