【问题标题】:Github actions for specific php version error针对特定 php 版本错误的 Github 操作
【发布时间】:2020-07-07 08:02:10
【问题描述】:

我有一个 laravel 项目,我正在尝试使用 github 操作。我已经将我的 php 版本设置为 7.3,但我总是遇到这种错误。

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].

测试仍然使用最新的php版本7.4

但是在我的.yaml 文件中,我遵循了 php 配置的操作,例如

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

有什么想法吗?

【问题讨论】:

    标签: php laravel unit-testing github github-actions


    【解决方案1】:

    我通过在.yaml文件中添加这行代码来解决这个问题

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-02
      • 2020-04-09
      • 1970-01-01
      • 2021-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-19
      相关资源
      最近更新 更多