PHP CI #1551
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
# For details of what checks are run for PRs please refer below | |
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | |
name: PHP CI | |
on: | |
push: | |
branches: [ "main", "master", "next" ] | |
tags: [ "v*" ] # have tools scan this stable version | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
# schedule dayly tests, since dependencies are not intended to be locked | |
# this means: at 23:42 every day | |
- cron: '42 23 * * *' | |
concurrency: | |
group: '${{ github.workflow }}-${{ github.ref }}' | |
cancel-in-progress: true | |
env: | |
PHP_VERSION_LATEST: "8.3" | |
PHP_PROJECT_EXT: dom,json,libxml,simplexml # via `composer info -pt` | |
REPORTS_DIR: CI_reports | |
TESTS_REPORTS_ARTIFACT: tests-reports | |
TYPES_REPORTS_ARTIFACT: types-reports | |
jobs: | |
composer-validate: | |
name: Composer Validate | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: none | |
- name: Validate composer.json and composer.lock | |
run: composer validate --no-interaction | |
phpunit: | |
name: PHPUnit (${{ matrix.os}}, ${{ matrix.php }}, ${{ matrix.dependencies }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ] | |
php: | |
- "8.3" # highest supported | |
- "8.2" | |
- "8.1" # lowest supported | |
dependencies: [ "lowest", "highest" ] | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: dir setup | |
run: mkdir ${{ env.REPORTS_DIR }} | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: xdebug | |
- name: Get composer cache directory | |
id: composer-cache | |
shell: bash | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.*', 'tools/phpunit/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependencies }}- | |
composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}- | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install PHPUnit | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/phpunit | |
- name: Install lowest dependencies | |
if: ${{ matrix.dependencies == 'lowest' }} | |
run: | | |
composer remove --dev 'roave/security-advisories' | |
composer update --prefer-dist --no-interaction --no-progress --prefer-lowest | |
- name: Install highest dependencies | |
if: ${{ matrix.dependencies != 'lowest' }} | |
run: composer update --prefer-dist --no-interaction --no-progress | |
- name: Run PHPUnit tests | |
run: > | |
php | |
-d zend.assertions=1 -d assert.exception=1 | |
-d display_errors=On -d error_reporting=-1 -d log_errors_max_len=0 | |
-d memory_limit=-1 | |
-d xdebug.mode=coverage | |
-d pcov.enabled=1 -d pcov.directory=src | |
tools/phpunit/vendor/phpunit/phpunit/phpunit | |
--no-progress | |
--log-junit='${{ env.REPORTS_DIR }}/phpunit/tests/${{ matrix.os }}_php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml' | |
--coverage-clover='${{ env.REPORTS_DIR }}/phpunit/coverage/${{ matrix.os}}_php${{ matrix.php }}_${{ matrix.dependencies }}.clover.xml' | |
- name: Artifact reports | |
if: ${{ ! cancelled() }} | |
# see https://github.com/actions/upload-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: '${{ env.TESTS_REPORTS_ARTIFACT }}_${{ matrix.os}}_php${{ matrix.php }}_${{ matrix.dependencies }}' | |
path: ${{ env.REPORTS_DIR }} | |
if-no-files-found: error | |
report-coverage: | |
name: Publish test coverage | |
needs: [ "phpunit" ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: fetch test artifacts | |
# see https://github.com/actions/download-artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: '${{ env.TESTS_REPORTS_ARTIFACT }}_*' | |
merge-multiple: true | |
path: ${{ env.REPORTS_DIR }} | |
- name: Run codacy-coverage-reporter | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
## see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets | |
if: ${{ env.CODACY_PROJECT_TOKEN != '' }} | |
# see https://github.com/codacy/codacy-coverage-reporter-action | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ env.CODACY_PROJECT_TOKEN }} | |
coverage-reports: ${{ env.REPORTS_DIR }}/phpunit/coverage/*.clover.xml | |
code-checker: | |
name: Code Analysis (${{ matrix.php }}, ${{ matrix.dependencies }}) | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- # highest supported | |
php: "8.3" | |
dependencies: "highest" | |
- # lowest supported | |
php: "8.1" | |
dependencies: "lowest" | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.*', 'tools/psalm/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependencies }}- | |
composer-${{ github.job }}-${{ runner.os }}-${{ matrix.php }}- | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install psalm | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/psalm | |
- name: Install lowest dependencies | |
if: ${{ matrix.dependencies == 'lowest' }} | |
run: | | |
composer remove --dev 'roave/security-advisories' | |
composer config platform.php ${{ matrix.php }} | |
composer update --prefer-dist --no-interaction --no-progress --prefer-lowest | |
- name: Install highest dependencies | |
if: ${{ matrix.dependencies != 'lowest' }} | |
run: | | |
composer config platform.php ${{ matrix.php }} | |
composer update --prefer-dist --no-interaction --no-progress | |
- name: Run Psalm tests | |
run: > | |
php tools/psalm/vendor/vimeo/psalm/psalm | |
--no-diff | |
--no-cache | |
--long-progress | |
--output-format=github | |
--report=${{ env.REPORTS_DIR }}/psalm/php${{ matrix.php }}_${{ matrix.dependencies }}.junit.xml | |
--stats | |
--shepherd | |
- name: Artifact reports | |
if: ${{ ! cancelled() }} | |
# see https://github.com/actions/upload-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: '${{ env.TYPES_REPORTS_ARTIFACT }}_php${{ matrix.php }}_${{ matrix.dependencies }}' | |
path: ${{ env.REPORTS_DIR }} | |
if-no-files-found: error | |
composer-unused: | |
name: ComposerUnused | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-unused/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install composer-unused | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/composer-unused | |
- name: Install dependencies | |
run: composer install --no-dev --prefer-dist --no-interaction --no-progress | |
- name: Run composer-unused tests | |
run: > | |
php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused | |
--no-progress | |
--no-interaction | |
--excludeDir=tools | |
composer-require-checker: | |
name: ComposerRequireChecker | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-require-checker/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install composer-require-checker | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/composer-require-checker | |
- name: Install dependencies | |
run: composer install --no-dev --prefer-dist --no-interaction --no-progress | |
- name: Run composer-require-checker tests | |
run: > | |
php tools/composer-require-checker/vendor/maglnet/composer-require-checker/bin/composer-require-checker | |
--no-interaction | |
coding-standards: | |
name: Coding Standards | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
extensions: ${{ env.PHP_PROJECT_EXT }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/php-cs-fixer/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install PHP-CS-Fixer | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/php-cs-fixer | |
- name: Run PHP-CS-Fixer tests | |
run: > | |
php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer | |
fix | |
--dry-run | |
--diff | |
--using-cache=no | |
--show-progress=dots | |
--no-interaction | |
composer-normalize: | |
name: Composer normalize | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/composer-normalize/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install composer-normalize | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/composer-normalize | |
- name: Run composer-normalize tests | |
run: > | |
composer -d tools/composer-normalize | |
normalize | |
--dry-run | |
--diff | |
--no-check-lock | |
--no-update-lock | |
--no-interaction | |
$PWD/composer.json | |
phpmd: | |
name: PHP Mess Detector | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/phpmd/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install phpmd | |
run: composer install --prefer-dist --no-interaction --no-progress | |
working-directory: tools/phpmd | |
- name: Run phpmd tests | |
run: > | |
php tools/phpmd/vendor/phpmd/phpmd/src/bin/phpmd | |
src | |
github | |
phpmd.xml | |
examples: | |
name: Examples | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
# see https://github.com/shivammathur/setup-php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_LATEST }} | |
tools: composer:v2 | |
coverage: none | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
if: ${{ steps.composer-cache.outputs.dir }} | |
# see https://github.com/actions/cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: composer-${{ github.job }}-${{ runner.os }}-${{ hashFiles('composer.*', 'tools/phpmd/composer.*') }} | |
restore-keys: | | |
composer-${{ github.job }}-${{ runner.os }}- | |
- name: Install dependencies | |
run: composer install --no-dev --prefer-dist --no-interaction --no-progress | |
- name: run all examples | |
run: > | |
find examples -type f -name '*.php' -print0 | |
| xargs -0 -L1 -t | |
php -f |