2

I'm trying to test a bundle on different versions of Symfony with github actions. I tried to configure my job as explained in Best practices for reusable bundles

Here is my job:

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

Even if I export Symfony version with symfony/flex, composer always install Symfony 5.3 (which is the current stable version)

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)

If needed, here is the requirement lines of my composer.json file:

{
    ...
    "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"
    },
    ...
}

EDIT: On my local dev computer, it works fine, when I run:

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

1 Answer 1

1

It seems that export command isn't environment-proof.

Finally, I removed these lines:

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

and updated the last line:

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

to

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

This perhaps is a partial solution, because I guess that it will failed on windows-os.

Sign up to request clarification or add additional context in comments.

1 Comment

Did you figure out a foolproof solution?

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.