Merge pull request #283 from shivammathur/develop

2.5.0
This commit is contained in:
Shivam Mathur 2020-09-07 09:44:02 +05:30
commit 0ca827ae3b
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
18 changed files with 742 additions and 494 deletions

1
.github/FUNDING.yml vendored
View File

@ -1,5 +1,6 @@
# These are supported funding model platforms # These are supported funding model platforms
open_collective: setup-php
tidelift: "npm/setup-php" tidelift: "npm/setup-php"
community_bridge: setup-php community_bridge: setup-php
patreon: shivammathur patreon: shivammathur

2
.github/SECURITY.md vendored
View File

@ -7,7 +7,7 @@ The following versions of this project are supported for security updates.
| Version | Supported | | Version | Supported |
| ------- | ------------------ | | ------- | ------------------ |
| 1.9.x | :white_check_mark: | | 1.9.x | :white_check_mark: |
| 2.4.x | :white_check_mark: | | 2.5.x | :white_check_mark: |
## Supported PHP Versions ## Supported PHP Versions

119
README.md
View File

@ -9,9 +9,13 @@
<p align="center"> <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://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://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="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-%3E%3D%205.3-8892BF.svg"></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>
<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> </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> </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. 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.
@ -100,8 +104,9 @@ 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. - 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 ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with pecl extension
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
tools: pecl tools: pecl
extensions: swoole extensions: swoole
@ -116,8 +121,9 @@ 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. - 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 ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with specific version of PECL extension
with: uses: shivammathur/setup-php@v2
with:
php-version: '5.4' php-version: '5.4'
tools: pecl tools: pecl
extensions: swoole-1.9.3 extensions: swoole-1.9.3
@ -126,8 +132,9 @@ with:
- Pre-release versions of PECL extensions can be setup by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`. - Pre-release versions of PECL extensions can be setup by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with pre-release PECL extension
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
tools: pecl tools: pecl
extensions: xdebug-beta extensions: xdebug-beta
@ -136,12 +143,23 @@ with:
- Shared extensions can be removed by prefixing them with a `:`. - Shared extensions can be removed by prefixing them with a `:`.
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP and remove shared extension
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
extensions: :opcache 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. - Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
- These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS. - These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.
@ -150,11 +168,12 @@ with:
These tools can be setup globally using the `tools` input. 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 ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with tools
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
@ -163,23 +182,28 @@ 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. 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 ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with composer v2
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
tools: composer:v2 tools: composer:v2
``` ```
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. 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 ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with tools
with: uses: shivammathur/setup-php@v2
php-version: '7.4' with:
tools: php-cs-fixer:2.16.2, phpunit:8.5.1 php-version: '7.2'
tools: phpunit:8.5.8
``` ```
**Notes** **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. - 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. - Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
@ -191,8 +215,9 @@ Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action"). Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with Xdebug
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
coverage: xdebug coverage: xdebug
``` ```
@ -205,13 +230,25 @@ 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. If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with PCOV
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
ini-values: pcov.directory=api #optional, see above for usage. ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov 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 ### Disable Coverage
Specify `coverage: none` to remove both `Xdebug` and `PCOV`. Specify `coverage: none` to remove both `Xdebug` and `PCOV`.
@ -223,8 +260,9 @@ Consider disabling the coverage using this PHP action for these reasons.
- You are profiling your code using `blackfire`. - You are profiling your code using `blackfire`.
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with no coverage driver
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
coverage: none coverage: none
``` ```
@ -326,7 +364,7 @@ steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup nightly PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.0' php-version: '8.0'
@ -438,7 +476,7 @@ jobs:
- You can specify the `update` environment variable to `true` to force update to the latest release. - You can specify the `update` environment variable to `true` to force update to the latest release.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP with latest versions
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
@ -453,7 +491,7 @@ jobs:
To debug any issues, you can use the `verbose` tag instead of `v2`. To debug any issues, you can use the `verbose` tag instead of `v2`.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP with logs
uses: shivammathur/setup-php@verbose uses: shivammathur/setup-php@verbose
with: with:
php-version: '7.4' php-version: '7.4'
@ -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. - 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"). - 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 contributors*
<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 ## :sparkling_heart: Support This Project
- Please star the project and share it. If you blog, please share your experience of using this action. - 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:contact@setup-php.com) to sponsor the project. - If you use `setup-php` at your company, please [reach out](mailto:contact@setup-php.com) to sponsor the project.
*Huge thanks to the following companies for supporting `setup-php`* *Huge thanks to the following companies for supporting `setup-php`*
<p> <p>
<a href="https://www.jetbrains.com/?from=setup-php"> <a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="150" height="85"> <img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="106" height="60">
</a> </a>
<img src="https://shivammathur.com/blank.svg" alt="spacer" width="40" height="85"> &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"> <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/tidelift.png" alt="Tidelift" width="70" height="60">
</a> </a>
</p> </p>
@ -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/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-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/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](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-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") - [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")

View File

@ -12,9 +12,9 @@ describe('Config tests', () => {
win32 = await config.addINIValues( win32 = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', '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 () => { it('checking addINIValuesOnLinux', async () => {
@ -29,9 +29,9 @@ describe('Config tests', () => {
linux = await config.addINIValues( linux = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', '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 () => { it('checking addINIValuesOnDarwin', async () => {
@ -45,8 +45,8 @@ describe('Config tests', () => {
darwin = await config.addINIValues( darwin = await config.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata', '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');
}); });
}); });

View File

@ -46,8 +46,8 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Phalcon phalcon3'); expect(win32).toContain('Add-Phalcon phalcon3');
expect(win32).toContain('Add-Extension does_not_exist'); expect(win32).toContain('Add-Extension does_not_exist');
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora'); win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(win32).toContain('Platform fedora is not supported'); expect(win32).toContain('Platform openbsd is not supported');
win32 = await extensions.addExtension('blackfire', '7.3', 'win32'); win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
expect(win32).toContain('Add-Blackfire blackfire'); expect(win32).toContain('Add-Blackfire blackfire');
@ -100,8 +100,8 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('cubrid', '7.4', 'linux'); linux = await extensions.addExtension('cubrid', '7.4', 'linux');
expect(linux).toContain('add_cubrid cubrid'); expect(linux).toContain('add_cubrid cubrid');
linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(linux).toContain('Platform fedora is not supported'); expect(linux).toContain('Platform openbsd is not supported');
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux'); linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('add_phalcon phalcon3'); expect(linux).toContain('add_phalcon phalcon3');
@ -119,6 +119,12 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux'); linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
expect(linux).toContain('add_blackfire blackfire-1.31.0'); 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 () => { it('checking addExtensionOnDarwin', async () => {
@ -195,7 +201,7 @@ describe('Extension tests', () => {
); );
expect(darwin).toContain('add_extension does_not_exist'); expect(darwin).toContain('add_extension does_not_exist');
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora'); darwin = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(darwin).toContain('Platform fedora is not supported'); expect(darwin).toContain('Platform openbsd is not supported');
}); });
}); });

View File

@ -270,8 +270,8 @@ describe('Tools tests', () => {
expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain( expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain(
'releases/download/v1.2.3/symfony_windows_amd64' 'releases/download/v1.2.3/symfony_windows_amd64'
); );
expect(await tools.getSymfonyUri('1.2.3', 'fedora')).toContain( expect(await tools.getSymfonyUri('1.2.3', 'openbsd')).toContain(
'Platform fedora is not supported' 'Platform openbsd is not supported'
); );
}); });
@ -300,21 +300,18 @@ describe('Tools tests', () => {
it('checking addArchive', async () => { it('checking addArchive', async () => {
let script: string = await tools.addArchive( let script: string = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'linux' 'linux'
); );
expect(script).toContain('add_tool https://tool.com/tool.phar tool'); expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'darwin' 'darwin'
); );
expect(script).toContain('add_tool https://tool.com/tool.phar tool'); expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'win32' 'win32'
); );
@ -322,11 +319,10 @@ describe('Tools tests', () => {
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'fedora' 'openbsd'
); );
expect(script).toContain('Platform fedora is not supported'); expect(script).toContain('Platform openbsd is not supported');
}); });
it('checking addDevTools', async () => { it('checking addDevTools', async () => {
@ -354,8 +350,8 @@ describe('Tools tests', () => {
'Add-Log "$cross" "php-config" "php-config is not a windows tool"' 'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
); );
script = await tools.addDevTools('tool', 'fedora'); script = await tools.addDevTools('tool', 'openbsd');
expect(script).toContain('Platform fedora is not supported'); expect(script).toContain('Platform openbsd is not supported');
}); });
it('checking addPackage', async () => { it('checking addPackage', async () => {
@ -373,13 +369,13 @@ describe('Tools tests', () => {
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
expect(script).toContain('Add-Composertool tool tool:1.2.3 user/'); expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'openbsd');
expect(script).toContain('Platform fedora is not supported'); expect(script).toContain('Platform openbsd is not supported');
}); });
it('checking addTools on linux', async () => { it('checking addTools on linux', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli', 'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
'7.4', '7.4',
'linux' 'linux'
); );
@ -399,6 +395,9 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan' 'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
); );
expect(script).toContain(
'add_tool https://www.phing.info/get/phing-latest.phar phing'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.io/releases/phive.phar phive' 'add_tool https://phar.io/releases/phive.phar phive'
); );
@ -436,6 +435,7 @@ describe('Tools tests', () => {
'infection', 'infection',
'phan', 'phan',
'phan:2.7.2', 'phan:2.7.2',
'phing:1.2.3',
'phinx', 'phinx',
'phive:1.2.3', 'phive:1.2.3',
'php-config', 'php-config',
@ -483,6 +483,9 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan' 'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan'
); );
expect(script).toContain(
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs' 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
); );

View File

@ -131,8 +131,8 @@ describe('Utils tests', () => {
expect(step_log).toEqual('step_log "Test message"'); expect(step_log).toEqual('step_log "Test message"');
step_log = await utils.stepLog(message, 'darwin'); step_log = await utils.stepLog(message, 'darwin');
expect(step_log).toEqual('step_log "Test message"'); expect(step_log).toEqual('step_log "Test message"');
step_log = await utils.stepLog(message, 'fedora'); step_log = await utils.stepLog(message, 'openbsd');
expect(step_log).toContain('Platform fedora is not supported'); expect(step_log).toContain('Platform openbsd is not supported');
let add_log: string = await utils.addLog( let add_log: string = await utils.addLog(
'tick', 'tick',
@ -145,8 +145,8 @@ describe('Utils tests', () => {
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"'); expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin'); add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"'); expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'fedora'); add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'openbsd');
expect(add_log).toContain('Platform fedora is not supported'); expect(add_log).toContain('Platform openbsd is not supported');
}); });
it('checking getExtensionPrefix', async () => { it('checking getExtensionPrefix', async () => {
@ -163,8 +163,8 @@ describe('Utils tests', () => {
expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1'); expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1'); expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1'); expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('fedora')).toContain( expect(await utils.suppressOutput('openbsd')).toContain(
'Platform fedora is not supported' 'Platform openbsd is not supported'
); );
}); });
@ -178,8 +178,8 @@ describe('Utils tests', () => {
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool '); expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool '); expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool '); expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await utils.getCommand('fedora', 'tool')).toContain( expect(await utils.getCommand('openbsd', 'tool')).toContain(
'Platform fedora is not supported' 'Platform openbsd is not supported'
); );
}); });
@ -191,8 +191,8 @@ describe('Utils tests', () => {
expect(await utils.scriptExtension('linux')).toBe('.sh'); expect(await utils.scriptExtension('linux')).toBe('.sh');
expect(await utils.scriptExtension('darwin')).toBe('.sh'); expect(await utils.scriptExtension('darwin')).toBe('.sh');
expect(await utils.scriptExtension('win32')).toBe('.ps1'); expect(await utils.scriptExtension('win32')).toBe('.ps1');
expect(await utils.scriptExtension('fedora')).toContain( expect(await utils.scriptExtension('openbsd')).toContain(
'Platform fedora is not supported' 'Platform openbsd is not supported'
); );
}); });

62
dist/index.js vendored
View File

@ -973,7 +973,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1030,7 +1030,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1682,7 +1682,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1986,11 +1986,10 @@ exports.getCleanedToolsList = getCleanedToolsList;
* Helper function to get script to setup a tool using a phar url * Helper function to get script to setup a tool using a phar url
* *
* @param tool * @param tool
* @param version
* @param url * @param url
* @param os_version * @param os_version
*/ */
async function addArchive(tool, version, url, os_version) { async function addArchive(tool, url, os_version) {
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
@ -2054,22 +2053,22 @@ async function addTools(tools_csv, php_version, os_version) {
break; break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', version, url, os_version); script += await addArchive('composer', url, os_version);
break; break;
case 'composer-normalize': case 'composer-normalize':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'ergebnis/composer-normalize/' + uri; url = github + 'ergebnis/composer-normalize/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer-prefetcher': case 'composer-prefetcher':
script += await addPackage(tool, release, 'narrowspark/automatic-', os_version); script += await addPackage(tool, release, 'narrowspark/automatic-', os_version);
@ -2077,35 +2076,39 @@ async function addTools(tools_csv, php_version, os_version) {
case 'composer-require-checker': case 'composer-require-checker':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'maglnet/ComposerRequireChecker/' + uri; url = github + 'maglnet/ComposerRequireChecker/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer-unused': case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'composer-unused/composer-unused/' + uri; url = github + 'composer-unused/composer-unused/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'cs2pr': case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download'); uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'flex': case 'flex':
script += await addPackage(tool, release, 'symfony/', os_version); script += await addPackage(tool, release, 'symfony/', os_version);
break; break;
case 'infection': case 'infection':
url = github + 'infection/infection/' + uri; url = github + 'infection/infection/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'pecl': case 'pecl':
script += await utils.getCommand(os_version, 'pecl'); script += await utils.getCommand(os_version, 'pecl');
break; break;
case 'phan': case 'phan':
url = github + 'phan/phan/' + uri; url = github + 'phan/phan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break;
case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version);
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -2120,48 +2123,48 @@ async function addTools(tools_csv, php_version, os_version) {
case 'php-cs-fixer': case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcbf': case 'phpcbf':
case 'phpcs': case 'phpcs':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phplint': case 'phplint':
script += await addPackage(tool, release, 'overtrue/', os_version); script += await addPackage(tool, release, 'overtrue/', os_version);
break; break;
case 'phpmd': case 'phpmd':
url = github + 'phpmd/phpmd/' + uri; url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'prestissimo': case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version); script += await addPackage(tool, release, 'hirak/', os_version);
break; break;
case 'psalm': case 'psalm':
url = github + 'vimeo/psalm/' + uri; url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'symfony': case 'symfony':
case 'symfony-cli': case 'symfony-cli':
uri = await getSymfonyUri(version, os_version); uri = await getSymfonyUri(version, os_version);
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', version, url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
case 'vapor-cli': case 'vapor-cli':
script += await addPackage(tool, release, 'laravel/', os_version); script += await addPackage(tool, release, 'laravel/', os_version);
break; break;
case 'wp-cli': case 'wp-cli':
url = github + (await getWpCliUrl(version)); url = github + (await getWpCliUrl(version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
default: default:
script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version); script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
@ -2209,7 +2212,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2352,7 +2355,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2445,7 +2448,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2467,6 +2470,8 @@ const matchers = __importStar(__webpack_require__(86));
* @param os_version * @param os_version
*/ */
async function build(filename, version, os_version) { async function build(filename, version, os_version) {
const name = 'setup-php';
const url = 'setup-php.com/support';
// taking inputs // taking inputs
const extension_csv = (await utils.getInput('extensions', false)) || const extension_csv = (await utils.getInput('extensions', false)) ||
(await utils.getInput('extension', false)); (await utils.getInput('extension', false));
@ -2490,6 +2495,8 @@ async function build(filename, version, os_version) {
if (ini_values_csv) { if (ini_values_csv) {
script += await config.addINIValues(ini_values_csv, os_version); script += await config.addINIValues(ini_values_csv, os_version);
} }
script += '\n' + (await utils.stepLog('Support this project', os_version));
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
return await utils.writeScript(filename, script); return await utils.writeScript(filename, script);
} }
exports.build = build; exports.build = build;
@ -2763,7 +2770,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2950,6 +2957,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(version_extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):

770
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.4.3", "version": "2.5.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
@ -24,28 +24,28 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.4", "@actions/core": "^1.2.5",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.10", "@types/jest": "^26.0.13",
"@types/node": "^14.6.0", "@types/node": "^14.6.4",
"@typescript-eslint/eslint-plugin": "^3.9.1", "@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^3.9.1", "@typescript-eslint/parser": "^4.0.1",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.7.0", "eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.20.0", "eslint-plugin-jest": "^24.0.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5", "husky": "^4.2.5",
"jest": "^26.4.0", "jest": "^26.4.2",
"jest-circus": "^26.4.0", "jest-circus": "^26.4.2",
"prettier": "^2.0.5", "prettier": "^2.1.1",
"ts-jest": "^26.2.0", "ts-jest": "^26.3.0",
"typescript": "^3.9.7" "typescript": "^4.0.2"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,

View File

@ -245,6 +245,9 @@ export async function addExtensionLinux(
version_extension version_extension
): ):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(
version_extension
):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):

View File

@ -19,6 +19,8 @@ export async function build(
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
const name = 'setup-php';
const url = 'setup-php.com/support';
// taking inputs // taking inputs
const extension_csv: string = const extension_csv: string =
(await utils.getInput('extensions', false)) || (await utils.getInput('extensions', false)) ||
@ -48,6 +50,9 @@ export async function build(
script += await config.addINIValues(ini_values_csv, os_version); script += await config.addINIValues(ini_values_csv, os_version);
} }
script += '\n' + (await utils.stepLog('Support this project', os_version));
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
return await utils.writeScript(filename, script); return await utils.writeScript(filename, script);
} }

23
src/scripts/ext/intl.sh Normal file
View File

@ -0,0 +1,23 @@
# Function to install ICU
install_icu() {
icu=$1
if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then
sudo curl -o /tmp/icu.tar.zst -sL "https://dl.bintray.com/shivammathur/icu4c/icu4c-$icu.tar.zst"
sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local
sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/
fi
}
# Function to add ext-intl with the given version of ICU
add_intl() {
icu=$(echo "$1" | cut -d'-' -f 2)
supported_version=$(curl "${curl_opts[@]:?}" https://api.bintray.com/packages/shivammathur/icu4c/icu4c | grep -Po "$icu" | head -n 1)
if [ "$icu" != "$supported_version" ]; then
add_log "${cross:?}" "intl" "ICU $icu is not supported"
else
install_icu "$icu" >/dev/null 2>&1
sudo curl "${curl_opts[@]:?}" -o "${ext_dir:?}/intl.so" "https://dl.bintray.com/shivammathur/icu4c/php${version:?}-intl-$icu.so"
enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu"
fi
}

View File

@ -41,6 +41,7 @@ cleanup_lists() {
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save
sudo mkdir /etc/apt/sources.list.d sudo mkdir /etc/apt/sources.list.d
sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/ sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/
sudo mv /etc/apt/sources.list.d.save/*dotdeb*.list /etc/apt/sources.list.d/ 2>/dev/null || true
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit
fi fi
} }
@ -124,7 +125,10 @@ delete_extension() {
sudo sed -i "/$extension/d" "$pecl_file" sudo sed -i "/$extension/d" "$pecl_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
[ "$runner" = "self-hosted" ] && $apt_remove "php-$extension" if [ "$runner" = "self-hosted" ]; then
$apt_remove "php-$extension" >/dev/null 2>&1 || true
$apt_remove "php$version-$extension" >/dev/null 2>&1 || true
fi
} }
# Function to disable and delete extensions. # Function to disable and delete extensions.

View File

@ -1,5 +1,9 @@
# Function to add blackfire and blackfire-agent. # Function to add blackfire and blackfire-agent.
Function Add-Blackfire() { Function Add-Blackfire() {
$arch_name ='amd64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
$arch_name = '386'
}
$agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent $agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent
$url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip" $url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1 Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1

View File

@ -1,12 +1,12 @@
get_protobuf_tag() { get_protobuf_tag() {
if [ "$protobuf_tag" = "latest" ]; then if [ "$protobuf_tag" = "latest" ]; then
protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+.[0-9]+.[0-9]+)" | head -n 1) protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
else else
status_code=$(sudo curl -s -w "%{http_code}" -o /tmp/protobuf.tmp "${curl_opts[@]:?}" "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag") status_code=$(sudo curl -s -w "%{http_code}" -o /tmp/protobuf.tmp "${curl_opts[@]:?}" "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
if [ "$status_code" = "200" ]; then if [ "$status_code" = "200" ]; then
protobuf_tag="v$protobuf_tag" protobuf_tag="v$protobuf_tag"
else else
protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+.[0-9]+.[0-9]+)" | head -n 1) protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
fi fi
fi fi
} }

View File

@ -64,6 +64,20 @@ Function Add-Path {
Get-PathFromRegistry Get-PathFromRegistry
} }
# Function to make sure printf is in PATH.
Function Add-Printf {
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
} else {
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
}
} else {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe"
}
}
# Function to get a clean Powershell profile. # Function to get a clean Powershell profile.
Function Get-CleanPSProfile { Function Get-CleanPSProfile {
if(-not(Test-Path -LiteralPath $profile)) { if(-not(Test-Path -LiteralPath $profile)) {
@ -75,13 +89,12 @@ Function Get-CleanPSProfile {
# Function to install PhpManager. # Function to install PhpManager.
Function Install-PhpManager() { Function Install-PhpManager() {
$repo = "mlocati/powershell-phpmanager" $module_path = "$bin_dir\PhpManager\PhpManager.psm1"
$tag = (Invoke-RestMethod https://api.github.com/repos/$repo/tags)[0].Name
$module_path = "$bin_dir\PhpManager\powershell-phpmanager-$tag\PhpManager\PhpManager.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { if(-not (Test-Path $module_path -PathType Leaf)) {
$release = Invoke-RestMethod https://api.github.com/repos/mlocati/powershell-phpmanager/releases/latest
$zip_file = "$bin_dir\PhpManager.zip" $zip_file = "$bin_dir\PhpManager.zip"
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir\PhpManager -Force Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
} }
Import-Module $module_path Import-Module $module_path
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path" Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path"
@ -276,17 +289,14 @@ $master_version = '8.0'
$cert_source='CurrentUser' $cert_source='CurrentUser'
$arch = 'x64' $arch = 'x64'
$arch_name ='amd64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') { if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
$arch = 'x86' $arch = 'x86'
$arch_name = '386'
} }
$ts = $env:PHPTS -eq 'ts' $ts = $env:PHPTS -eq 'ts'
if($env:PHPTS -ne 'ts') { if($env:PHPTS -ne 'ts') {
$env:PHPTS = 'nts' $env:PHPTS = 'nts'
} }
if($env:RUNNER -eq 'self-hosted') { if($env:RUNNER -eq 'self-hosted') {
$bin_dir = 'C:\tools\bin' $bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version" $php_dir = "$php_dir$version"
@ -295,10 +305,6 @@ if($env:RUNNER -eq 'self-hosted') {
Get-CleanPSProfile >$null 2>&1 Get-CleanPSProfile >$null 2>&1
New-Item $bin_dir -Type Directory 2>&1 | Out-Null New-Item $bin_dir -Type Directory 2>&1 | Out-Null
Add-Path -PathItem $bin_dir Add-Path -PathItem $bin_dir
if(-not(Test-Path $bin_dir\printf.exe)) {
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-$arch.zip" -OutFile "$bin_dir\printf.zip" >$null 2>&1
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force >$null 2>&1
}
if($version -lt 5.6) { if($version -lt 5.6) {
Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner" Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner"
Start-Sleep 1 Start-Sleep 1
@ -316,6 +322,8 @@ if($env:RUNNER -eq 'self-hosted') {
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1 New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
} }
} }
Add-Printf >$null 2>&1
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-PhpManager >$null 2>&1 Install-PhpManager >$null 2>&1
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"

View File

@ -346,13 +346,11 @@ export async function getCleanedToolsList(
* Helper function to get script to setup a tool using a phar url * Helper function to get script to setup a tool using a phar url
* *
* @param tool * @param tool
* @param version
* @param url * @param url
* @param os_version * @param os_version
*/ */
export async function addArchive( export async function addArchive(
tool: string, tool: string,
version: string,
url: string, url: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
@ -449,22 +447,22 @@ export async function addTools(
break; break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', version, url, os_version); script += await addArchive('composer', url, os_version);
break; break;
case 'composer-normalize': case 'composer-normalize':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'ergebnis/composer-normalize/' + uri; url = github + 'ergebnis/composer-normalize/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer-prefetcher': case 'composer-prefetcher':
script += await addPackage( script += await addPackage(
@ -477,35 +475,39 @@ export async function addTools(
case 'composer-require-checker': case 'composer-require-checker':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'maglnet/ComposerRequireChecker/' + uri; url = github + 'maglnet/ComposerRequireChecker/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer-unused': case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'composer-unused/composer-unused/' + uri; url = github + 'composer-unused/composer-unused/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'cs2pr': case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download'); uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'flex': case 'flex':
script += await addPackage(tool, release, 'symfony/', os_version); script += await addPackage(tool, release, 'symfony/', os_version);
break; break;
case 'infection': case 'infection':
url = github + 'infection/infection/' + uri; url = github + 'infection/infection/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'pecl': case 'pecl':
script += await utils.getCommand(os_version, 'pecl'); script += await utils.getCommand(os_version, 'pecl');
break; break;
case 'phan': case 'phan':
url = github + 'phan/phan/' + uri; url = github + 'phan/phan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break;
case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version);
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -520,48 +522,48 @@ export async function addTools(
case 'php-cs-fixer': case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcbf': case 'phpcbf':
case 'phpcs': case 'phpcs':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phplint': case 'phplint':
script += await addPackage(tool, release, 'overtrue/', os_version); script += await addPackage(tool, release, 'overtrue/', os_version);
break; break;
case 'phpmd': case 'phpmd':
url = github + 'phpmd/phpmd/' + uri; url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'prestissimo': case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version); script += await addPackage(tool, release, 'hirak/', os_version);
break; break;
case 'psalm': case 'psalm':
url = github + 'vimeo/psalm/' + uri; url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'symfony': case 'symfony':
case 'symfony-cli': case 'symfony-cli':
uri = await getSymfonyUri(version, os_version); uri = await getSymfonyUri(version, os_version);
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', version, url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
case 'vapor-cli': case 'vapor-cli':
script += await addPackage(tool, release, 'laravel/', os_version); script += await addPackage(tool, release, 'laravel/', os_version);
break; break;
case 'wp-cli': case 'wp-cli':
url = github + (await getWpCliUrl(version)); url = github + (await getWpCliUrl(version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
default: default:
script += await utils.addLog( script += await utils.addLog(