shivammathur / setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
https://setup-php.com
MIT License
2.92k stars 341 forks source link

Enable PHP extension manually #741

Closed boenrobot closed 1 year ago

boenrobot commented 1 year ago

Describe the feature

Provide some script (and docs for it) which would allow the user of the action to call upon it to install, enable or disable PHP extensions during the run of their CI script, rather than at the initial setup.

Version

Underlying issue

I have tests which depend on the presence or absence of a PHP extension (GD in the particular case, but the same problem exists with many extensions). That is, some tests require the presence of the extension, and others its absence.

Sure, I could run tests in a matrix, but it's only a couple of tests that need this, while the vast majority don't. So it would be super inefficient to run all tests again, this time without the PHP extension.

So instead, I'd like to run all tests without the extension, then enable the extension, and run only the tests that require its presence.

Describe alternatives

I did see some scripts in the scripts folder for this... It seems like I could reverse engineer them, or manually perform the steps done inside, but both of those ideas seem error prone. Having an actual guide to follow would be much better.

Additional context

Are you willing to submit a PR?

I am too unfamiliar with the organizations of github actions, so an initial PR, probably no.

If there's some discrepancies between PHP extensions installed initially and installed with the separate tool (i.e. installations succeeds in one way, but not the other), I would be willing to submit PR(s) with fixes.

shivammathur commented 1 year ago

Hope this helps.

Prefixing an extension with : in the extensions input should disable it.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: 8.1
    extensions: :gd

# Run tests without gd

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  with:
    php-version: 8.1
    extensions: gd

# Run tests with gd

Test workflow: https://github.com/shivammathur/test-setup-php/actions/runs/5240987253/workflow