Skip to content

Run PHP Tests and Code Quality Tools #378

Run PHP Tests and Code Quality Tools

Run PHP Tests and Code Quality Tools #378

Workflow file for this run

name: Run PHP Tests and Code Quality Tools
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Also run every day at midnight
- cron: '0 0 * * *'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
php: [8.3, 8.2, 8.1]
# prefer-lowest is causing unit tests to fail when php 7.2 is run against PHPunit 7.x,
# PHPUnit 8.x is the latest stable release that supports PHP 7.2 and that runs fine
# dependency-version: [prefer-lowest, prefer-stable]
dependency-version: [prefer-stable]
os: [ubuntu-20.04, ubuntu-22.04]
include:
- os: ubuntu-20.04
php: 8.1
- os: ubuntu-22.04
php: 8.1
- os: ubuntu-22.04
php: 8.2
#exclude:
#- os: ubuntu-20.04
# php: 7.3
name: PHP-${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: pcre.jit=0, pcre.backtrack_limit=9999999, pcre.recursion_limit=9999999
coverage: xdebug
- name: PHP version
run: php -v
- name: Composer version
run: composer --version
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install Dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md
- name: Run PHPUnit Test Suite
run: vendor/bin/phpunit
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
- name: Run Rector
# Run rector for PHP 7.3+ but not 8.0
#if: matrix.php == '7.4'
run: vendor/bin/rector process src --dry-run
continue-on-error: true
- name: Run Psalm
# Run psalm for PHP 7.4 & 8.0 but not 7.2 & 7.3, psalm is currently blowing up with PHP 7.2 & 7.3
# if: matrix.php != '7.3'
run: vendor/bin/psalm
continue-on-error: true