psalm-github-actions icon indicating copy to clipboard operation
psalm-github-actions copied to clipboard

Bump to PHP 8.3

Open dshafik opened this issue 1 year ago • 2 comments

We can no longer use this image as our application requires 8.3 and composer install fails.

composer install --no-scripts --no-progress --no-dev 
  Installing dependencies from lock file
  Verifying lock file contents can be installed on current platform.
  Your lock file does not contain a compatible set of packages. Please run composer update.
  
    Problem 1
      - Root composer.json requires php ^8.3 but your php version (8.2.13) does not satisfy that requirement.
  
  Error: Your lock file does not contain a compatible set of packages. Please run composer update.
  
    Problem 1
      - Root composer.json requires php ^8.3 but your php version (8.2.13) does not satisfy that requirement.

I'm happy to open a PR for this, but realistically you might need to start building multiple packages to support each of the different (minor) versions of PHP supported by a given version of Psalm.

dshafik avatar Mar 15 '24 00:03 dshafik

Interesting, I just ran into the same issue because we're trying to bump to PHP 8.2 and the container only has PHP 8.1.2 installed. I'm guessing that's based on the jobs.build.runs-on property of the Github workflow, since we're running on ubuntu-latest and the version matches: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#php-tools

Out of curiosity, which runner image are you using that has PHP 8.2 support? Looks like the latest Win/Mac runner releases have PHP8.3, but Ubuntu is lagging the pack with 8.1.

EDIT: Did some more digging on this, and it was a decision by GitHub to remove non-Canonical repositories from their Ubuntu 22.04 runner, which is why the image is capped at PHP 8.1.2. Source thread here.

Looks like the "official" workaround for this is to use shivammathur/setup-php as an early workflow step to activate the PPA:Ondrej repo & install the requested version(s) of PHP from that. Fortunately, that process went smoothly, and the increased CI workflow times aren't an issue for us.

braindawg avatar Mar 28 '24 19:03 braindawg

Psalm already has built-in support for PHP versions that differ from the installed environment, so my previous comment is mostly moot.

Seems to me that the best way to provide support for multiple versions of PHP is to expose Psalm's --php-version CLI option as a workflow param. Then we could use the container to check against all supported PHP versions:

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        php-versions: ['8.1', '8.2', '8.3']
    steps:
    - name: Psalm – Static Analysis for PHP
      uses: docker://ghcr.io/psalm/psalm-github-actions:5.15.0
      with:
        composer_ignore_platform_reqs: true
        composer_require_dev: true
        php-version: ${{ matrix.php-versions }}

braindawg avatar Apr 16 '24 18:04 braindawg