Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.3 to CI workflow and optimize pint execution #2

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 70 additions & 16 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,97 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['8.2', '8.3']
include:
- php-version: '8.3'
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: Validate composer.lock is up to date
run: composer validate --no-check-all --strict

- name: Get Composer Cache Directory
id: composer-cache-dir
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run pint (code formatting)
run: composer run pint
continue-on-error: true # Continue even if pint fails due to formatting issues
- name: Check code style with Pint
if: matrix.latest == true
run: composer run pint -- --test
continue-on-error: true

- name: Commit and push pint fixes (if any)
if: failure() # Only run this step if pint made changes (i.e., if pint fails)
- name: Apply Pint fixes
if: failure() && matrix.latest == true
run: |
composer run pint
git config --local user.name "GitHub Actions"
git config --local user.email "[email protected]"
git add .
git commit -m "Apply Pint fixes"
git commit -am "Apply Pint fixes" || echo "No changes to commit"
git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref }}

- name: Run PHPStan (static analysis)
run: composer run stan
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- run: composer install --prefer-dist --no-progress
- run: composer run stan
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Get Composer Cache Directory
id: composer-cache-dir
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run coverage-min (with 80% minimum coverage requirement)
run: composer run coverage-min
run: composer run coverage-min

- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage
Loading