draw134
draw134

Reputation: 1187

Github actions for specific php version error

I have a laravel project and i am trying to use using github actions. I already set my php version to 7.3 and I was always getting this kind of error.

Run composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for pelago/emogrifier v2.2.0 -> satisfiable by pelago/emogrifier[v2.2.0].
    - pelago/emogrifier v2.2.0 requires php ^5.5.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 -> your PHP version (7.4.3) does not satisfy that requirement.
  Problem 2
    - pelago/emogrifier v2.2.0 requires php ^5.5.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 -> your PHP version (7.4.3) does not satisfy that requirement.
    - snowfire/beautymail dev-master requires pelago/emogrifier 2.2.0 -> satisfiable by pelago/emogrifier[v2.2.0].
    - Installation request for snowfire/beautymail dev-master -> satisfiable by snowfire/beautymail[dev-master].

Still the test uses the latest php version which is 7.4

But in my .yaml file I followed php config for actions like

name: Laravel

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  laravel-tests:

    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
      with:
        php-version: '7.3'
        tools: composer, phpunit'
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: composer install
    - name: Generate key
      run: php artisan key:generate
    - name: Directory Permissions
      run: chmod -R 777 storage bootstrap/cache
    - name: Create Database
      run: |
        mkdir -p database
        touch database/database.sqlite
    - name: Execute tests (Unit and Feature tests) via PHPUnit
      env:
        DB_CONNECTION: sqlite
        DB_DATABASE: database/database.sqlite
      run: vendor/bin/phpunit

Any thoughts?

Upvotes: 1

Views: 1234

Answers (1)

draw134
draw134

Reputation: 1187

I figured it out by adding this lines of code in the .yaml file

runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ubuntu-latest] // you can add multiple operating systems
        php-versions: ['7.3'] // you can add multiple versions
    name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

    steps:
    - uses: actions/checkout@v2
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: ${{ matrix.php-versions }}
        extensions: intl #optional
        ini-values: "post_max_size=256M" #optional
    - name: Check PHP Version
      run: php

Upvotes: 1

Related Questions