Compare commits

...

59 Commits
2.5.0 ... 2.7.0

Author SHA1 Message Date
c188004a52 Fix macos 2020-11-28 14:59:24 +05:30
c596331f84 Improve regexes for pre-release extensions 2020-10-31 19:04:20 +05:30
bb5dfb73cf Fix php-dev setup 2020-10-31 15:25:16 +05:30
215b040f0d Fix contribution docs 2020-10-31 14:55:27 +05:30
925ede2589 Refactor composer setup 2020-10-30 19:25:39 +05:30
d1510a82d5 Merge pull request #321 from mlocati/composer-specific-version
Allow installing a specific Composer version
2020-10-30 17:46:45 +05:30
808e74aed5 Adjust filtered composer version 2020-10-30 12:02:36 +01:00
f51d00d350 Allow installing a specific Composer version 2020-10-30 11:15:26 +01:00
c8111b053c Fix blackfire-player to v1.9.3 for PHP 5.5 to PHP 7.0 2020-10-30 11:40:25 +05:30
294f03454a Install VcRedist from GitHub 2020-10-30 11:40:24 +05:30
5d27b8f90e Use PECL directly for nightly versions 2020-10-28 22:21:08 +05:30
87e62cbb7f Fix composer version for prestissimo & composer-prefetcher to v1 2020-10-25 00:55:01 +05:30
2c29e8b9a1 Fix version change if composer is a dependency 2020-10-24 23:40:43 +05:30
04a9e3b562 Update dependencies as per runner on macOS 2020-10-23 07:22:04 +05:30
4adaa73d25 Merge pull request #315 from GrahamCampbell/patch-1
PHP 8.1 supported too
2020-10-22 02:45:09 +05:30
234594684c PHP 8.1 supported too 2020-10-21 22:08:40 +01:00
3c0527bec1 Merge pull request #313 from shivammathur/develop
2.7.0
2020-10-19 18:26:33 +05:30
c5d41cd3f1 Bump version to 2.7.0 2020-10-19 17:39:36 +05:30
601cabfd2a Update README 2020-10-19 17:06:48 +05:30
81c750c6d7 Add support for imagick for PHP 5.6+ on macOS using shivammathur/homebrew-extensions 2020-10-19 15:55:40 +05:30
0661130e18 Add support for igbinary on macOS using shivammathur/homebrew-extensions 2020-10-18 19:41:59 +05:30
4244b92ac6 Fix matchers setup when action is called twice 2020-10-18 19:41:58 +05:30
e9595da9ac Remove patch for RLIMIT_CORE bug in sudo, fixed upstream 2020-10-18 19:41:57 +05:30
b77ec78d01 Add support for fail-fast env variable 2020-10-18 19:41:56 +05:30
96d8c1e901 Add support for PHP 8.1 on par with PHP 8.0 2020-10-18 19:41:55 +05:30
8816b6ff48 Add PHP 8.1 to the main workflow 2020-10-18 19:41:54 +05:30
9205a596c9 Add support for PHP 8.1 on Windows 2020-10-18 19:41:53 +05:30
6fc20c9b7f Add support for PHP 8.1 on Ubuntu 2020-10-18 19:41:52 +05:30
eb07280d5c Perform only one URL call to download latest PhpManager.zip asset 2020-10-18 19:41:51 +05:30
eaaab1cec3 Fix oci8 and pdo_oci 2020-10-18 19:33:03 +05:30
853381d0bb Merge pull request #310 from shivammathur/develop
Switch to apt-get
2020-10-15 14:16:50 +05:30
1394617d60 Switch to apt-get 2020-10-15 14:16:50 +05:30
093498a0a1 Merge pull request #307 from shivammathur/develop
Specify PHP version when installing ast
2020-10-15 14:16:49 +05:30
d2241010ef Specify PHP version when installing ast 2020-10-15 14:16:48 +05:30
a0f02c17c0 Merge pull request #304 from shivammathur/develop
Hotfix
2020-10-15 14:16:47 +05:30
bb5257e07d Update Node.js dependencies 2020-10-15 14:16:47 +05:30
f687ff8f21 Fix dependency mess in phalcon4 setup on ubuntu 2020-10-15 14:16:46 +05:30
537c66b2ea Minor fixes in scripts 2020-10-15 14:16:22 +05:30
073c2e666b Merge pull request #300 from shivammathur/develop
2.6.0
2020-10-15 14:16:21 +05:30
465e63b28c Bump version to 2.6.0 2020-10-15 14:16:21 +05:30
b8f0b066dc Add support for behat and phpspec 2020-10-15 14:16:20 +05:30
9e663851ce Move matchers setup to scripts 2020-10-15 14:16:19 +05:30
ad196941ed Refactor install.test.ts 2020-10-15 14:16:19 +05:30
f8e867a9ff Refactor install.ts 2020-10-15 14:16:18 +05:30
8cb01730c7 Prioritize with over env for inputs 2020-10-15 14:16:17 +05:30
ebba1db2c3 Add alias latest 2020-10-15 14:16:17 +05:30
716331904e Switch to environment files. Apply GHSA-mfwh-5m23-j46w (CVE-2020-15228) 2020-10-15 14:16:16 +05:30
2ad63ddbd3 Merge pull request #294 from shivammathur/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.5 to 1.2.6
2020-10-15 14:16:15 +05:30
c4606c9269 Log versions in tools setup 2020-10-15 14:16:15 +05:30
7dcb43c768 Improve problem matchers section in README 2020-10-15 14:16:14 +05:30
691c5309aa Bump @actions/core from 1.2.5 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-15 14:16:13 +05:30
84b222366a Merge pull request #292 from szepeviktor/patch-1
PHPStan is GH Actions-friendly
2020-10-15 14:16:13 +05:30
b98ed88402 PHPStan is GH Actions-friendly
no need for cs2pr
2020-10-15 14:16:12 +05:30
0ca827ae3b Merge pull request #283 from shivammathur/develop
2.5.0
2020-10-15 14:16:11 +05:30
16b0a25bf6 Bump version to 2.5.0 2020-10-15 14:16:10 +05:30
fa0af5c382 Update README 2020-10-15 14:16:09 +05:30
db36b200b1 Fix regex in protoc.sh 2020-10-15 14:16:06 +05:30
7cfd76cc1b Move $arch_name to tools/blackfire.ps1 2020-10-15 14:16:05 +05:30
682b1f5e44 Make sure printf is in PATH in Windows 2020-10-15 14:16:04 +05:30
34 changed files with 2073 additions and 1417 deletions

View File

@ -8,7 +8,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C
* Fork the project. * Fork the project.
* Make your bug fix or feature addition. * Make your bug fix or feature addition.
* Add tests for it. This is important so we don't break it in a future version unintentionally. * Add tests for it, so we don't break it in a future version unintentionally.
* If editing the scripts, create a demo integration test. * If editing the scripts, create a demo integration test.
* Send a pull request to the develop branch with all the details. * Send a pull request to the develop branch with all the details.
@ -18,13 +18,6 @@ Due to time constraints, you may not always get a quick response. Please do not
## Coding Guidelines ## Coding Guidelines
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to format the code before committing it.
```bash
$ npm run format
$ npm run lint
```
## Using setup-php from a Git checkout ## Using setup-php from a Git checkout
The following commands can be used to perform the initial checkout of setup-php: The following commands can be used to perform the initial checkout of setup-php:
@ -41,6 +34,19 @@ Install setup-php dependencies using [npm](https://www.npmjs.com/):
$ npm install $ npm install
``` ```
If you are using `Windows` configure `git` to handle line endings.
```cmd
git config --local core.autocrlf true
```
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to fix and verify the code quality.
```bash
$ npm run format
$ npm run lint
```
## Running the test suite ## Running the test suite
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command: After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:

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

View File

@ -11,7 +11,7 @@ assignees: 'shivammathur'
<!-- Please describe the bug concisely. --> <!-- Please describe the bug concisely. -->
**Version** **Version**
- [ ] I have checked releases and the bug exists in the latest patch version of `v1` or `v2`. - [ ] I have checked releases, and the bug exists in the latest patch version of `v1` or `v2`.
- [ ] `v2` - [ ] `v2`
- [ ] `v1` - [ ] `v1`

View File

@ -11,7 +11,7 @@ assignees: 'shivammathur'
<!-- Please describe concisely the feature you want to add. --> <!-- Please describe concisely the feature you want to add. -->
**Version** **Version**
- [ ] I have checked releases and the feature is missing in the latest patch version of `v2`. - [ ] I have checked releases, and the feature is missing in the latest patch version of `v2`.
**Underlying issue** **Underlying issue**
<!-- Please describe the issue this would solve. --> <!-- Please describe the issue this would solve. -->

View File

@ -5,12 +5,12 @@ labels: bug or enhancement
--- ---
## A Pull Request should be associated with an Issue. ## A Pull Request should be associated with a Discussion.
> If you're fixing a bug, adding a new feature or improving something please provide the details in Issues, > If you're fixing a bug, adding a new feature or improving something please provide the details in discussions,
> so that the development can be pointed in the intended direction. > so that the development can be pointed in the intended direction.
Related issue: <!-- Please link the related issue --> Related discussion: <!-- Please link the related discussion -->
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md) > Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
> Thank you for your contribution. > Thank you for your contribution.
@ -30,7 +30,7 @@ This PR [briefly explain what it does]
> In case this PR edits any scripts: > In case this PR edits any scripts:
- [ ] I have checked the edited scripts for syntax. - [ ] I have checked the edited scripts for syntax.
- [ ] I have tested the changes in an integration test (If yes, provide workflow link). - [ ] I have tested the changes in an integration test (If yes, provide workflow YAML and link).
<!-- <!--
- Please target the develop branch when submitting the pull request. - Please target the develop branch when submitting the pull request.

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.6.x | :white_check_mark: |
## Supported PHP Versions ## Supported PHP Versions

View File

@ -25,7 +25,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest] operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
env: env:
extensions: xml, opcache, xdebug, pcov extensions: xml, opcache, xdebug, pcov
key: cache-v3 key: cache-v3

295
README.md
View File

@ -8,13 +8,17 @@
<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://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></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.1-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 set up 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.
## Contents ## Contents
@ -30,6 +34,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Disable Coverage](#disable-coverage) - [Disable Coverage](#disable-coverage)
- [Usage](#memo-usage) - [Usage](#memo-usage)
- [Inputs](#inputs) - [Inputs](#inputs)
- [Flags](#flags)
- [Basic Setup](#basic-setup) - [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup) - [Matrix Setup](#matrix-setup)
- [Nightly Build Setup](#nightly-build-setup) - [Nightly Build Setup](#nightly-build-setup)
@ -65,12 +70,14 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|`7.3`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`| |`7.3`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|`7.4`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`| |`7.4`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|`8.0`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`| |`8.0`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
|`8.1`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
**Note:** Specifying `8.0` and `8.1` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` and `PHP 8.1.0-dev` respectively. See [nightly build setup](#nightly-build-setup) for more information.
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [nightly build setup](#nightly-build-setup) for more information.
## :cloud: OS/Platform Support ## :cloud: OS/Platform Support
Both `GitHub-hosted` runners and `self-hosted` runners are supported on the following operating systems. The action supports both `GitHub-hosted` runners and `self-hosted` runners on the following operating systems.
### GitHub-Hosted Runners ### GitHub-Hosted Runners
@ -81,6 +88,7 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
|Ubuntu 20.04|`ubuntu-20.04`|`PHP 7.4`| |Ubuntu 20.04|`ubuntu-20.04`|`PHP 7.4`|
|Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 7.4`| |Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 7.4`|
|macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 7.4`| |macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 7.4`|
|macOS Big Sur 11.0|`macos-11.0`|`PHP 7.4`|
### Self-Hosted Runners ### Self-Hosted Runners
@ -92,6 +100,7 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
|Windows 7 and newer|`self-hosted` or `Windows`| |Windows 7 and newer|`self-hosted` or `Windows`|
|Windows Server 2012 R2 and newer|`self-hosted` or `Windows`| |Windows Server 2012 R2 and newer|`self-hosted` or `Windows`|
|macOS Catalina 10.15|`self-hosted` or `macOS`| |macOS Catalina 10.15|`self-hosted` or `macOS`|
|macOS Big Sur 11.0|`self-hosted` or `macOS`|
- Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners. - Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
@ -100,8 +109,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 +126,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 +137,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,52 +148,91 @@ 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
``` ```
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. - 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
```
- 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.
- By default, extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
```yaml
- name: Setup PHP with fail-fast
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: oci8
env:
fail-fast: true
```
## :wrench: Tools Support ## :wrench: Tools Support
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` `behat`, `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`, `phpspec`, `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
``` ```
To setup a particular version of a tool, specify it in the form `tool:version`. - To set up a particular version of a tool, specify it in the form `tool:version`. The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying `v1`, `v2`, `snapshot` or `preview` as versions or the exact version in semver format.
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
``` ```
Version for other tools should be in `semver` format and a valid release of the tool. - If you have specified composer plugins `prestissimo` or `composer-prefetcher` in tools, the latest stable version of `composer v1` will be setup. Unless some of your packages require `composer v1`, it is recommended to drop `prestissimo` and use `composer v2`.
- The 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 set up `PHPUnit` on `PHP 7.2`.
```yaml ```yaml
uses: shivammathur/setup-php@v2 - name: Setup PHP with tools
with: uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
tools: phpunit:8.5.8
```
- By default, tools which cannot be set up gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
```yaml
- name: Setup PHP with fail-fast
uses: shivammathur/setup-php@v2
with:
php-version: '7.4' php-version: '7.4'
tools: php-cs-fixer:2.16.2, phpunit:8.5.1 tools: deployer
env:
fail-fast: true
``` ```
**Notes** **Notes**
- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. - Input `tools` is useful to set up tools which you only use in GitHub Actions, thus keeping your `composer.json` tidy.
- 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 do not want to use all your dev-dependencies in GitHub Actions workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted. - If you have a tool in your `composer.json`, do not setup it with `tools` input as the two instances of the tool might conflict.
## :signal_strength: Coverage Support ## :signal_strength: Coverage Support
@ -191,8 +242,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 +257,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 +287,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
``` ```
@ -233,10 +298,13 @@ with:
### Inputs ### Inputs
> Specify using `with` keyword
#### `php-version` (required) #### `php-version` (required)
- Specify the PHP version you want to setup. - Specify the PHP version you want to set up.
- Accepts a `string`. For example `'7.4'`. - Accepts a `string`. For example `'7.4'`.
- Accepts `latest` to set up the latest stable PHP version.
- See [PHP support](#tada-php-support) for supported PHP versions. - See [PHP support](#tada-php-support) for supported PHP versions.
#### `extensions` (optional) #### `extensions` (optional)
@ -253,16 +321,41 @@ with:
#### `coverage` (optional) #### `coverage` (optional)
- Specify the code coverage driver you want to setup. - Specify the code coverage driver you want to set up.
- Accepts `xdebug`, `pcov` or `none`. - Accepts `xdebug`, `pcov` or `none`.
- See [coverage support](#signal_strength-coverage-support) for more info. - See [coverage support](#signal_strength-coverage-support) for more info.
#### `tools` (optional) #### `tools` (optional)
- Specify the tools you want to setup. - Specify the tools you want to set up.
- Accepts a `string` in csv-format. For example `phpunit, phpcs` - Accepts a `string` in csv-format. For example: `phpunit, phpcs`
- See [tools Support](#wrench-tools-support) for tools supported. - See [tools Support](#wrench-tools-support) for tools supported.
### Flags
> Specify using `env` keyword
#### `fail-fast` (optional)
- Specify to mark the workflow as failed if an extension or tool fails to set up.
- This changes the default mode from graceful warnings to fail-fast.
- By default, it is set to `false`.
- Accepts `true` and `false`.
#### `phpts` (optional)
- Specify to set up thread-safe version of PHP on windows.
- Accepts `ts` and `nts`.
- By default, it is set to `nts`.
- See [thread safe setup](#thread-safe-setup) for more info.
#### `update` (optional)
- Specify to update PHP on the runner to the latest patch version.
- Accepts `true` and `false`.
- By default, it is set to `false`.
- See [force update](#force-update) for more info.
See below for more info. See below for more info.
### Basic Setup ### Basic Setup
@ -313,23 +406,23 @@ jobs:
### Nightly Build Setup ### Nightly Build Setup
> Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP. > Setup a nightly build of `PHP 8.0` or `PHP 8.1`.
- This version is currently in development. - These versions are currently in development.
- `PECL` is installed by default with this version on `ubuntu` and `macOS`. - `PECL` is installed by default with these versions on `ubuntu` and `macOS`.
- Some user space extensions might not support this version currently. - Some user space extensions might not support these versions currently.
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. - Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on these versions.
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version. - Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") for features implemented in `PHP 8.0`.
```yaml ```yaml
steps: 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.1'
extensions: mbstring extensions: mbstring
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1
coverage: pcov coverage: pcov
@ -340,8 +433,8 @@ steps:
> Setup PHP on a self-hosted runner. > Setup PHP on a self-hosted runner.
- To setup a dockerized self-hosted runner, refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Ubuntu) to setup in an `Ubuntu` container and refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows) to setup in a `Windows` container. - To set up a dockerized self-hosted runner, refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Ubuntu) to set up in an `Ubuntu` container and refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows) to set up in a `Windows` container.
- To setup the runner directly on the host OS or in a virtual machine, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner. - To set up the runner directly on the host OS or in a virtual machine, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner.
- If your workflow uses [services](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then setup the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container. - If your workflow uses [services](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then setup the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.
Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail. Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.
@ -367,7 +460,7 @@ jobs:
``` ```
**Notes** **Notes**
- Do not setup multiple self-hosted runners on the a single server instance as parallel workflow will conflict with each other. - Do not setup multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
- Do not setup self-hosted runners on the side on your development environment or your production server. - Do not setup self-hosted runners on the side on your development environment or your production server.
### Local Testing Setup ### Local Testing Setup
@ -407,7 +500,7 @@ act -P ubuntu-16.04=shivammathur/node:xenial
### Thread Safe Setup ### Thread Safe Setup
> Setup both `TS` and `NTS` PHP on `Windows`. > Setup `TS` or `NTS` PHP on `Windows`.
- `NTS` versions are setup by default. - `NTS` versions are setup by default.
- On `Ubuntu` and `macOS` only `NTS` versions are supported. - On `Ubuntu` and `macOS` only `NTS` versions are supported.
@ -432,13 +525,13 @@ jobs:
### Force Update ### Force Update
> Update to latest patch of PHP versions. > Update to the latest patch of PHP versions.
- Pre-installed PHP versions on the GitHub Actions runner are not updated to their latest patch release by default. - Pre-installed PHP versions on the GitHub Actions runner are not updated to their latest patch release by default.
- 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 +546,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'
@ -461,12 +554,12 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.
### Cache Extensions ### Cache Extensions
You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time. You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to set up when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details. Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.
### Cache Composer Dependencies ### Cache Composer Dependencies
If your project uses composer, you can persist composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time. If your project uses composer, you can persist the composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
```yaml ```yaml
- name: Get composer cache directory - name: Get composer cache directory
@ -485,7 +578,7 @@ If your project uses composer, you can persist composer's internal cache directo
``` ```
**Notes** **Notes**
- Please do not cache `vendor` directory using `action/cache` as that will have side-effects. - Please do not cache `vendor` directory using `action/cache` as that will have side effects.
- In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache. - In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
```yaml ```yaml
@ -494,7 +587,7 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
### Cache Node.js Dependencies ### Cache Node.js Dependencies
If your project has node.js dependencies, you can persist npm's or yarn's cache directory. The cached files are available across check-runs and will reduce the workflow execution time. If your project has node.js dependencies, you can persist NPM or yarn cache directory. The cached files are available across check-runs and will reduce the workflow execution time.
```yaml ```yaml
- name: Get node.js cache directory - name: Get node.js cache directory
@ -509,7 +602,7 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache
restore-keys: ${{ runner.os }}-node- restore-keys: ${{ runner.os }}-node-
``` ```
**Note:** Please do not cache `node_modules` directory as that will have side-effects. **Note:** Please do not cache `node_modules` directory as that will have side effects.
### Composer GitHub OAuth ### Composer GitHub OAuth
@ -526,9 +619,11 @@ If you have a number of workflows which setup multiple tools or have many compos
### Problem Matchers ### Problem Matchers
Problem matchers are `json` configurations which identify errors and warnings in your logs and surface them prominently in the GitHub Actions UI by highlighting them and creating code annotations.
#### PHP #### PHP
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHP - name: Setup problem matchers for PHP
@ -537,29 +632,59 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu
#### PHPUnit #### PHPUnit
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHPUnit - name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
``` ```
#### Other Tools #### PHPStan
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code. PHPStan supports error reporting in GitHub Actions, so it does not require problem matchers.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpstan`.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
tools: cs2pr, phpstan tools: phpstan
- name: PHPStan - name: Run PHPStan
run: phpstan analyse src --error-format=checkstyle | cs2pr run: phpstan analyse src
```
#### Psalm
Psalm supports error reporting in GitHub Actions with an output format `github`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: psalm
- name: Run Psalm
run: psalm --output-format=github
```
#### Tools with checkstyle support
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpcs`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: cs2pr, phpcs
- name: Run phpcs
run: phpcs -q --report=checkstyle src | cs2pr
``` ```
### Examples ### Examples
@ -594,15 +719,15 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
## :bookmark: Versioning ## :bookmark: Versioning
- It is highly recommended to use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with latest minor and patch releases. With `v2` you automatically get the bug fixes, new features and support for latest PHP releases. For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases. - Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, new features and support for latest PHP releases. For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
- Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date. - Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date.
- Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes or new features. - Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes or new features.
- Using the `master` branch as version is highly discouraged, it might break your workflow after major releases as they have breaking changes. - It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes.
- If you are using the `v1` tag or a `1.x.y` version, it is recommended that you [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release. - If you are using the `v1` tag or a `1.x.y` version, you should [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release.
## :scroll: License ## :scroll: License
- The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). - The scripts and documentation in this project are under the [MIT License](LICENSE "License for shivammathur/setup-php").
- This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories. - This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
- The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License"). - The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").
@ -613,27 +738,40 @@ 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 contributors" 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>
## :package: Dependencies ## :package: Dependencies
- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies") - [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
- [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
- [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions") - [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions")
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows") - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages") - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
@ -641,6 +779,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

@ -53,6 +53,18 @@ describe('Config tests', () => {
expect(linux).toContain('echo "xdebug.mode=coverage"'); expect(linux).toContain('echo "xdebug.mode=coverage"');
}); });
it('checking addCoverage with Xdebug3 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug3', '8.1', 'linux');
expect(linux).toContain('add_extension xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});
it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.1', 'linux');
expect(linux).toContain('add_extension xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});
it('checking addCoverage with Xdebug on darwin', async () => { it('checking addCoverage with Xdebug on darwin', async () => {
const darwin: string = await coverage.addCoverage( const darwin: string = await coverage.addCoverage(
'xdebug', 'xdebug',

View File

@ -3,7 +3,7 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
'7.4', '7.4',
'win32' 'win32'
); );
@ -18,6 +18,7 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension grpc stable 1.2.3');
expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
expect(win32).toContain('Add-Extension sqlsrv devel 1.2.3');
win32 = await extensions.addExtension('pcov', '5.6', 'win32'); win32 = await extensions.addExtension('pcov', '5.6', 'win32');
expect(win32).toContain( expect(win32).toContain(
@ -70,7 +71,7 @@ describe('Extension tests', () => {
'sudo $debconf_fix apt-get install -y php7.4-sqlite3' 'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
); );
expect(linux).toContain('remove_extension intl'); expect(linux).toContain('remove_extension intl');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-ast');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain('add_pdo_extension mysql'); expect(linux).toContain('add_pdo_extension mysql');
@ -129,13 +130,15 @@ describe('Extension tests', () => {
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension( let darwin: string = await extensions.addExtension(
'Xdebug, pcov, grpc, protobuf, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3', 'Xdebug, pcov, grpc, igbinary, imagick, protobuf, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
'7.2', '7.2',
'darwin' 'darwin'
); );
expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension xdebug');
expect(darwin).toContain('add_brew_extension pcov'); expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('add_brew_extension grpc'); expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension igbinary');
expect(darwin).toContain('add_brew_extension imagick');
expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension swoole'); expect(darwin).toContain('add_brew_extension swoole');
expect(darwin).toContain('pecl_install sqlite3'); expect(darwin).toContain('pecl_install sqlite3');
@ -179,11 +182,7 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('redis', '7.2', 'darwin'); darwin = await extensions.addExtension('redis', '7.2', 'darwin');
expect(darwin).toContain('pecl_install redis'); expect(darwin).toContain('pecl_install redis');
darwin = await extensions.addExtension('imagick', '5.6', 'darwin'); darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('pecl_install imagick');
darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick'); expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('pecl_install imagick'); expect(darwin).toContain('pecl_install imagick');

View File

@ -1,10 +1,11 @@
import * as install from '../src/install'; import * as install from '../src/install';
import * as utils from '../src/utils';
/** /**
* Mock install.ts * Mock install.ts
*/ */
jest.mock('../src/install', () => ({ jest.mock('../src/install', () => ({
build: jest.fn().mockImplementation( getScript: jest.fn().mockImplementation(
async ( async (
filename: string, filename: string,
version: string, version: string,
@ -39,24 +40,18 @@ jest.mock('../src/install', () => ({
run: jest.fn().mockImplementation( run: jest.fn().mockImplementation(
async (): Promise<string> => { async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || ''; const os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || ''; const version: string = await utils.parseVersion(
version = version.length > 1 ? version.slice(0, 3) : version + '.0'; await utils.getInput('php-version', true)
let script = ''; );
switch (os_version) { const tool = await utils.scriptTool(os_version);
case 'darwin': const filename = os_version + (await utils.scriptExtension(os_version));
case 'linux': return [
script = await install.build(os_version + '.sh', version, os_version); await install.getScript(filename, version, os_version),
script += 'bash script.sh ' + version + ' ' + __dirname; tool,
break; filename,
case 'win32': version,
script = await install.build(os_version + '.sh', version, os_version); __dirname
script += 'pwsh script.ps1 ' + version + ' ' + __dirname; ].join(' ');
break;
default:
script += os_version + ' is not supported';
}
return script;
} }
) )
})); }));
@ -93,13 +88,13 @@ describe('Install', () => {
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname); expect(script).toContain('pwsh win32.ps1 7.0 ' + __dirname);
setEnv('7.3', 'win32', '', '', '', ''); setEnv('7.3', 'win32', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); expect(script).toContain('pwsh win32.ps1 7.3 ' + __dirname);
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '');
@ -108,7 +103,7 @@ describe('Install', () => {
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); expect(script).toContain('pwsh win32.ps1 7.3 ' + __dirname);
}); });
it('Test install on linux', async () => { it('Test install on linux', async () => {
@ -116,7 +111,13 @@ describe('Install', () => {
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.3 '); expect(script).toContain('bash linux.sh 7.3 ');
setEnv('latest', 'linux', '', '', '', '');
script = '' + (await install.run());
expect(script).toContain('initial script');
expect(script).toContain('bash linux.sh 7.4 ');
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit'); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit');
@ -125,7 +126,7 @@ describe('Install', () => {
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('bash script.sh 7.3'); expect(script).toContain('bash linux.sh 7.3');
expect(script).toContain('add_tool'); expect(script).toContain('add_tool');
}); });
@ -134,7 +135,7 @@ describe('Install', () => {
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.3 ' + __dirname); expect(script).toContain('bash darwin.sh 7.3 ' + __dirname);
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '');
@ -143,7 +144,7 @@ describe('Install', () => {
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('bash script.sh 7.3 ' + __dirname); expect(script).toContain('bash darwin.sh 7.3 ' + __dirname);
}); });
it('Test malformed version inputs', async () => { it('Test malformed version inputs', async () => {
@ -151,18 +152,24 @@ describe('Install', () => {
let script: string = '' + '' + (await install.run()); let script: string = '' + '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.4 ' + __dirname); expect(script).toContain('bash darwin.sh 7.4 ' + __dirname);
setEnv(8.0, 'darwin', '', '', '', ''); setEnv(8.0, 'darwin', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 8.0 ' + __dirname); expect(script).toContain('bash darwin.sh 8.0 ' + __dirname);
setEnv(8, 'darwin', '', '', '', ''); setEnv(8, 'darwin', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 8.0 ' + __dirname); expect(script).toContain('bash darwin.sh 8.0 ' + __dirname);
setEnv(8.1, 'darwin', '', '', '', '');
script = '' + (await install.run());
expect(script).toContain('initial script');
expect(script).toContain('bash darwin.sh 8.1 ' + __dirname);
}); });
}); });

View File

@ -1,41 +0,0 @@
import * as io from '@actions/io';
import * as matchers from '../src/matchers';
jest.mock('@actions/io');
describe('Matchers', () => {
it('Add matchers', async () => {
process.env['RUNNER_TOOL_CACHE'] = __dirname;
await matchers.addMatchers();
const spy = jest.spyOn(io, 'cp');
expect(spy).toHaveBeenCalledTimes(2);
});
it('Test PHPUnit Regex', async () => {
const regex1 = /^\d+\)\s.*$/;
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
const regex3 = /^\s*$/;
const regex4 = /^(.*):(\d+)$/;
expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true);
expect(regex2.test('Failed asserting that false is true')).toBe(true);
expect(regex3.test('\n')).toBe(true);
expect(regex4.test('/path/to/file.php:42')).toBe(true);
});
it('Test PHP Regex', async () => {
const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/;
const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/;
expect(
regex1.test('PHP Parse error: error_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Notice: info_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Warning: warning_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Deprecated: deprecated_message in file.php on line 10')
).toBe(true);
});
});

View File

@ -187,6 +187,21 @@ describe('Tools tests', () => {
); );
}); });
it('checking getBlackfirePlayerUrl', async () => {
expect(await tools.getBlackfirePlayerUrl('latest', '7.4')).toBe(
'https://get.blackfire.io/blackfire-player.phar'
);
expect(await tools.getBlackfirePlayerUrl('latest', '5.5')).toBe(
'https://get.blackfire.io/blackfire-player-v1.9.3.phar'
);
expect(await tools.getBlackfirePlayerUrl('latest', '7.0')).toBe(
'https://get.blackfire.io/blackfire-player-v1.9.3.phar'
);
expect(await tools.getBlackfirePlayerUrl('1.2.3', '7.0')).toBe(
'https://get.blackfire.io/blackfire-player-v1.2.3.phar'
);
});
it('checking getDeployerUri', async () => { it('checking getDeployerUri', async () => {
expect(await tools.getDeployerUrl('latest')).toBe( expect(await tools.getDeployerUrl('latest')).toBe(
'https://deployer.org/deployer.phar' 'https://deployer.org/deployer.phar'
@ -207,9 +222,17 @@ describe('Tools tests', () => {
'a', 'a',
'b' 'b'
]); ]);
expect(await tools.addComposer(['a', 'b', 'composer:1.2'])).toStrictEqual([
'composer',
'a',
'b'
]);
expect( expect(
await tools.addComposer(['a', 'b', 'composer:1.2.3']) await tools.addComposer(['a', 'b', 'composer:1.2.3'])
).toStrictEqual(['composer', 'a', 'b']); ).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect(
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect( expect(
await tools.addComposer(['a', 'b', 'composer:snapshot']) await tools.addComposer(['a', 'b', 'composer:snapshot'])
).toStrictEqual(['composer:snapshot', 'a', 'b']); ).toStrictEqual(['composer:snapshot', 'a', 'b']);
@ -228,6 +251,9 @@ describe('Tools tests', () => {
expect( expect(
await tools.addComposer(['a', 'b', 'c', 'composer:v2']) await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:2', 'a', 'b', 'c']); ).toStrictEqual(['composer:2', 'a', 'b', 'c']);
expect(
await tools.addComposer(['hirak', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:1', 'hirak', 'b', 'c']);
}); });
it('checking getComposerUrl', async () => { it('checking getComposerUrl', async () => {
@ -249,6 +275,21 @@ describe('Tools tests', () => {
expect(await tools.getComposerUrl('2')).toContain( expect(await tools.getComposerUrl('2')).toContain(
'https://getcomposer.org/composer-2.phar' 'https://getcomposer.org/composer-2.phar'
); );
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
);
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://getcomposer.org/composer-1.7.2.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://getcomposer.org/composer-2.0.0-RC2.phar'
);
expect(await tools.getComposerUrl('wrong')).toContain(
'https://getcomposer.org/composer-stable.phar'
);
}); });
it('checking getSymfonyUri', async () => { it('checking getSymfonyUri', async () => {
@ -277,14 +318,17 @@ describe('Tools tests', () => {
it('checking getCleanedToolsList', async () => { it('checking getCleanedToolsList', async () => {
const tools_list: string[] = await tools.getCleanedToolsList( const tools_list: string[] = await tools.getCleanedToolsList(
'tool, composer:1.2.3, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher' 'tool, composer:1.2, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, phpspec/phpspec, symfony/flex'
); );
expect(tools_list).toStrictEqual([ expect(tools_list).toStrictEqual([
'composer', 'composer',
'tool', 'tool',
'behat',
'composer-unused',
'vapor-cli',
'phinx', 'phinx',
'prestissimo', 'phpspec',
'composer-prefetcher' 'flex'
]); ]);
}); });
@ -301,53 +345,55 @@ describe('Tools tests', () => {
let script: string = await tools.addArchive( let script: string = await tools.addArchive(
'tool', 'tool',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'linux' 'linux',
'-v'
); );
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',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'darwin' 'darwin',
'-v'
); );
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',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'win32' 'win32',
'-v'
); );
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',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'openbsd' 'openbsd',
'-v'
); );
expect(script).toContain('Platform openbsd is not supported'); expect(script).toContain('Platform openbsd is not supported');
}); });
it('checking addDevTools', async () => { it('checking addDevTools', async () => {
let script: string = await tools.addDevTools('phpize', 'linux'); let script: string = await tools.addDevTools('phpize', 'linux');
expect(script).toContain('add_devtools'); expect(script).toContain('add_devtools phpize');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
script = await tools.addDevTools('php-config', 'linux'); script = await tools.addDevTools('php-config', 'linux');
expect(script).toContain('add_devtools'); expect(script).toContain('add_devtools php-config');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
script = await tools.addDevTools('phpize', 'darwin'); script = await tools.addDevTools('phpize', 'darwin');
expect(script).toContain('add_log "$tick" "phpize" "Added"'); expect(script).toContain('add_devtools phpize');
script = await tools.addDevTools('php-config', 'darwin'); script = await tools.addDevTools('php-config', 'darwin');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_devtools php-config');
script = await tools.addDevTools('phpize', 'win32'); script = await tools.addDevTools('phpize', 'win32');
expect(script).toContain( expect(script).toContain(
'Add-Log "$cross" "phpize" "phpize is not a windows tool"' 'Add-Log "$tick" "phpize" "phpize is not a windows tool"'
); );
script = await tools.addDevTools('php-config', 'win32'); script = await tools.addDevTools('php-config', 'win32');
expect(script).toContain( expect(script).toContain(
'Add-Log "$cross" "php-config" "php-config is not a windows tool"' 'Add-Log "$tick" "php-config" "php-config is not a windows tool"'
); );
script = await tools.addDevTools('tool', 'openbsd'); script = await tools.addDevTools('tool', 'openbsd');
@ -381,34 +427,34 @@ describe('Tools tests', () => {
); );
expect(script).toContain('add_blackfire'); expect(script).toContain('add_blackfire');
expect(script).toContain( expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player' 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer' 'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer "-V"'
); );
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 "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://www.phing.info/get/phing-latest.phar phing' 'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.io/releases/phive.phar phive' 'add_tool https://phar.io/releases/phive.phar phive status'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit' 'add_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony version'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli' 'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
); );
expect(script).toContain('add_protoc latest'); expect(script).toContain('add_protoc latest');
expect(script).toContain('add_grpc_php_plugin latest'); expect(script).toContain('add_grpc_php_plugin latest');
@ -417,16 +463,15 @@ describe('Tools tests', () => {
expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain('add_composertool phplint phplint overtrue/'); expect(script).toContain('add_composertool phplint phplint overtrue/');
expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/'); expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/');
expect(script).toContain('add_devtools'); expect(script).toContain('add_devtools php-config');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_devtools phpize');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
}); });
it('checking addTools on darwin', async () => { it('checking addTools on darwin', async () => {
const listOfTools = [ const listOfTools = [
'behat',
'blackfire', 'blackfire',
'blackfire-player', 'blackfire-player',
'composer-normalize', 'composer-normalize',
'composer-prefetcher:1.2.3',
'composer-require-checker', 'composer-require-checker',
'composer-unused', 'composer-unused',
'cs2pr:1.2.3', 'cs2pr:1.2.3',
@ -444,6 +489,7 @@ describe('Tools tests', () => {
'phpcs', 'phpcs',
'phpize', 'phpize',
'phpmd', 'phpmd',
'phpspec',
'protoc:v1.2.3', 'protoc:v1.2.3',
'psalm', 'psalm',
'symfony', 'symfony',
@ -460,72 +506,71 @@ describe('Tools tests', () => {
expect(script).toContain('add_blackfire'); expect(script).toContain('add_blackfire');
expect(script).toContain( expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player' 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize' 'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar composer-require-checker' 'add_tool https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar composer-require-checker "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused' 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr' 'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection' 'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan' 'add_tool https://www.phing.info/get/phing-1.2.3.phar phing "-v"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing' 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs "--version"'
); );
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/phpcbf.phar phpcbf "--version"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf' 'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd "--version"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd' 'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd' 'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"'
);
expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
); );
expect(script).toContain('add_grpc_php_plugin 1.2.3'); expect(script).toContain('add_grpc_php_plugin 1.2.3');
expect(script).toContain('add_protoc 1.2.3'); expect(script).toContain('add_protoc 1.2.3');
expect(script).toContain('add_composertool behat behat behat/');
expect(script).toContain('add_composertool phpspec phpspec phpspec/');
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/'); expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
expect(script).toContain('add_composertool flex flex symfony/'); expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan' 'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan "-v"'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
); );
expect(script).toContain( expect(script).toContain(
'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-' 'add_composertool composer-unused composer-unused icanhazstring/'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony version'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli' 'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
); );
expect(script).toContain('add_log "$tick" "phpize" "Added"'); expect(script).toContain('add_devtools phpize');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_devtools php-config');
}); });
it('checking addTools on windows', async () => { it('checking addTools on windows', async () => {
const listOfTools = [ const listOfTools = [
@ -541,7 +586,6 @@ describe('Tools tests', () => {
'php-config', 'php-config',
'phpize', 'phpize',
'phpmd', 'phpmd',
'prestissimo',
'symfony', 'symfony',
'wp-cli' 'wp-cli'
]; ];
@ -554,31 +598,30 @@ describe('Tools tests', () => {
expect(script).toContain('Add-Blackfire'); expect(script).toContain('Add-Blackfire');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player' 'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player "-V"'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"'
); );
expect(script).toContain('Add-Composertool flex flex symfony/'); expect(script).toContain('Add-Composertool flex flex symfony/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer' 'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
); );
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd' 'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
); );
expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive' 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive status'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony' 'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony version'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli' 'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
); );
expect(script).toContain('phpize is not a windows tool'); expect(script).toContain('phpize is not a windows tool');
expect(script).toContain('php-config is not a windows tool'); expect(script).toContain('php-config is not a windows tool');
@ -598,7 +641,7 @@ describe('Tools tests', () => {
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
); );
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/'); expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
@ -621,7 +664,7 @@ describe('Tools tests', () => {
script = await tools.addTools('composer:preview', '7.4', 'linux'); script = await tools.addTools('composer:preview', '7.4', 'linux');
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'
); );
script = await tools.addTools( script = await tools.addTools(
'composer:v1, composer:preview, composer:snapshot', 'composer:v1, composer:preview, composer:snapshot',
@ -629,7 +672,7 @@ describe('Tools tests', () => {
'linux' 'linux'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'
); );
}); });
}); });

View File

@ -17,23 +17,37 @@ async function cleanup(path: string): Promise<void> {
} }
describe('Utils tests', () => { describe('Utils tests', () => {
it('checking readEnv', async () => {
process.env['test'] = 'setup-php';
expect(await utils.readEnv('test')).toBe('setup-php');
expect(await utils.readEnv('undefined')).toBe('');
});
it('checking getInput', async () => { it('checking getInput', async () => {
process.env['test'] = 'setup-php'; process.env['test'] = 'setup-php';
process.env['undefined'] = '';
expect(await utils.getInput('test', false)).toBe('setup-php'); expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('undefined', false)).toBe('');
expect(await utils.getInput('setup-php', false)).toBe('setup-php'); expect(await utils.getInput('setup-php', false)).toBe('setup-php');
expect(await utils.getInput('DoesNotExist', false)).toBe(''); expect(await utils.getInput('DoesNotExist', false)).toBe('');
expect(async () => {
await utils.getInput('DoesNotExist', true);
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
});
it('checking parseVersion', async () => {
expect(await utils.parseVersion('7')).toBe('7.0');
expect(await utils.parseVersion('7.4')).toBe('7.4');
expect(await utils.parseVersion('latest')).toBe('7.4');
}); });
it('checking asyncForEach', async () => { it('checking asyncForEach', async () => {
const array: Array<string> = ['a', 'b', 'c']; const array: Array<string> = ['a', 'b', 'c'];
let concat = ''; let concat = '';
await utils.asyncForEach(array, async function ( await utils.asyncForEach(
str: string array,
): Promise<void> { async function (str: string): Promise<void> {
concat += str; concat += str;
}); }
);
expect(concat).toBe('abc'); expect(concat).toBe('abc');
}); });
@ -70,12 +84,12 @@ describe('Utils tests', () => {
const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || '';
const script_path: string = path.join(runner_dir, 'test.sh'); const script_path: string = path.join(runner_dir, 'test.sh');
await utils.writeScript('test.sh', testString); await utils.writeScript('test.sh', testString);
await fs.readFile(script_path, function ( await fs.readFile(
error: Error | null, script_path,
data: Buffer function (error: Error | null, data: Buffer) {
) {
expect(testString).toBe(data.toString()); expect(testString).toBe(data.toString());
}); }
);
await cleanup(script_path); await cleanup(script_path);
}); });
@ -196,6 +210,15 @@ describe('Utils tests', () => {
); );
}); });
it('checking scriptTool', async () => {
expect(await utils.scriptTool('linux')).toBe('bash');
expect(await utils.scriptTool('darwin')).toBe('bash');
expect(await utils.scriptTool('win32')).toBe('pwsh');
expect(await utils.scriptTool('openbsd')).toContain(
'Platform openbsd is not supported'
);
});
it('checking customPackage', async () => { it('checking customPackage', async () => {
const script_path: string = path.join('ext', 'pkg.sh'); const script_path: string = path.join('ext', 'pkg.sh');
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain( expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(

401
dist/index.js vendored
View File

@ -953,46 +953,29 @@ class ExecState extends events.EventEmitter {
/***/ }), /***/ }),
/***/ 86: /***/ 82:
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(__unusedmodule, exports) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { // We use any as a valid input type
if (k2 === undefined) k2 = k; /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addMatchers = void 0;
const path = __importStar(__webpack_require__(622));
const utils = __importStar(__webpack_require__(163));
const io = __importStar(__webpack_require__(1));
/** /**
* Cache json files for problem matchers * Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/ */
async function addMatchers() { function toCommandValue(input) {
const config_path = path.join(__dirname, '..', 'src', 'configs'); if (input === null || input === undefined) {
const runner_dir = await utils.getInput('RUNNER_TOOL_CACHE', false); return '';
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir); }
await io.cp(path.join(config_path, 'php.json'), runner_dir); else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
} }
exports.addMatchers = addMatchers; exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map
/***/ }), /***/ }),
@ -1003,6 +986,42 @@ module.exports = require("os");
/***/ }), /***/ }),
/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map
/***/ }),
/***/ 129: /***/ 129:
/***/ (function(module) { /***/ (function(module) {
@ -1030,15 +1049,30 @@ 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;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0; exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.getInput = exports.readEnv = void 0;
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
async function readEnv(property) {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
exports.readEnv = readEnv;
/** /**
* Function to get inputs from both with and env annotations. * Function to get inputs from both with and env annotations.
* *
@ -1046,16 +1080,39 @@ const core = __importStar(__webpack_require__(470));
* @param mandatory * @param mandatory
*/ */
async function getInput(name, mandatory) { async function getInput(name, mandatory) {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, { required: mandatory });
default:
return input; return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
} }
} }
exports.getInput = getInput; exports.getInput = getInput;
/**
* Function to parse PHP version.
*
* @param version
*/
async function parseVersion(version) {
switch (version) {
case 'latest':
return '7.4';
default:
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
}
}
exports.parseVersion = parseVersion;
/** /**
* Async foreach loop * Async foreach loop
* *
@ -1307,6 +1364,23 @@ async function scriptExtension(os_version) {
} }
} }
exports.scriptExtension = scriptExtension; exports.scriptExtension = scriptExtension;
/**
* Function to get script tool
*
* @param os_version
*/
async function scriptTool(os_version) {
switch (os_version) {
case 'win32':
return 'pwsh';
case 'linux':
case 'darwin':
return 'bash';
default:
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}
exports.scriptTool = scriptTool;
/** /**
* Function to get script to add tools with custom support. * Function to get script to add tools with custom support.
* *
@ -1348,6 +1422,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/** /**
* Commands * Commands
* *
@ -1401,28 +1476,14 @@ class Command {
return cmdStr; return cmdStr;
} }
} }
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) { function escapeData(s) {
return toCommandValue(s) return utils_1.toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A'); .replace(/\n/g, '%0A');
} }
function escapeProperty(s) { function escapeProperty(s) {
return toCommandValue(s) return utils_1.toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
@ -1456,6 +1517,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431); const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87)); const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
/** /**
@ -1482,9 +1545,17 @@ var ExitCode;
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) { function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val); const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal; process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal); command_1.issueCommand('set-env', { name }, convertedVal);
}
} }
exports.exportVariable = exportVariable; exports.exportVariable = exportVariable;
/** /**
@ -1500,7 +1571,13 @@ exports.setSecret = setSecret;
* @param inputPath * @param inputPath
*/ */
function addPath(inputPath) { function addPath(inputPath) {
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath); command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
} }
exports.addPath = addPath; exports.addPath = addPath;
@ -1682,12 +1759,12 @@ 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;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0; exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getBlackfirePlayerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0;
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/** /**
* Function to get tool version * Function to get tool version
@ -1837,14 +1914,14 @@ async function addPhive(version, os_version) {
switch (version) { switch (version) {
case 'latest': case 'latest':
return ((await utils.getCommand(os_version, 'tool')) + return ((await utils.getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive'); 'https://phar.io/releases/phive.phar phive status');
default: default:
return ((await utils.getCommand(os_version, 'tool')) + return ((await utils.getCommand(os_version, 'tool')) +
'https://github.com/phar-io/phive/releases/download/' + 'https://github.com/phar-io/phive/releases/download/' +
version + version +
'/phive-' + '/phive-' +
version + version +
'.phar phive'); '.phar phive status');
} }
} }
exports.addPhive = addPhive; exports.addPhive = addPhive;
@ -1865,6 +1942,23 @@ async function getPharUrl(domain, tool, prefix, version) {
} }
} }
exports.getPharUrl = getPharUrl; exports.getPharUrl = getPharUrl;
/**
* Function to get blackfire player url for a PHP version.
*
* @param version
* @param php_version
*/
async function getBlackfirePlayerUrl(version, php_version) {
switch (true) {
case /5\.[5-6]|7\.0/.test(php_version) && version == 'latest':
version = '1.9.3';
break;
default:
break;
}
return await getPharUrl('https://get.blackfire.io', 'blackfire-player', 'v', version);
}
exports.getBlackfirePlayerUrl = getBlackfirePlayerUrl;
/** /**
* Function to get the Deployer url * Function to get the Deployer url
* *
@ -1928,15 +2022,19 @@ exports.getWpCliUrl = getWpCliUrl;
*/ */
async function addComposer(tools_list) { async function addComposer(tools_list) {
const regex_any = /^composer($|:.*)/; const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/; const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches = tools_list.filter(tool => regex_valid.test(tool)); const matches = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer'; let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool)); tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) { switch (true) {
case undefined: case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break; break;
default: default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1'); composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
break; break;
} }
tools_list.unshift(composer); tools_list.unshift(composer);
@ -1949,18 +2047,17 @@ exports.addComposer = addComposer;
* @param version * @param version
*/ */
async function getComposerUrl(version) { async function getComposerUrl(version) {
const cache_url = 'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace('latest', 'stable')}.phar`;
version.replace('latest', 'stable') + switch (true) {
'.phar,'; case /^snapshot$/.test(version):
switch (version) { return `${cache_url},https://getcomposer.org/composer.phar`;
case 'snapshot': case /^preview$|^[1-2]$/.test(version):
return cache_url + 'https://getcomposer.org/composer.phar'; return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
case 'preview': case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
case '1': cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
case '2': return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
return (cache_url + 'https://getcomposer.org/composer-' + version + '.phar');
default: default:
return cache_url + 'https://getcomposer.org/composer-stable.phar'; return `${cache_url},https://getcomposer.org/composer-stable.phar`;
} }
} }
exports.getComposerUrl = getComposerUrl; exports.getComposerUrl = getComposerUrl;
@ -1976,7 +2073,7 @@ async function getCleanedToolsList(tools_csv) {
.map(function (extension) { .map(function (extension) {
return extension return extension
.trim() .trim()
.replace(/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, ''); .replace(/-agent|behat\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//, '');
}) })
.filter(Boolean); .filter(Boolean);
return [...new Set(tools_list)]; return [...new Set(tools_list)];
@ -1988,9 +2085,11 @@ exports.getCleanedToolsList = getCleanedToolsList;
* @param tool * @param tool
* @param url * @param url
* @param os_version * @param os_version
* @param ver_param
*/ */
async function addArchive(tool, url, os_version) { async function addArchive(tool, url, os_version, ver_param) {
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; return ((await utils.getCommand(os_version, 'tool')) +
(await utils.joins(url, tool, ver_param)));
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
/** /**
@ -2002,13 +2101,10 @@ exports.addArchive = addArchive;
async function addDevTools(tool, os_version) { async function addDevTools(tool, os_version) {
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
return ('add_devtools' +
'\n' +
(await utils.addLog('$tick', tool, 'Added', 'linux')));
case 'darwin': case 'darwin':
return await utils.addLog('$tick', tool, 'Added', 'darwin'); return 'add_devtools ' + tool;
case 'win32': case 'win32':
return await utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32'); return await utils.addLog('$tick', tool, tool + ' is not a windows tool', 'win32');
default: default:
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }
@ -2051,24 +2147,28 @@ async function addTools(tools_csv, php_version, os_version) {
case 'protoc': case 'protoc':
script += await utils.customPackage(tool, 'tools', version, os_version); script += await utils.customPackage(tool, 'tools', version, os_version);
break; break;
case 'behat':
case 'phpspec':
script += await addPackage(tool, release, tool + '/', os_version);
break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getBlackfirePlayerUrl(version, php_version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', url, os_version); script += await addArchive('composer', url, os_version, 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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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);
@ -2076,39 +2176,37 @@ 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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'composer-unused': case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); script += await addPackage(tool, release, 'icanhazstring/', os_version);
url = github + 'composer-unused/composer-unused/' + uri;
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
break; break;
case 'phing': case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar'; url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -2123,48 +2221,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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"--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, url, os_version); script += await addArchive(tool, url, os_version, '"--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, url, os_version); script += await addArchive(tool, url, os_version, '"--version"');
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
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', url, os_version); script += await addArchive('symfony', url, os_version, '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, url, os_version); script += await addArchive(tool, url, os_version, '"--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);
@ -2212,7 +2310,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;
}; };
@ -2236,7 +2334,7 @@ async function addCoverageXdebug(extension, version, os_version, pipe) {
const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version); const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version);
switch (true) { switch (true) {
case /^xdebug3$/.test(extension): case /^xdebug3$/.test(extension):
case /^8\.0$/.test(version): case /^8\.\d$/.test(version):
return '\n' + xdebug + '\n' + ini + '\n' + log; return '\n' + xdebug + '\n' + ini + '\n' + log;
case /^xdebug$/.test(extension): case /^xdebug$/.test(extension):
default: default:
@ -2355,7 +2453,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;
}; };
@ -2448,12 +2546,12 @@ 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;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.build = void 0; exports.run = exports.getScript = void 0;
const exec_1 = __webpack_require__(986); const exec_1 = __webpack_require__(986);
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const config = __importStar(__webpack_require__(641)); const config = __importStar(__webpack_require__(641));
@ -2461,7 +2559,6 @@ const coverage = __importStar(__webpack_require__(635));
const extensions = __importStar(__webpack_require__(911)); const extensions = __importStar(__webpack_require__(911));
const tools = __importStar(__webpack_require__(534)); const tools = __importStar(__webpack_require__(534));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
const matchers = __importStar(__webpack_require__(86));
/** /**
* Build the script * Build the script
* *
@ -2469,17 +2566,15 @@ const matchers = __importStar(__webpack_require__(86));
* @param version * @param version
* @param os_version * @param os_version
*/ */
async function build(filename, version, os_version) { async function getScript(filename, version, os_version) {
const name = 'setup-php';
const url = 'https://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));
const ini_values_csv = await utils.getInput('ini-values', false); const ini_values_csv = await utils.getInput('ini-values', false);
const coverage_driver = await utils.getInput('coverage', false); const coverage_driver = await utils.getInput('coverage', false);
const pecl = await utils.getInput('pecl', false);
let tools_csv = await utils.getInput('tools', false); let tools_csv = await utils.getInput('tools', false);
if (pecl == 'true' || if (/.*-(beta|alpha|devel|snapshot|\d+\.\d+\.\d+).*/.test(extension_csv)) {
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) ||
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)) {
tools_csv = 'pecl, ' + tools_csv; tools_csv = 'pecl, ' + tools_csv;
} }
let script = await utils.readScript(filename); let script = await utils.readScript(filename);
@ -2493,31 +2588,23 @@ 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.getScript = getScript;
/** /**
* Run the script * Run the script
*/ */
async function run() { async function run() {
try { try {
let version = await utils.getInput('php-version', true); const version = await utils.parseVersion(await utils.getInput('php-version', true));
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const os_version = process.platform; const os_version = process.platform;
// check the os version and run the respective script const tool = await utils.scriptTool(os_version);
let script_path = ''; const script = os_version + (await utils.scriptExtension(os_version));
switch (os_version) { const location = await getScript(script, version, os_version);
case 'darwin': const fail_fast = await utils.readEnv('fail-fast');
case 'linux': await exec_1.exec(await utils.joins(tool, location, version, __dirname, fail_fast));
script_path = await build(os_version + '.sh', version, os_version);
await exec_1.exec('bash ' + script_path + ' ' + version + ' ' + __dirname);
break;
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break;
}
await matchers.addMatchers();
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -2766,7 +2853,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;
}; };
@ -2796,7 +2883,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
remove_script += '\nremove_extension ' + ext_name.slice(1); remove_script += '\nremove_extension ' + ext_name.slice(1);
return; return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
@ -2818,11 +2905,11 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin'); add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.9xdebug, 5.6igbinary to 8.9igbinary
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6imagick to 7.4imagick, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole
// match 7.1pcov to 8.0pcov // match 7.1pcov to 8.9pcov
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; command = 'add_brew_extension ' + ext_name;
break; break;
@ -2830,8 +2917,8 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8'; command = command_prefix + 'redis-2.2.8';
break; break;
// match imagick // match 5.4imagick and 5.5imagick
case /^imagick$/.test(extension): case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe); command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe);
break; break;
// match sqlite // match sqlite
@ -2868,7 +2955,7 @@ async function addExtensionWindows(extension_csv, version) {
remove_script += '\nRemove-Extension ' + ext_name.slice(1); remove_script += '\nRemove-Extension ' + ext_name.slice(1);
break; break;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
@ -2887,9 +2974,9 @@ async function addExtensionWindows(extension_csv, version) {
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version); add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
break; break;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension): case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension); matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec(version_extension);
add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2], matches[1]); add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]);
break; break;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
@ -2902,9 +2989,9 @@ async function addExtensionWindows(extension_csv, version) {
add_script += add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.9mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.9mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.9mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
@ -2944,7 +3031,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
remove_script += '\nremove_extension ' + ext_name.slice(1); remove_script += '\nremove_extension ' + ext_name.slice(1);
return; return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
@ -2976,7 +3063,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
add_script += add_script +=
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'; '\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
return; return;
// match 8.0xdebug3 // match 8.0xdebug3...8.9xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension): case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug'; extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
@ -2986,8 +3073,8 @@ async function addExtensionLinux(extension_csv, version, pipe) {
extension = extension.replace(/pdo[_-]|3/, ''); extension = extension.replace(/pdo[_-]|3/, '');
add_script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match ast and uopz // match uopz
case /^(ast|uopz)$/.test(extension): case /^(uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe; command = command_prefix + '-' + extension + pipe;
break; break;
// match sqlite // match sqlite

1660
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.4.3", "version": "2.7.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",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"lint": "eslint **/*.ts --cache", "lint": "eslint **/*.ts --cache --fix",
"format": "prettier --write **/*.ts && git add .", "format": "prettier --write **/*.ts && git add .",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"release": "ncc build src/install.ts -o dist && git add -f dist/", "release": "ncc build src/install.ts -o dist && git add -f dist/",
@ -24,28 +24,28 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.4", "@actions/core": "^1.2.6",
"@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.14",
"@types/node": "^14.6.0", "@types/node": "^14.11.10",
"@typescript-eslint/eslint-plugin": "^3.9.1", "@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^3.9.1", "@typescript-eslint/parser": "^4.4.1",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.7.0", "eslint": "^7.11.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.13.0",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^23.20.0", "eslint-plugin-jest": "^24.1.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5", "husky": "^4.3.0",
"jest": "^26.4.0", "jest": "^26.6.0",
"jest-circus": "^26.4.0", "jest-circus": "^26.6.0",
"prettier": "^2.0.5", "prettier": "^2.1.2",
"ts-jest": "^26.2.0", "ts-jest": "^26.4.1",
"typescript": "^3.9.7" "typescript": "^4.0.3"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,

View File

@ -32,7 +32,7 @@ export async function addCoverageXdebug(
); );
switch (true) { switch (true) {
case /^xdebug3$/.test(extension): case /^xdebug3$/.test(extension):
case /^8\.0$/.test(version): case /^8\.\d$/.test(version):
return '\n' + xdebug + '\n' + ini + '\n' + log; return '\n' + xdebug + '\n' + ini + '\n' + log;
case /^xdebug$/.test(extension): case /^xdebug$/.test(extension):
default: default:

View File

@ -27,7 +27,7 @@ export async function addExtensionDarwin(
remove_script += '\nremove_extension ' + ext_name.slice(1); remove_script += '\nremove_extension ' + ext_name.slice(1);
return; return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
@ -66,11 +66,13 @@ export async function addExtensionDarwin(
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin'); add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.9xdebug, 5.6igbinary to 8.9igbinary
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6imagick to 7.4imagick, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole
// match 7.1pcov to 8.0pcov // match 7.1pcov to 8.9pcov
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(
version_extension
):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; command = 'add_brew_extension ' + ext_name;
break; break;
@ -78,8 +80,8 @@ export async function addExtensionDarwin(
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8'; command = command_prefix + 'redis-2.2.8';
break; break;
// match imagick // match 5.4imagick and 5.5imagick
case /^imagick$/.test(extension): case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins( command = await utils.joins(
'brew install pkg-config imagemagick' + pipe, 'brew install pkg-config imagemagick' + pipe,
'&& ' + command_prefix + 'imagick' + pipe '&& ' + command_prefix + 'imagick' + pipe
@ -127,7 +129,7 @@ export async function addExtensionWindows(
remove_script += '\nRemove-Extension ' + ext_name.slice(1); remove_script += '\nRemove-Extension ' + ext_name.slice(1);
break; break;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
@ -162,16 +164,14 @@ export async function addExtensionWindows(
); );
break; break;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test( case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension):
version_extension matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec(
):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(
version_extension version_extension
) as RegExpExecArray; ) as RegExpExecArray;
add_script += await utils.joins( add_script += await utils.joins(
'\nAdd-Extension', '\nAdd-Extension',
ext_name, ext_name,
matches[2], matches[2].replace('preview', 'devel'),
matches[1] matches[1]
); );
break; break;
@ -186,9 +186,9 @@ export async function addExtensionWindows(
add_script += add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.9mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.9mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.9mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
@ -232,7 +232,7 @@ export async function addExtensionLinux(
remove_script += '\nremove_extension ' + ext_name.slice(1); remove_script += '\nremove_extension ' + ext_name.slice(1);
return; return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-(semver)...5.6blackfire-(semver), 7.0blackfire-(semver)...7.4blackfire-(semver)
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
@ -285,7 +285,7 @@ export async function addExtensionLinux(
add_script += add_script +=
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'; '\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
return; return;
// match 8.0xdebug3 // match 8.0xdebug3...8.9xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension): case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug'; extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
@ -295,8 +295,8 @@ export async function addExtensionLinux(
extension = extension.replace(/pdo[_-]|3/, ''); extension = extension.replace(/pdo[_-]|3/, '');
add_script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match ast and uopz // match uopz
case /^(ast|uopz)$/.test(extension): case /^(uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe; command = command_prefix + '-' + extension + pipe;
break; break;
// match sqlite // match sqlite

View File

@ -5,7 +5,6 @@ import * as coverage from './coverage';
import * as extensions from './extensions'; import * as extensions from './extensions';
import * as tools from './tools'; import * as tools from './tools';
import * as utils from './utils'; import * as utils from './utils';
import * as matchers from './matchers';
/** /**
* Build the script * Build the script
@ -14,24 +13,19 @@ import * as matchers from './matchers';
* @param version * @param version
* @param os_version * @param os_version
*/ */
export async function build( export async function getScript(
filename: string, filename: string,
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
const name = 'setup-php';
const url = 'https://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)) ||
(await utils.getInput('extension', false));
const ini_values_csv: string = await utils.getInput('ini-values', false); const ini_values_csv: string = await utils.getInput('ini-values', false);
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
const pecl: string = await utils.getInput('pecl', false);
let tools_csv: string = await utils.getInput('tools', false); let tools_csv: string = await utils.getInput('tools', false);
if ( if (/.*-(beta|alpha|devel|snapshot|\d+\.\d+\.\d+).*/.test(extension_csv)) {
pecl == 'true' ||
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) ||
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)
) {
tools_csv = 'pecl, ' + tools_csv; tools_csv = 'pecl, ' + tools_csv;
} }
@ -48,6 +42,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);
} }
@ -56,24 +53,17 @@ export async function build(
*/ */
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
let version: string = await utils.getInput('php-version', true); const version: string = await utils.parseVersion(
version = version.length > 1 ? version.slice(0, 3) : version + '.0'; await utils.getInput('php-version', true)
);
const os_version: string = process.platform; const os_version: string = process.platform;
const tool = await utils.scriptTool(os_version);
// check the os version and run the respective script const script = os_version + (await utils.scriptExtension(os_version));
let script_path = ''; const location = await getScript(script, version, os_version);
switch (os_version) { const fail_fast = await utils.readEnv('fail-fast');
case 'darwin': await exec(
case 'linux': await utils.joins(tool, location, version, __dirname, fail_fast)
script_path = await build(os_version + '.sh', version, os_version); );
await exec('bash ' + script_path + ' ' + version + ' ' + __dirname);
break;
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break;
}
await matchers.addMatchers();
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

View File

@ -1,13 +0,0 @@
import * as path from 'path';
import * as utils from './utils';
import * as io from '@actions/io';
/**
* Cache json files for problem matchers
*/
export async function addMatchers(): Promise<void> {
const config_path = path.join(__dirname, '..', 'src', 'configs');
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
await io.cp(path.join(config_path, 'php.json'), runner_dir);
}

View File

@ -13,6 +13,7 @@ add_log() {
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
[ "$fail_fast" = "true" ] && exit 1;
fi fi
} }
@ -67,10 +68,10 @@ check_extension() {
fi fi
} }
# Fuction to get the PECL version. # Function to get the PECL version.
get_pecl_version() { get_pecl_version() {
extension=$1 extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/' pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)") pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
@ -91,7 +92,7 @@ add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
@ -152,16 +153,35 @@ configure_composer() {
exit 1 exit 1
fi fi
composer -q global config process-timeout 0 composer -q global config process-timeout 0
echo "::add-path::/Users/$USER/.composer/vendor/bin" echo "$composer_bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi fi
} }
# Function to extract tool version.
get_tool_version() {
tool=$1
param=$2
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
if [ "$tool" = "composer" ]; then
if [ "$param" != "snapshot" ]; then
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
else
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
echo "$trunk+$commit"
fi
else
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi
}
# Function to setup a remote tool. # Function to setup a remote tool.
add_tool() { add_tool() {
url=$1 url=$1
tool=$2 tool=$2
ver_param=$3
tool_path="$tool_path_dir/$tool" tool_path="$tool_path_dir/$tool"
if [ ! -e "$tool_path" ]; then if [ ! -e "$tool_path" ]; then
rm -rf "$tool_path" rm -rf "$tool_path"
@ -191,7 +211,8 @@ add_tool() {
elif [ "$tool" = "wp-cli" ]; then elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi fi
add_log "$tick" "$tool" "Added" tool_version=$(get_tool_version "$tool" "$ver_param")
add_log "$tick" "$tool" "Added $tool $tool_version"
else else
add_log "$cross" "$tool" "Could not setup $tool" add_log "$cross" "$tool" "Could not setup $tool"
fi fi
@ -203,8 +224,20 @@ add_composertool() {
release=$2 release=$2
prefix=$3 prefix=$3
( (
composer global require "$prefix$release" >/dev/null 2>&1 && add_log "$tick" "$tool" "Added" composer global require "$prefix$release" >/dev/null 2>&1 &&
json=$(grep "$prefix$tool" /Users/"$USER"/.composer/composer.json) &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
if [ -e "$composer_bin/composer" ]; then
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
fi
}
# Function to handle request to add phpize and php-config.
add_devtools() {
tool=$1
add_log "$tick" "$tool" "Added $tool $semver"
} }
# Function to configure PECL # Function to configure PECL
@ -217,7 +250,19 @@ configure_pecl() {
# Function to handle request to add PECL. # Function to handle request to add PECL.
add_pecl() { add_pecl() {
add_log "$tick" "PECL" "Added" pecl_version=$(get_tool_version "pecl" "version")
add_log "$tick" "PECL" "Found PECL $pecl_version"
}
# Function to update dependencies.
update_dependencies() {
if [[ "$version" =~ $nightly_versions ]] && [ "$runner" != "self-hosted" ]; then
while read -r formula; do
curl -o "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
to_wait+=( $! )
done < "$(brew --prefix)/Homebrew/Library/Taps/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
wait "${to_wait[@]}"
fi
} }
# Function to setup PHP 5.6 and newer. # Function to setup PHP 5.6 and newer.
@ -225,10 +270,11 @@ setup_php() {
action=$1 action=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap --shallow shivammathur/homebrew-php brew tap --shallow shivammathur/homebrew-php
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then update_dependencies
brew unlink php@"$version" if ! [[ "$(find "$(brew --cellar)"/php/ -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]] && [ "$action" != "upgrade" ]; then
brew unlink shivammathur/php/php@"$version"
else else
brew "$action" shivammathur/php/php@"$version" brew upgrade "shivammathur/php/php@$version" 2>/dev/null || brew install "shivammathur/php/php@$version"
fi fi
brew link --force --overwrite php@"$version" brew link --force --overwrite php@"$version"
} }
@ -237,8 +283,12 @@ setup_php() {
tick="✓" tick="✓"
cross="✗" cross="✗"
version=$1 version=$1
dist=$2
fail_fast=$3
nodot_version=${1/./} nodot_version=${1/./}
nightly_versions="8.[0-1]"
old_versions="5.[3-5]" old_versions="5.[3-5]"
composer_bin="/Users/$USER/.composer/vendor/bin"
tool_path_dir="/usr/local/bin" tool_path_dir="/usr/local/bin"
curl_opts=(-sL) curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
@ -272,7 +322,8 @@ sudo chmod 777 "$ini_file" "$tool_path_dir"
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file" echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -p "$ext_dir" sudo mkdir -m 777 -p "$ext_dir" "/Users/$USER/.composer"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ') semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "$tick" "PHP" "$status PHP $semver"

View File

@ -9,10 +9,11 @@ add_license_log() {
# Function to get the tag for a php version. # Function to get the tag for a php version.
get_tag() { get_tag() {
master_version='8.0'
tag='master' tag='master'
if [ ! "${version:?}" = "$master_version" ]; then if ! [[ ${version:?} =~ $nightly_versions ]]; then
tag="php-$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')" tag="php-$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')"
elif [ "${version:?}" = '8.0' ]; then
tag="PHP-8.0"
fi fi
echo "$tag" echo "$tag"
} }
@ -72,18 +73,23 @@ restore_phpize() {
# Function to patch pdo_oci. # Function to patch pdo_oci.
patch_pdo_oci_config() { patch_pdo_oci_config() {
curl -O "${curl_opts[@]}" https://raw.githubusercontent.com/php/php-src/master/ext/pdo_oci/config.m4 curl -O "${curl_opts[@]}" https://raw.githubusercontent.com/php/php-src/PHP-8.0/ext/pdo_oci/config.m4
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4 if [[ ${version:?} =~ 5.[3-6] ]]; then
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
fi
} }
# Function to install the dependencies. # Function to install the dependencies.
add_dependencies() { add_dependencies() {
if [ "$os" = 'Linux' ]; then if [ "$os" = 'Linux' ]; then
if [ "${runner:?}" = "self-hosted" ]; then if [ "${runner:?}" = "self-hosted" ]; then
${apt_install:?} autoconf automake libaio-dev gcc g++ php"$version"-dev if ! [[ ${version:?} =~ $nightly_versions ]]; then
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++ php"$version"-dev
else else
update_lists ${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++
${apt_install:?} php"$version"-dev fi
else
! [[ ${version:?} =~ $nightly_versions ]] && update_lists && ${apt_install:?} --no-upgrade --no-install-recommends php"$version"-dev
fi fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" sudo update-alternatives --set php-config /usr/bin/php-config"$version"
sudo update-alternatives --set phpize /usr/bin/phpize"$version" sudo update-alternatives --set phpize /usr/bin/phpize"$version"
@ -117,6 +123,7 @@ add_oci() {
oracle_home='/opt/oracle' oracle_home='/opt/oracle'
oracle_client=$oracle_home/instantclient oracle_client=$oracle_home/instantclient
os=$(uname -s) os=$(uname -s)
nightly_versions='8.[0-1]'
add_client >/dev/null 2>&1 add_client >/dev/null 2>&1
add_dependencies >/dev/null 2>&1 add_dependencies >/dev/null 2>&1
add_oci_helper >/dev/null 2>&1 add_oci_helper >/dev/null 2>&1

View File

@ -3,7 +3,11 @@ add_phalcon_helper() {
status='Installed and enabled' status='Installed and enabled'
if [ "$os_name" = "Linux" ]; then if [ "$os_name" = "Linux" ]; then
update_lists update_lists
if [ "$extension" = "phalcon4" ]; then
${apt_install:?} "php${version:?}-psr" "php${version:?}-$extension"
else
${apt_install:?} "php${version:?}-$extension" ${apt_install:?} "php${version:?}-$extension"
fi
else else
phalcon_ini_file=${ini_file:?} phalcon_ini_file=${ini_file:?}
sed -i '' '/extension.*psr/d' "${ini_file:?}" sed -i '' '/extension.*psr/d' "${ini_file:?}"

View File

@ -13,6 +13,7 @@ add_log() {
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message" printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
[ "$fail_fast" = "true" ] && exit 1;
fi fi
} }
@ -42,7 +43,7 @@ cleanup_lists() {
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 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/ 2>/dev/null" exit
fi fi
} }
@ -69,7 +70,6 @@ update_lists() {
# Function to setup environment for self-hosted runners. # Function to setup environment for self-hosted runners.
self_hosted_setup() { self_hosted_setup() {
echo "Set disable_coredump false" | sudo tee -a /etc/sudo.conf
if ! command -v apt-fast >/dev/null; then if ! command -v apt-fast >/dev/null; then
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
fi fi
@ -89,10 +89,10 @@ configure_pecl() {
fi fi
} }
# Fuction to get the PECL version of an extension. # Function to get the PECL version of an extension.
get_pecl_version() { get_pecl_version() {
extension=$1 extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/' pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)") pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
@ -153,7 +153,7 @@ enable_extension() {
fi fi
} }
# Funcion to add PDO extension. # Function to add PDO extension.
add_pdo_extension() { add_pdo_extension() {
pdo_ext="pdo_$1" pdo_ext="pdo_$1"
if check_extension "$pdo_ext"; then if check_extension "$pdo_ext"; then
@ -186,8 +186,12 @@ add_extension() {
if [[ "$version" =~ 5.[4-5] ]]; then if [[ "$version" =~ 5.[4-5] ]]; then
install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}" install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
fi fi
if [[ "$version" =~ $nightly_versions ]]; then
pecl_install "$extension"
else
eval "$install_command" >/dev/null 2>&1 || eval "$install_command" >/dev/null 2>&1 ||
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension" (update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension"
fi
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
sudo chmod 777 "$ini_file" sudo chmod 777 "$ini_file"
@ -198,7 +202,7 @@ add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
@ -231,7 +235,7 @@ add_extension_from_source() {
args=$4 args=$4
prefix=$5 prefix=$5
( (
add_devtools add_devtools phpize
delete_extension "$extension" delete_extension "$extension"
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz
tar xf /tmp/"$extension".tar.gz -C /tmp tar xf /tmp/"$extension".tar.gz -C /tmp
@ -252,16 +256,35 @@ configure_composer() {
exit 1; exit 1;
fi fi
composer -q global config process-timeout 0 composer -q global config process-timeout 0
echo "::add-path::/home/$USER/.composer/vendor/bin" echo "$composer_bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi fi
} }
# Function to extract tool version.
get_tool_version() {
tool=$1
param=$2
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
if [ "$tool" = "composer" ]; then
if [ "$param" != "snapshot" ]; then
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
else
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
echo "$trunk+$commit"
fi
else
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi
}
# Function to setup a remote tool. # Function to setup a remote tool.
add_tool() { add_tool() {
url=$1 url=$1
tool=$2 tool=$2
ver_param=$3
tool_path="$tool_path_dir/$tool" tool_path="$tool_path_dir/$tool"
if [ ! -e "$tool_path" ]; then if [ ! -e "$tool_path" ]; then
rm -rf "$tool_path" rm -rf "$tool_path"
@ -289,7 +312,8 @@ add_tool() {
elif [ "$tool" = "wp-cli" ]; then elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi fi
add_log "$tick" "$tool" "Added" tool_version=$(get_tool_version "$tool" "$ver_param")
add_log "$tick" "$tool" "Added $tool $tool_version"
else else
add_log "$cross" "$tool" "Could not setup $tool" add_log "$cross" "$tool" "Could not setup $tool"
fi fi
@ -302,23 +326,30 @@ add_composertool() {
prefix=$3 prefix=$3
( (
composer global require "$prefix$release" >/dev/null 2>&1 && composer global require "$prefix$release" >/dev/null 2>&1 &&
add_log "$tick" "$tool" "Added" json=$(grep "$prefix$tool" /home/"$USER"/.composer/composer.json) &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
if [ -e "$composer_bin/composer" ]; then
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
fi
} }
# Function to setup phpize and php-config. # Function to setup phpize and php-config.
add_devtools() { add_devtools() {
tool=$1
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1 $apt_install --no-upgrade php"$version"-dev php"$version"-xml >/dev/null 2>&1 || update_lists && $apt_install --no-upgrade php"$version"-dev php"$version"-xml >/dev/null 2>&1
fi fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1 sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1 sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
configure_pecl >/dev/null 2>&1 configure_pecl >/dev/null 2>&1
add_log "$tick" "$tool" "Added $tool $semver"
} }
# Function to setup the nightly build from master branch. # Function to setup the nightly build from shivammathur/php-builder
setup_master() { setup_nightly() {
curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner" curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner" "$version"
} }
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5. # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
@ -330,12 +361,13 @@ setup_old_versions() {
# Function to add PECL. # Function to add PECL.
add_pecl() { add_pecl() {
add_devtools >/dev/null 2>&1 add_devtools phpize >/dev/null 2>&1
if [ ! -e /usr/bin/pecl ]; then if [ ! -e /usr/bin/pecl ]; then
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1 $apt_install --no-upgrade php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1
fi fi
configure_pecl >/dev/null 2>&1 configure_pecl >/dev/null 2>&1
add_log "$tick" "PECL" "Added" pecl_version=$(get_tool_version "pecl" "version")
add_log "$tick" "PECL" "Added PECL $pecl_version"
} }
# Function to switch versions of PHP binaries. # Function to switch versions of PHP binaries.
@ -349,7 +381,7 @@ switch_version() {
# Function to get PHP version in semver format. # Function to get PHP version in semver format.
php_semver() { php_semver() {
if [ ! "$version" = "$master_version" ]; then if ! [[ "$version" =~ $nightly_versions ]]; then
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-' php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
else else
php -v | head -n 1 | cut -f 2 -d ' ' php -v | head -n 1 | cut -f 2 -d ' '
@ -382,8 +414,8 @@ update_php() {
# Function to install PHP. # Function to install PHP.
add_php() { add_php() {
if [ "$version" = "$master_version" ]; then if [[ "$version" =~ $nightly_versions ]]; then
setup_master setup_nightly
elif [[ "$version" =~ $old_versions ]]; then elif [[ "$version" =~ $old_versions ]]; then
setup_old_versions setup_old_versions
else else
@ -397,12 +429,15 @@ tick="✓"
cross="✗" cross="✗"
pecl_config="false" pecl_config="false"
version=$1 version=$1
master_version="8.0" dist=$2
fail_fast=$3
nightly_versions="8.[0-1]"
old_versions="5.[3-5]" old_versions="5.[3-5]"
debconf_fix="DEBIAN_FRONTEND=noninteractive" debconf_fix="DEBIAN_FRONTEND=noninteractive"
github="https://github.com/shivammathur" github="https://github.com/shivammathur"
apt_install="sudo $debconf_fix apt-fast install -y" apt_install="sudo $debconf_fix apt-get install -y"
apt_remove="sudo $debconf_fix apt-fast remove -y" apt_remove="sudo $debconf_fix apt-get remove -y"
composer_bin="/home/$USER/.composer/vendor/bin"
tool_path_dir="/usr/local/bin" tool_path_dir="/usr/local/bin"
curl_opts=(-sL) curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
@ -419,7 +454,7 @@ fi
# Setup PHP # Setup PHP
step_log "Setup PHP" step_log "Setup PHP"
sudo mkdir -p /var/run /run/php sudo mkdir -m 777 -p /home/"$USER"/.composer /var/run /run/php
if [ "$existing_version" != "$version" ]; then if [ "$existing_version" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then
add_php >/dev/null 2>&1 add_php >/dev/null 2>&1
@ -438,7 +473,7 @@ else
update_php >/dev/null 2>&1 update_php >/dev/null 2>&1
else else
status="Found" status="Found"
if [ "$version" = "$master_version" ]; then if [[ "$version" =~ $nightly_versions ]]; then
switch_version >/dev/null 2>&1 switch_version >/dev/null 2>&1
fi fi
fi fi
@ -452,4 +487,5 @@ pecl_file="$scan_dir"/99-pecl.ini
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1 echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1 sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir" sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "$tick" "PHP" "$status PHP $semver"

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
@ -12,6 +16,6 @@ Function Add-Blackfire() {
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) { if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1 blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
} }
Add-Log $tick "blackfire" "Added" Add-Log $tick "blackfire" "Added blackfire $agent_version"
Add-Log $tick "blackfire-agent" "Added" Add-Log $tick "blackfire-agent" "Added blackfire-agent $agent_version"
} }

View File

@ -29,6 +29,7 @@ add_blackfire() {
[ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1 [ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
[ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1 [ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
blackfire_config >/dev/null 2>&1 blackfire_config >/dev/null 2>&1
add_log "${tick:?}" "blackfire" "Added" tool_version=$(get_tool_version "blackfire" "version")
add_log "${tick:?}" "blackfire-agent" "Added" add_log "${tick:?}" "blackfire" "Added blackfire $tool_version"
add_log "${tick:?}" "blackfire-agent" "Added blackfire-agent $tool_version"
} }

View File

@ -9,11 +9,12 @@ Function Add-Msys2() {
Function Add-Grpc_php_plugin() { Function Add-Grpc_php_plugin() {
$msys_location = Add-Msys2 $msys_location = Add-Msys2
. $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1 $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
Write-Output "::add-path::$msys_location\mingw64\bin" $grpc_version = Get-ToolVersion 'Write-Output' "$logs"
Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe" Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe" Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-Log $tick "grpc_php_plugin" "Added" Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
Write-Output "::endgroup::" Write-Output "::endgroup::"

View File

@ -44,7 +44,7 @@ add_grpc_php_plugin() {
sudo chmod a+x /usr/local/bin/grpc_php_plugin sudo chmod a+x /usr/local/bin/grpc_php_plugin
) >/dev/null 2>&1 ) >/dev/null 2>&1
echo "::set-output name=grpc_php_plugin_path::/usr/local/bin/grpc_php_plugin" echo "::set-output name=grpc_php_plugin_path::/usr/local/bin/grpc_php_plugin"
add_log "${tick:?}" "grpc_php_plugin" "Added" add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
cat "/tmp/grpc-${grpc_tag:1}/LICENSE" cat "/tmp/grpc-${grpc_tag:1}/LICENSE"
echo "::endgroup::" echo "::endgroup::"

View File

@ -31,7 +31,7 @@ Function Add-Protoc() {
Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1 Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe" Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
Add-Log $tick "protoc" "Added" Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
Write-Output "::endgroup::" Write-Output "::endgroup::"

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
} }
@ -21,7 +21,7 @@ add_protoc() {
sudo unzip /tmp/protobuf.zip -d /usr/local/ sudo unzip /tmp/protobuf.zip -d /usr/local/
sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
) >/dev/null 2>&1 ) >/dev/null 2>&1
add_log "${tick:?}" "protoc" "Added" add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
echo "::endgroup::" echo "::endgroup::"

View File

@ -8,7 +8,10 @@ param (
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] [ValidateLength(1, [int]::MaxValue)]
[string] [string]
$dir $dist,
[Parameter(Position = 2, Mandatory = $false)]
[string]
$fail_fast = 'false'
) )
# Function to log start of a operation. # Function to log start of a operation.
@ -18,8 +21,14 @@ Function Step-Log($message) {
# Function to log result of a operation. # Function to log result of a operation.
Function Add-Log($mark, $subject, $message) { Function Add-Log($mark, $subject, $message) {
$code = if ($mark -eq $cross) { "31" } else { "32" } if ($mark -eq $tick) {
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
} else {
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
if($fail_fast -eq 'true') {
exit 1;
}
}
} }
# Function to add a line to a powershell profile safely. # Function to add a line to a powershell profile safely.
@ -64,6 +73,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 "$github/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)) {
@ -73,17 +96,24 @@ Function Get-CleanPSProfile {
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile" Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
} }
# Function to install PhpManager. # Function to install a powershell package from GitHub.
Function Install-PhpManager() { Function Install-GitHubPackage() {
$module_path = "$bin_dir\PhpManager\PhpManager.psm1" param(
[Parameter(Position = 0, Mandatory = $true)]
$package,
[Parameter(Position = 1, Mandatory = $true)]
$psm1_path,
[Parameter(Position = 2, Mandatory = $true)]
$url
)
$module_path = "$bin_dir\$psm1_path.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\$package.zip"
$zip_file = "$bin_dir\PhpManager.zip" Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip_file
Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -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 "$package-search" "Import-Module $module_path"
} }
# Function to add PHP extensions. # Function to add PHP extensions.
@ -175,12 +205,33 @@ Function Edit-ComposerConfig() {
exit 1; exit 1;
} }
composer -q global config process-timeout 0 composer -q global config process-timeout 0
Write-Output "::add-path::$env:APPDATA\Composer\vendor\bin" Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
if (Test-Path env:COMPOSER_TOKEN) { if (Test-Path env:COMPOSER_TOKEN) {
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
} }
} }
# Function to extract tool version.
Function Get-ToolVersion() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
$tool,
[Parameter(Position = 1, Mandatory = $true)]
$param
)
$version_regex = "[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-z0-9]+){0,1}"
if($tool -eq 'composer') {
if ($param -eq 'snapshot') {
$trunk = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
$commit = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value }
return "$trunk+$commit"
} else {
return Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
}
}
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
}
# Function to add tools. # Function to add tools.
Function Add-Tool() { Function Add-Tool() {
Param ( Param (
@ -189,9 +240,10 @@ Function Add-Tool() {
$url, $url,
[Parameter(Position = 1, Mandatory = $true)] [Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] $tool,
[string] [Parameter(Position = 2, Mandatory = $true)]
$tool [ValidateNotNull()]
$ver_param
) )
if (Test-Path $bin_dir\$tool) { if (Test-Path $bin_dir\$tool) {
Remove-Item $bin_dir\$tool Remove-Item $bin_dir\$tool
@ -225,7 +277,8 @@ Function Add-Tool() {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
} }
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) { if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
Add-Log $tick $tool "Added" $tool_version = Get-ToolVersion $tool $ver_param
Add-Log $tick $tool "Added $tool $tool_version"
} else { } else {
Add-Log $cross $tool "Could not add $tool" Add-Log $cross $tool "Could not add $tool"
} }
@ -250,9 +303,14 @@ Function Add-Composertool() {
[string] [string]
$prefix $prefix
) )
composer -q global require $prefix$release 2>&1 | out-null composer global require $prefix$release 2>&1 | out-null
if($?) { $json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
Add-Log $tick $tool "Added" if(Test-Path $composer_bin\composer) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
}
if($json) {
$tool_version = Get-ToolVersion "Write-Output" "$json"
Add-Log $tick $tool "Added $tool $tool_version"
} else { } else {
Add-Log $cross $tool "Could not setup $tool" Add-Log $cross $tool "Could not setup $tool"
} }
@ -269,23 +327,22 @@ $cross = ([char]10007)
$php_dir = 'C:\tools\php' $php_dir = 'C:\tools\php'
$ext_dir = "$php_dir\ext" $ext_dir = "$php_dir\ext"
$bin_dir = $php_dir $bin_dir = $php_dir
$github = 'https://github.com'
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
$current_profile = "$env:TEMP\setup-php.ps1" $current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$master_version = '8.0' $nightly_version = '8.[0-9]'
$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"
@ -294,10 +351,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
@ -315,8 +368,10 @@ 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-GitHubPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP" Step-Log "Setup PHP"
@ -329,12 +384,11 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
$status = "Installed" $status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) { if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') { if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
Install-Module -Name VcRedist -Force Install-GitHubPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
} }
if ($version -eq $master_version) { if ($version -match $nightly_version) {
$version = 'master' Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpNightly.ps1 -OutFile $php_dir\Install-PhpNightly.ps1 > $null 2>&1
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpMaster.ps1 -OutFile $php_dir\Install-PhpMaster.ps1 > $null 2>&1 & $php_dir\Install-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
& $php_dir\Install-PhpMaster.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir
} else { } else {
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1 Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
} }
@ -359,4 +413,6 @@ if($version -lt "5.5") {
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
} }
Update-PhpCAInfo -Path $php_dir -Source $cert_source Update-PhpCAInfo -Path $php_dir -Source $cert_source
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)" Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"

View File

@ -167,7 +167,7 @@ export async function addPhive(
case 'latest': case 'latest':
return ( return (
(await utils.getCommand(os_version, 'tool')) + (await utils.getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive' 'https://phar.io/releases/phive.phar phive status'
); );
default: default:
return ( return (
@ -176,7 +176,7 @@ export async function addPhive(
version + version +
'/phive-' + '/phive-' +
version + version +
'.phar phive' '.phar phive status'
); );
} }
} }
@ -203,6 +203,31 @@ export async function getPharUrl(
} }
} }
/**
* Function to get blackfire player url for a PHP version.
*
* @param version
* @param php_version
*/
export async function getBlackfirePlayerUrl(
version: string,
php_version: string
): Promise<string> {
switch (true) {
case /5\.[5-6]|7\.0/.test(php_version) && version == 'latest':
version = '1.9.3';
break;
default:
break;
}
return await getPharUrl(
'https://get.blackfire.io',
'blackfire-player',
'v',
version
);
}
/** /**
* Function to get the Deployer url * Function to get the Deployer url
* *
@ -280,15 +305,19 @@ export async function getWpCliUrl(version: string): Promise<string> {
*/ */
export async function addComposer(tools_list: string[]): Promise<string[]> { export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex_any = /^composer($|:.*)/; const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/; const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool)); const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer'; let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool)); tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) { switch (true) {
case undefined: case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break; break;
default: default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1'); composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
break; break;
} }
tools_list.unshift(composer); tools_list.unshift(composer);
@ -301,21 +330,20 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
* @param version * @param version
*/ */
export async function getComposerUrl(version: string): Promise<string> { export async function getComposerUrl(version: string): Promise<string> {
const cache_url = let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace(
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + 'latest',
version.replace('latest', 'stable') + 'stable'
'.phar,'; )}.phar`;
switch (version) { switch (true) {
case 'snapshot': case /^snapshot$/.test(version):
return cache_url + 'https://getcomposer.org/composer.phar'; return `${cache_url},https://getcomposer.org/composer.phar`;
case 'preview': case /^preview$|^[1-2]$/.test(version):
case '1': return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
case '2': case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
return ( cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
cache_url + 'https://getcomposer.org/composer-' + version + '.phar' return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
);
default: default:
return cache_url + 'https://getcomposer.org/composer-stable.phar'; return `${cache_url},https://getcomposer.org/composer-stable.phar`;
} }
} }
@ -334,7 +362,7 @@ export async function getCleanedToolsList(
return extension return extension
.trim() .trim()
.replace( .replace(
/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, /-agent|behat\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//,
'' ''
); );
}) })
@ -348,13 +376,18 @@ export async function getCleanedToolsList(
* @param tool * @param tool
* @param url * @param url
* @param os_version * @param os_version
* @param ver_param
*/ */
export async function addArchive( export async function addArchive(
tool: string, tool: string,
url: string, url: string,
os_version: string os_version: string,
ver_param: string
): Promise<string> { ): Promise<string> {
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; return (
(await utils.getCommand(os_version, 'tool')) +
(await utils.joins(url, tool, ver_param))
);
} }
/** /**
@ -369,16 +402,11 @@ export async function addDevTools(
): Promise<string> { ): Promise<string> {
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
return (
'add_devtools' +
'\n' +
(await utils.addLog('$tick', tool, 'Added', 'linux'))
);
case 'darwin': case 'darwin':
return await utils.addLog('$tick', tool, 'Added', 'darwin'); return 'add_devtools ' + tool;
case 'win32': case 'win32':
return await utils.addLog( return await utils.addLog(
'$cross', '$tick',
tool, tool,
tool + ' is not a windows tool', tool + ' is not a windows tool',
'win32' 'win32'
@ -445,24 +473,28 @@ export async function addTools(
case 'protoc': case 'protoc':
script += await utils.customPackage(tool, 'tools', version, os_version); script += await utils.customPackage(tool, 'tools', version, os_version);
break; break;
case 'behat':
case 'phpspec':
script += await addPackage(tool, release, tool + '/', os_version);
break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getBlackfirePlayerUrl(version, php_version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', url, os_version); script += await addArchive('composer', url, os_version, 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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'composer-prefetcher': case 'composer-prefetcher':
script += await addPackage( script += await addPackage(
@ -475,39 +507,37 @@ 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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'composer-unused': case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download'); script += await addPackage(tool, release, 'icanhazstring/', os_version);
url = github + 'composer-unused/composer-unused/' + uri;
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
break; break;
case 'phing': case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar'; url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -522,48 +552,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, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"--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, url, os_version); script += await addArchive(tool, url, os_version, '"--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, url, os_version); script += await addArchive(tool, url, os_version, '"--version"');
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version, '"-V"');
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, url, os_version); script += await addArchive(tool, url, os_version, '"-v"');
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', url, os_version); script += await addArchive('symfony', url, os_version, '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, url, os_version); script += await addArchive(tool, url, os_version, '"--version"');
break; break;
default: default:
script += await utils.addLog( script += await utils.addLog(

View File

@ -2,6 +2,21 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
export async function readEnv(property: string): Promise<string> {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
/** /**
* Function to get inputs from both with and env annotations. * Function to get inputs from both with and env annotations.
* *
@ -12,13 +27,36 @@ export async function getInput(
name: string, name: string,
mandatory: boolean mandatory: boolean
): Promise<string> { ): Promise<string> {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, {required: mandatory});
default:
return input; return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
}
}
/**
* Function to parse PHP version.
*
* @param version
*/
export async function parseVersion(version: string): Promise<string> {
switch (version) {
case 'latest':
return '7.4';
default:
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
} }
} }
@ -339,6 +377,27 @@ export async function scriptExtension(os_version: string): Promise<string> {
} }
} }
/**
* Function to get script tool
*
* @param os_version
*/
export async function scriptTool(os_version: string): Promise<string> {
switch (os_version) {
case 'win32':
return 'pwsh';
case 'linux':
case 'darwin':
return 'bash';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/** /**
* Function to get script to add tools with custom support. * Function to get script to add tools with custom support.
* *