Skip to content

Merge pull request #6 from ray-di/v1-no-jit #68

Merge pull request #6 from ray-di/v1-no-jit

Merge pull request #6 from ray-di/v1-no-jit #68

# GitHub Actions workflow specifically designed for running PHPUnit tests
# This workflow is optimized to install only the necessary dependencies for PHPUnit
# and explicitly avoids installing development tools to prevent latest PHP compatibility issues
name: Continuous Integration
on:
push:
paths-ignore:
- '**.md' # Skip workflow on documentation changes only
pull_request:
workflow_dispatch: # Enable manual trigger
workflow_call: # Enable calling from other workflows
inputs:
old_stable:
description: Old stable php version matrix
required: true
type: string
current_stable:
description: Current stable php version
required: true
type: string
script:
description: Additional scripts to run
required: false
type: string
# Environment configuration
# Key flags:
# --no-plugins: Disables composer-bin-plugin to prevent vendor-bin installation
# This avoids installing tools like psalm that might have compatibility issues with PHP 8.4
env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist --no-plugins"
COMPOSER_UPDATE_FLAGS: ""
jobs:
phpunit:
name: PHPUnit
runs-on: ${{ matrix.os }}
strategy:
# Don't cancel other matrix jobs if one fails
fail-fast: false
matrix:
php-version: ${{ fromJson(inputs.old_stable) }}
dependencies: [highest, lowest]
os: [ubuntu-latest]
experimental: [false]
include:
- php-version: ${{ inputs.current_stable }}
os: windows-latest
dependencies: highest
experimental: false
- php-version: ${{ inputs.current_stable }}
os: ubuntu-latest
dependencies: highest
experimental: false
# Test current stable with lowest dependencies
- php-version: ${{ inputs.current_stable }}
os: ubuntu-latest
dependencies: lowest
experimental: false
continue-on-error: ${{ matrix.experimental }}
steps:
# Fetch repository content
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for accurate testing
# Configure PHP environment
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
ini-values: zend.assertions=1, opcache.jit_buffer_size=0, opcache.jit=0
extensions: pdo, pdo_mysql, pdo_sqlite # Install additional extensions
tools: none # Don't install additional tools
# Setup Composer cache for faster dependency installation
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php${{ matrix.php-version }}-composer-
${{ runner.os }}-composer-
# Ensure platform requirements are properly set
- name: Set platform requirements
shell: bash
run: |
composer config platform.php ${{ matrix.php-version }}
# Configure dependency installation based on test matrix
- name: Handle lowest dependencies update
if: matrix.dependencies == 'lowest'
shell: bash
run: echo COMPOSER_UPDATE_FLAGS="$COMPOSER_UPDATE_FLAGS --prefer-lowest" >> $GITHUB_ENV
- name: Remove platform config for dependency resolution
if: matrix.dependencies == 'highest'
shell: bash
run: composer config platform --unset
# Install dependencies using configured flags
- name: Update dependencies
shell: bash
run: |
# Validate composer.json before proceeding
composer validate --no-check-all --strict
composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}
# Run PHPUnit tests and generate coverage report
- name: Run test suite
shell: bash
run: vendor/bin/phpunit --coverage-clover=coverage.xml
env:
XDEBUG_MODE: coverage
# Upload coverage data to Codecov
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # Don't fail if coverage upload fails
# Execute additional custom scripts if provided
- name: Run additional script
if: inputs.script != ''
shell: bash
run: php ${{ inputs.script }}