Skip to content

Commit

Permalink
Merge pull request #283 from shivammathur/develop
Browse files Browse the repository at this point in the history
2.5.0
  • Loading branch information
shivammathur authored Sep 7, 2020
2 parents ffded4a + 7686d22 commit 1c76a2a
Show file tree
Hide file tree
Showing 17 changed files with 747 additions and 496 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# These are supported funding model platforms

open_collective: setup-php
tidelift: "npm/setup-php"
community_bridge: setup-php
patreon: shivammathur
Expand Down
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The following versions of this project are supported for security updates.
| Version | Supported |
| ------- | ------------------ |
| 1.9.x | :white_check_mark: |
| 2.4.x | :white_check_mark: |
| 2.5.x | :white_check_mark: |

## Supported PHP Versions

Expand Down
171 changes: 111 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
<p align="center">
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.3-8892BF.svg"></a>
<a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter"></a>
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
</p>
<p align="center">
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
<a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555"></a>
<a href="https://setup-php.statuspage.io/" title="setup-php status"><img alt="setup-php status" src="https://img.shields.io/badge/status-subscribe-28A745?logo=statuspage&logoColor=28A745&labelColor=555555"></a>
</p>

Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
Expand Down Expand Up @@ -100,11 +104,12 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: pecl
extensions: swoole
- name: Setup PHP with pecl extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: pecl
extensions: swoole
```
- On `windows` PECL extensions which have the `DLL` binary can be installed.
Expand All @@ -116,30 +121,43 @@ with:
- Specific versions of PECL extensions can be installed by suffixing the version. This is useful for installing old versions of extensions which support end of life PHP versions.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '5.4'
tools: pecl
extensions: swoole-1.9.3
- name: Setup PHP with specific version of PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '5.4'
tools: pecl
extensions: swoole-1.9.3
```

- Pre-release versions of PECL extensions can be setup by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: pecl
extensions: xdebug-beta
- name: Setup PHP with pre-release PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: pecl
extensions: xdebug-beta
```

- Shared extensions can be removed by prefixing them with a `:`.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: :opcache
- name: Setup PHP and remove shared extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: :opcache
```

- Extension `intl` can be setup with specific `ICU` version for `PHP 5.6` to `PHP 7.4` in `Ubuntu` workflows by suffixing `intl` with the `ICU` version. `ICU 50.2` and newer versions are supported. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported.

```yaml
- name: Setup PHP with intl
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: intl-67.1
```

- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
Expand All @@ -150,36 +168,42 @@ with:

These tools can be setup globally using the `tools` input.

`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli`
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phing`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli`

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: php-cs-fixer, phpunit
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: php-cs-fixer, phpunit
```

To setup a particular version of a tool, specify it in the form `tool:version`.
Latest stable version of `composer` is setup by default. You can setup the required version by specifying `v1`, `v2`, `snapshot` or `preview` as version.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
```

Version for other tools should be in `semver` format and a valid release of the tool.
Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.

Version for other tools should be in `semver` format and a valid release of the tool.
This is useful for installing tools for older versions of PHP.
For example to setup `PHPUnit` on `PHP 7.2`.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: php-cs-fixer:2.16.2, phpunit:8.5.1
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: phpunit:8.5.8
```

**Notes**
- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.

Expand All @@ -191,10 +215,11 @@ Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
```

### PCOV
Expand All @@ -205,11 +230,23 @@ Tests with `PCOV` run much faster than with `Xdebug`.
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov
- name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov
```

`PHPUnit` 8 and above supports `PCOV` out of the box.
If you are using `PHPUnit` 5, 6 or 7, you will need `krakjoe/pcov-clobber`.
Before executing your tests add the following step.

```yaml
- name: Setup PCOV
run: |
composer require pcov/clobber
vendor/bin/pcov clobber
```

### Disable Coverage
Expand All @@ -223,10 +260,11 @@ Consider disabling the coverage using this PHP action for these reasons.
- You are profiling your code using `blackfire`.

```yaml
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
- name: Setup PHP with no coverage driver
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
```

## :memo: Usage
Expand Down Expand Up @@ -326,7 +364,7 @@ steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
- name: Setup nightly PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
Expand Down Expand Up @@ -438,7 +476,7 @@ jobs:
- You can specify the `update` environment variable to `true` to force update to the latest release.

```yaml
- name: Setup PHP
- name: Setup PHP with latest versions
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
Expand All @@ -453,7 +491,7 @@ jobs:
To debug any issues, you can use the `verbose` tag instead of `v2`.

```yaml
- name: Setup PHP
- name: Setup PHP with logs
uses: shivammathur/setup-php@verbose
with:
php-version: '7.4'
Expand Down Expand Up @@ -613,21 +651,33 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
- See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide") before you start.
- If you face any issues while using this or want to suggest a feature/improvement, create an issue [here](https://github.com/shivammathur/setup-php/issues "Issues reported").

*Join the list of setup-php contributions*

<p align="center">
<a href="https://github.com/shivammathur/setup-php/graphs/contributors">
<img src="https://opencollective.com/setup-php/contributors.svg?width=1024&button=false" alt="setup-php contributers" width="100%">
</a>
</p>

## :sparkling_heart: Support This Project

- Please star the project and share it. If you blog, please share your experience of using this action.
- Please consider supporting our work by sponsoring using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon").
- Please consider supporting our work by sponsoring using [Open Collective](https://opencollective.com/setup-php), [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon").
- If you use `setup-php` at your company, please [reach out](mailto:[email protected]) to sponsor the project.

*Huge thanks to the following companies for supporting `setup-php`*

<p>
<p>
<a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="150" height="85">
</a>
<img src="https://shivammathur.com/blank.svg" alt="spacer" width="40" height="85">
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://shivammathur.com/tidelift.png" alt="Tidelift" width="100" height="85">
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="106" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://blackfire.io/?utm_source=setup-php">
<img src="https://shivammathur.com/blackfire.svg" alt="Blackfire" width="212" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://shivammathur.com/tidelift.png" alt="Tidelift" width="70" height="60">
</a>
</p>

Expand All @@ -641,6 +691,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
- [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases")
- [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
- [shivammathur/icu-intl](https://github.com/shivammathur/icu-intl "icu4c and php-intl builds")
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
- [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
- [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
Expand Down
12 changes: 6 additions & 6 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('Config tests', () => {

win32 = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
'openbsd'
);
expect(win32).toContain('Platform fedora is not supported');
expect(win32).toContain('Platform openbsd is not supported');
});

it('checking addINIValuesOnLinux', async () => {
Expand All @@ -29,9 +29,9 @@ describe('Config tests', () => {

linux = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
'openbsd'
);
expect(linux).toContain('Platform fedora is not supported');
expect(linux).toContain('Platform openbsd is not supported');
});

it('checking addINIValuesOnDarwin', async () => {
Expand All @@ -45,8 +45,8 @@ describe('Config tests', () => {

darwin = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
'openbsd'
);
expect(darwin).toContain('Platform fedora is not supported');
expect(darwin).toContain('Platform openbsd is not supported');
});
});
18 changes: 12 additions & 6 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Phalcon phalcon3');
expect(win32).toContain('Add-Extension does_not_exist');

win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(win32).toContain('Platform fedora is not supported');
win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(win32).toContain('Platform openbsd is not supported');

win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
expect(win32).toContain('Add-Blackfire blackfire');
Expand Down Expand Up @@ -100,8 +100,8 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
expect(linux).toContain('add_cubrid cubrid');

linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(linux).toContain('Platform fedora is not supported');
linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(linux).toContain('Platform openbsd is not supported');

linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('add_phalcon phalcon3');
Expand All @@ -119,6 +119,12 @@ describe('Extension tests', () => {

linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
expect(linux).toContain('add_blackfire blackfire-1.31.0');

linux = await extensions.addExtension('intl-65.1', '5.6', 'linux');
expect(linux).toContain('add_intl intl-65.1');

linux = await extensions.addExtension('intl-67.1', '7.3', 'linux');
expect(linux).toContain('add_intl intl-67.1');
});

it('checking addExtensionOnDarwin', async () => {
Expand Down Expand Up @@ -195,7 +201,7 @@ describe('Extension tests', () => {
);
expect(darwin).toContain('add_extension does_not_exist');

darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(darwin).toContain('Platform fedora is not supported');
darwin = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(darwin).toContain('Platform openbsd is not supported');
});
});
Loading

0 comments on commit 1c76a2a

Please sign in to comment.