I'm trying to build a composer library that I would like to be compatible back to PHP 7.0 but for this to work I need to use different PHPUnit versions.
I am trying to update the require component based on if-statements, but either none of them or all of them run. I don't really understand why.
I have tried to take inspiration from this post: github-action: does the IF have an 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
What exactly am I doing wrong or not understanding properly?