我试图建立一个作曲家库,我想要兼容回PHP 7.0,但为此工作,我需要使用不同的PHPUnit版本。
我正试图根据if语句更新require组件,但要么没有一个,要么全部运行。我真的不明白为什么。
我试着从这篇文章中获得灵感:github-action: IF有ELSE吗?
name: PHP CI
on:
pull_request:
branches:
- "master"
workflow_dispatch:
jobs:
render-php:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: ["ubuntu-latest"]
php-versions: ["7.0", "7.4", "8.0"]
phpunit-versions: ["latest"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git merge origin/master --no-commit --ff-only
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: phpunit:${{ matrix.phpunit-versions }}
- run: echo "${{ matrix.php-versions }}"
- name: "PHP 7.0"
if: "${{ matrix.php-versions }} == 7.0"
run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 6.0
- name: "PHP 7.4"
if: "${{ matrix.php-versions }} == 7.4"
run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 8.0
- name: "PHP >8.0"
if: "${{ matrix.php-versions }} >= 8.0"
run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit
- run: composer install
- run: ./vendor/bin/phpunit
我到底做错了什么或没有正确理解?
是我不理解if语句的工作方式,它应该是这样的状态:
if: ${{ matrix.php-versions == 7.0 }}