Add PHP 8.3 to CI workflow and optimize pint execution #4
Workflow file for this run
This file contains 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: Continuous Integration Workflow | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-version: ['8.2', '8.3'] # Define the PHP versions to run | |
include: | |
- php-version: '8.3' # Mark 8.3 as the latest | |
latest: true | |
steps: | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- name: Cache Composer dependencies | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php-${{ matrix.php-version }} | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Run pint (code formatting) | |
if: matrix.latest == true # Run pint only on the "latest" version | |
run: composer run pint | |
continue-on-error: true | |
- name: Commit and push pint fixes (if any) | |
if: failure() && matrix.latest == true # Commit pint fixes only for the latest PHP version | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "[email protected]" | |
git add . | |
git commit -m "Apply Pint fixes" | |
git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref }} | |
- name: Run PHPStan (static analysis) | |
run: composer run stan | |
- name: Run coverage-min (with 80% minimum coverage requirement) | |
run: composer run coverage-min |