GitHub Actions – Composer failing because of PHP Version constraint

  composer-php, github, github-actions, php, phpunit

I’m trying to get my unit-tests to run via GitHub Actions on a pull_request.

I can see the actions running when I update my PR but the PHP version doesn’t update when it tries to composer install my project.

Command: composer install --no-interaction --no-suggest --no-progress
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php ~7.3.0 but your PHP version (7.4.10) does not satisfy that requirement.

I’ve tried multiple different workflow files, and this was the one that gave me the most control, but it still seems to be running on php 7.4.

name: Run Tests

on:
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ubuntu-latest]
        php-versions: ['7.3']

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/[email protected]
      - uses: shivammathur/[email protected]
        with:
          php-version: ${{ matrix.php-versions }}
      - uses: php-actions/[email protected]
      - uses: php-actions/[email protected]

Finally, here is the snippet from my composer json that shows the constraint:

"require": {
    "php": "~7.3.0",
    "guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
    "phpunit/phpunit": "^8"
}

Source: Ask PHP

LEAVE A COMMENT