【问题标题】:How to force a symfony version on github actions when testing a bundle测试捆绑包时如何在 github 操作上强制使用 symfony 版本
【发布时间】:2021-06-13 15:02:58
【问题描述】:

我正在尝试使用 github 操作在不同版本的 Symfony 上测试捆绑包。我尝试按照Best practices for reusable bundles

中的说明配置我的工作

这是我的工作:

name: Bundle test

on:
  push: ~
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ${{ matrix.operating-system }}
    strategy:
      matrix:
        operating-system: [ ubuntu-latest ] #, windows-latest ]
        php: [ '7.4', '8.0' ]
        symfony: ['4.4', '5.2', '5.3']
    name: On ${{ matrix.operating-system }} with PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}
    steps:
      - uses: actions/checkout@master

      - name: Validate composer.json
        run: composer validate --strict

      - name: Setup PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
        run: php -v

      - name: Export Symfony version ${{ matrix.symfony }}
        run: export SYMFONY_REQUIRE=${{ matrix.symfony }}

      - name: Install symfony/flex
        run: composer global require --no-progress --no-scripts --no-plugins symfony/flex

      - name: Composer update on php ${{ matrix.php }} and symfony ${{ matrix.symfony }}
        run: composer update --prefer-dist --no-progress

即使我用 symfony/flex 导出 Symfony 版本,composer 总是安装 Symfony 5.3(这是当前的稳定版本)

Composer update on php 7.4 and symfony 4.4
Run composer update --prefer-dist --no-progress
Loading composer repositories with package information
Updating dependencies
Lock file operations: 85 installs, 0 updates, 0 removals
 ... ... ... ...
  - Locking symfony/console (v5.3.0)

如果需要,这里是我的composer.json 文件的需求行:

{
    ...
    "require": {
        "php": "^7.4|^8.0",
        "symfony/security-bundle": "^4.4|^5.2|^5.3"
    },
    "require-dev": {
        "phpunit/phpunit": "9.*",
        "friendsofphp/php-cs-fixer": "^2.19",
        "nyholm/symfony-bundle-test": "^1.7"
    },
    ...
}

编辑:在我的本地开发计算机上,它运行良好,当我运行时:

export SYMFONY_REQUIRE=5.2
symfony composer global require --no-progress --no-scripts --no-plugins symfony/flex
symfony composer update --prefer-dist --no-progress

【问题讨论】:

    标签: php symfony testing github-actions


    【解决方案1】:

    看来export 命令不是环保的。

    最后,我删除了这些行:

      - name: Export Symfony version ${{ matrix.symfony }}
        run: export SYMFONY_REQUIRE=${{ matrix.symfony }}
    

    并更新了最后一行:

      - name: Composer update on php ${{ matrix.php }} and symfony ${{ matrix.symfony }}
        run: composer update --prefer-dist --no-progress
    

      - name: Composer update on php ${{ matrix.php }} and symfony ${{ matrix.symfony }}
        run: SYMFONY_REQUIRE=${{ matrix.symfony }} composer update --prefer-dist --no-progress
    

    这可能是部分解决方案,因为我猜它会在 windows-os 上失败。

    【讨论】:

      猜你喜欢
      • 2018-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-31
      • 1970-01-01
      • 2021-06-26
      • 2012-08-21
      相关资源
      最近更新 更多