12

I have been using a GitHub Actions workflow for a while now:

name: Laravel

on: [push]

jobs:
  laravel-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: |
        rm -rf vendor
        composer install
    - name: Generate key
      run: php artisan key:generate
    - name: Link Storage
      run: php artisan storage:link
    - 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 --stop-on-failure

It worked until 8.0 came out, then composer exploded with a bunch of errors that this and that package, which I update regularly, are not compatible with 8.0.

Anywho, I need to set this to use 7.4 for now.

I understand the:

with:
  php-version: '7.4'

and I know I can use a matrix, but where am I calling the whole "use this php version" with in this script to make the tests run against 7.4?

1

1 Answer 1

20

Use the setup-php action:

name: Laravel

on: [push]

jobs:
  laravel-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1    
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: 7.4
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    [...]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.