shivammathur / setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
https://setup-php.com
MIT License
2.9k stars 337 forks source link

setup-php for php8.0 installs phpunit 10.0 #694

Closed mwinkens closed 1 year ago

mwinkens commented 1 year ago

Describe the bug

PHPUnit 10.0.0 by Sebastian Bergmann and contributors.

This version of PHPUnit requires PHP >= 8.1.
You are using PHP 8.0.27 (/usr/bin/php8.0).
Error: Process completed with exit code 1.

GitHub Actions job part

      - name: Install PHP ${{ matrix.php-version }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          ini-file: myapp/php.ini
          tools: phpunit, phpcs, phpcbf

Version

Runners

Operating systems

PHP versions

8.0

To Reproduce

Expected behavior

Not installing incompatible versions

Screenshots/Logs

Additional context

Are you willing to submit a PR?

Workaround:

specify the phpunit version as described in the Tools Support:

      - name: Install PHP ${{ matrix.php-version }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}
          ini-file: myapp/php.ini
          tools: phpunit:9.5, phpcs, phpcbf
shivammathur commented 1 year ago

tools input installs the latest version by default for a tool. Please specify the phpunit version that is correct for the php version while using it.

VincentLanglet commented 1 year ago

Hi @shivammathur, when using a matrix for php-version,

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
    steps:
      - uses: actions/checkout@v2

      - name: Setup PHP ${{ matrix.php-versions }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-versions }}
          tools: phpunit
          coverage: xdebug

it not easy to set specify which phpunit version to use:

There seems to be some logic for xdebug related to the php version https://github.com/shivammathur/setup-php/blob/baf9535ba58ae8ac3a7362d932ca85fc38621a5d/src/coverage.ts#L10-L11 Can't the same thing be done for phpunit ?

shivammathur commented 1 year ago

@VincentLanglet Yes, If someone contributes a PR for this, I will accept it.