Skip to content

GitHub pipeline, PHP 8.4 support #16

GitHub pipeline, PHP 8.4 support

GitHub pipeline, PHP 8.4 support #16

Workflow file for this run

name: PHP Tests
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "**" ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.4', '8.3', '8.2', '8.1']
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, json, xdebug, curl
coverage: pcov
tools: composer:v2
- name: Adjust composer dependencies for older PHP versions
run: php scripts/adjust-deps-for-older-php-versions.php
- name: Cache Composer packages
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: Run test suites for older PHP versions
if: matrix.php-version != '8.4'
run: composer run-script test-all
- name: Run test suites with coverage for latest PHP version
if: matrix.php-version == '8.4'
run: |
mkdir -p var/coverage
php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text --coverage-clover=var/coverage/clover.xml
- name: Extract Coverage and update GitHub status
if: matrix.php-version == '8.4' && success()
id: coverage
run: |
COVERAGE=$(php scripts/get-coverage.php var/coverage/clover.xml)
STATUS=$(if [ "$COVERAGE" -ge "95" ]; then echo "success"; else echo "failure"; fi)
echo "COVERAGE=${COVERAGE}" >> $GITHUB_ENV
HEADER_AUTH="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
HEADER_ACCEPT="Accept: application/vnd.github.v3+json"
URL="https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}"
PAYLOAD='{
"state": "success",
"context": "Code Coverage",
"description": "Coverage: ${{ env.COVERAGE }}%",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
echo "Sending"
echo $URL
echo $PAYLOAD
echo $COVERAGE
curl -X POST -H $HEADER_AUTH -H $HEADER_ACCEPT $URL -d '$PAYLOAD'