Compare commits

...

121 Commits

Author SHA1 Message Date
81cd5ae092 Bump version to 2.27.0 2023-11-01 19:56:15 +05:30
29a9813921 Add required extensions for box 2023-11-01 10:23:55 +05:30
f60e7de98e Add PHP 8.4 to the php workflow
Enable PHP 8.3 for macOS in the php workflow
2023-11-01 09:35:10 +05:30
b5efb21934 Add tests for box and php-scoper 2023-11-01 09:29:02 +05:30
26e6a92f3b Merge pull request #776 from theofidry/patch-1
feat: Add Box and PHP-Scoper as tools
2023-11-01 08:53:26 +05:30
28b68529b5 feat: Add Box and PHP-Scoper as tools 2023-11-01 08:53:26 +05:30
4e4861ec30 Fix support for couchbase on PHP 7.4 2023-10-30 08:11:09 +05:30
70169700c3 Try to improve couchbase compilation 2023-10-30 06:58:16 +05:30
f4e27c9ead Bump Node.js dependencies
Bump version to 2.26.1
2023-10-30 01:47:34 +05:30
9855c76987 Set keepAlive to false. After Node 19 it is true by default. 2023-10-30 01:38:35 +05:30
546935924a Merge pull request #771 from shivammathur/dependabot/npm_and_yarn/babel/traverse-7.23.2
Bump @babel/traverse from 7.22.5 to 7.23.2
2023-10-19 16:04:25 +05:30
491e9de600 Bump @babel/traverse from 7.22.5 to 7.23.2
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.5 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-19 09:40:39 +00:00
e3bda5bed8 Add support for macOS Sonoma (14) and drop support for Big Sur (11) 2023-10-01 19:03:17 +05:30
e70f6d9e7c Fallback to pecl in add_brew_extension on macOS 2023-10-01 18:49:44 +05:30
92e992b198 Update versioning section in the README 2023-09-23 04:32:24 +05:30
99680be1df Rename branch in README 2023-09-23 03:29:31 +05:30
e83e329355 Fix find call in darwin.sh in copy_brew_extensions on failure 2023-09-22 14:07:12 +05:30
10c12b9377 Fix checking for existing php formula on macOS 2023-09-22 14:00:55 +05:30
91026460e4 Create tool_path_dir if it does not exist 2023-09-22 08:15:57 +05:30
7fdd3ece87 Fix blackfire-player on Linux and macOS
Drop support for blackfire-player on Windows
2023-09-14 02:51:49 +05:30
0de5aa9140 Bump version to 2.26.0 2023-09-14 02:51:49 +05:30
a6e0b1404f Bump Node.js dependencies 2023-09-14 02:51:48 +05:30
5d259c66b1 Bump node version to 20 in action.yml
Node 16 is EOL on 2023-09-11 so we update it to Node 20 that was added in the actions/runner in v2.308.0
2023-09-14 02:51:48 +05:30
6207829361 Update use of actions/checkout to v4 2023-09-14 02:51:47 +05:30
319feb83c2 Add support to install sqlsrv and pdo_sqlsrv from GitHub releases 2023-09-14 02:51:41 +05:30
661ad4bf75 Fix enabling latest pecl extensions 2023-09-09 08:53:07 +05:30
04c15e2314 Remove hardcoded latest version for sqlsrv and pdo_sqlsrv 2023-09-09 08:05:42 +05:30
5aa416d77b Merge pull request #766 from GrahamCampbell/patch-1
Use sqlsvr 5.11.1 on PHP 8
2023-09-09 07:18:11 +05:30
a9a661ccd4 Use sqlsvr 5.11.1 on PHP 8 2023-09-09 00:45:36 +01:00
321f8d7d9a Add PHP 8.4 in the README 2023-08-30 15:15:56 +05:30
7af6c0fe6f Update Node.js dependencies 2023-08-30 15:15:56 +05:30
36e04fc85c Merge pull request #754 from jasongill/develop
Add automatic detection of required PHP version from Composer's platform setting
2023-07-30 08:50:55 +05:30
95916a72b1 Only use config.platform.php, as it's guaranteed to be the required version of PHP 2023-07-29 19:48:28 -04:00
a5fb328c6a Add support for reading PHP version from composer.lock or composer.json 2023-07-29 19:46:06 -04:00
72ae4ccbe5 Update Node.js dependenices
Remove semver override

Bump version to 2.25.5
2023-07-29 22:03:23 +05:30
5b2015e8fe Link opcache to ext_dir on macOS 2023-07-29 21:45:53 +05:30
9c77701ae5 Remove workaround of Debian 12 in ppa.sh 2023-07-03 07:38:22 +05:30
394503cb8a Override semver version to 7.5.3 GHSA-c2qf-rxjj-qqgw/CVE-2022-25883 2023-07-02 02:34:06 +05:30
f1cc14e3d5 Fix grep call in ppa.sh
When distros use DEB822-STYLE .sources file or a custom default list file the list_file is not present, so we check if it exists before calling grep on it
2023-07-02 02:16:13 +05:30
9d529a72e0 Only check castor version if castor.php is present 2023-06-24 02:25:43 +05:30
c63f07d82e Fix version prefix for castor 2023-06-23 23:28:05 +05:30
e40aa32c04 Update Node.js dependencies 2023-06-23 23:23:33 +05:30
a683e80307 Merge pull request #746 from pyrech/support-castor
Add support for tool jolicode/castor
2023-06-23 22:59:01 +05:30
7ce22e0264 Add support for jolicode/castor 2023-06-23 16:13:17 +02:00
4bd44f22a9 Bump version to 2.25.4
Update Node.js dependencies
2023-06-13 03:25:48 +05:30
d2f333de6f Fix regression in major/minor.major version support for phpunit 2023-06-13 03:16:19 +05:30
948bd8df3c Fix fs import in utlts.test.ts 2023-06-12 17:14:07 +05:30
8cac79fdb1 Bump version to 2.25.3
Update Node.js dependencies
2023-06-12 15:28:42 +05:30
6cc8b47c6f Add support to fetch tool versions from packagist 2023-06-12 15:27:46 +05:30
0be6fa1958 Remove quotes after : in CSVArray 2023-06-12 15:27:21 +05:30
22d9c80367 Cannot get release to run, so forced in changes 2023-06-12 15:27:21 +05:30
4630172078 Added what should be compensation for phpunit versions 2023-06-12 15:27:20 +05:30
1b02c009e7 Add npm run build to CONTRIBUTING.md 2023-06-12 04:45:59 +05:30
12282c9597 Add support for ts intl builds 2023-06-07 09:26:20 +05:30
592bbc7716 Shorten grep call in add_extensions.sh 2023-06-07 09:24:56 +05:30
fb5054b163 Use correct prefix for zend_extensions when installed using PECL 2023-06-06 19:27:14 +05:30
3f2a402846 Mark runner as self-hosted on nektos/act 2023-06-05 16:28:04 +05:30
c5fc0d8281 Fix disabling extensions with common substring 2023-05-24 23:01:34 +05:30
48037d201f Add priority config for couchbase and psr 2023-05-24 19:58:13 +05:30
71b43c4f65 Bump version to 2.25.2
Bump Node.js dependencies
2023-05-24 19:58:13 +05:30
3818224063 Fix to avoid double activation
Fix parsing extension input
2023-05-24 19:58:08 +05:30
5b29e8a454 Merge pull request #726 from yassinehamouten/fix/typo-in-sage-example
docs(example): fix a typo in the strategy of the sage example
2023-05-08 08:25:15 +05:30
2a798336a0 docs(example): fix a typo in the strategy of the sage example 2023-05-08 03:11:22 +02:00
cb8f453143 Update Node.js dependencies 2023-04-19 08:37:25 +05:30
19323ea920 Fix event extension priority 2023-04-18 22:02:29 +05:30
b951cf1d99 Add fallback using expanded assets in Add-DebugSymbols on Windows 2023-04-17 08:37:41 +05:30
1fdc5e773b Update Node.js dependencies 2023-04-17 03:36:15 +05:30
1474d67903 Drop support for ubuntu-18.04 2023-04-03 10:11:53 +05:30
1afae1868c Bump version 2.25.0
Bump Node.js dependencies
2023-04-03 10:04:23 +05:30
36e33e130a Add known non-default extension priorities in a config 2023-04-03 02:48:41 +05:30
3d794ddd93 Use phpenmod only for PHP 5.6 and above 2023-04-03 01:18:19 +05:30
c61bd0e074 Fix Get-File in win32.ps1 2023-04-03 00:03:00 +05:30
1f8252a3ed Fix selecting php-builder builds on Windows 2023-04-02 23:54:13 +05:30
3e2462a699 Add Url and FallbackUrl in exception on Windows 2023-04-02 23:42:19 +05:30
e513384a65 Fix jit configuration 2023-04-02 23:23:48 +05:30
6483a6ea70 Improve install_packages in linux.sh 2023-04-02 22:03:11 +05:30
ca308a6886 Fix minor shellcheck error 2023-04-02 21:51:40 +05:30
035ef490b9 Rename resolveVersion to readPHPversion 2023-04-02 20:30:40 +05:30
6bf279d08a Fix reading php version from file 2023-04-02 20:25:49 +05:30
bb16550379 Add support for relay on PHP 8.3 2023-03-31 01:23:49 +05:30
7d999d501a Switch to relay.so as the only source for relay extension 2023-03-31 00:40:53 +05:30
7f8b1e5773 Exclude php 8.3 on macos 2023-03-31 00:29:23 +05:30
6461006ceb Improve Write-Error messages 2023-03-14 06:07:46 +05:30
5f422817a1 Use Write-Error with ErrorAction as Stop instead of exit 2023-03-14 06:02:04 +05:30
1b08836381 Merge pull request #707 from G-Rath/patch-1
docs: improve sentence structure slightly
2023-03-05 02:40:49 +05:30
ae98bca05f docs: improve sentence structure slightly 2023-03-05 09:15:35 +13:00
fb1ad7fc84 Fix enable_extension 2023-02-09 15:50:52 +05:30
0d60024683 Choose correct ts build for zephir_parser 2023-02-09 15:41:48 +05:30
1224b29111 Add support for snmp on macOS using shivammathur/extensions 2023-02-08 20:44:10 +05:30
2f306f9d25 Use phpenmod to enable extensions on linux 2023-02-05 19:45:47 +05:30
39b4e4a983 Fix warning about using -n and -I together in xargs 2023-02-05 19:19:43 +05:30
7e46297c8d Update README 2023-02-03 15:32:03 +05:30
f9390a5478 Add retry logic to Invoke-Webrequests
Add fallback url to nightly setup
2023-02-03 12:59:37 +05:30
f42145a164 Remove call to getManifestURL unless needed in utils.parseVersion 2023-01-29 21:53:23 +05:30
755bbb1cc0 Minor refactor in php.yml 2023-01-29 21:53:17 +05:30
a36edd3ca4 Test php-version-file in php workflow 2023-01-29 21:41:09 +05:30
f2018b2189 Update php-version and php-version-file input section in README 2023-01-29 21:20:52 +05:30
9c411b6e2b Minor refactor in utils.resolveVersion 2023-01-29 20:17:23 +05:30
e8d8aa3403 Add back the required parameter in action.yml 2023-01-29 19:51:07 +05:30
686e8dfff9 Merge pull request #691 from stevelacey/php-version-file-inputs
Move php version default out of action.yml and update inputs
2023-01-29 19:46:18 +05:30
b46c8e2a8c Move php version default out of action.yml and update inputs #629 #690 2023-01-29 16:23:08 +08:00
2d47531473 Merge pull request #690 from stevelacey/php-version-file
Support .php-version file for version detection
2023-01-29 11:40:49 +05:30
fd03521cb4 Support .php-version file; closes #629 2023-01-29 13:41:50 +08:00
f03add0b41 Add uuid to brew_extensions list 2023-01-29 08:41:56 +05:30
baf9535ba5 Merge pull request #689 from viktorruskai/patch-1
Fix DocBlock in `utils.ts`
2023-01-28 03:41:21 +05:30
cc0e576689 Update utils.ts 2023-01-27 22:12:33 +01:00
d30ad8b184 Fix relay cache setup 2023-01-27 08:38:32 +05:30
0f765070fa Update Node.js dependencies 2023-01-27 07:41:01 +05:30
313d0cfdbf Fix function name in grpc_php_plugin.ps1 2023-01-27 05:26:40 +05:30
cf767706fe Bump version to 2.24.0 2023-01-24 21:23:58 +05:30
1267cf80a1 Change choco install script URL 2023-01-22 02:10:29 +05:30
7abee8e28c Add custom support for zephir parser 2023-01-22 02:04:12 +05:30
dd0115673c Fix sudo setup for containers with broken lists 2023-01-21 08:06:21 +05:30
bbc65d999a Fix extension logs
Refactor utils.addCommand
2023-01-18 09:00:28 +05:30
6db1a06425 Improve support for blackfire-player 2023-01-17 05:11:26 +05:30
52eb86c60c Add support for relay extension 2023-01-12 16:14:06 +05:30
2b77dd6b79 Merge pull request #684 from Rotzbua/patch-1
doc: fix otudated github action version
2023-01-10 19:53:38 +05:30
224f9ddef5 doc: fix otudated github action version 2023-01-10 14:19:28 +01:00
7f5c8b51ba Merge pull request #683 from shivammathur/dependabot/npm_and_yarn/json5-1.0.2
Bump json5 from 1.0.1 to 1.0.2
2023-01-08 17:17:22 +05:30
bd5c747191 Bump json5 from 1.0.1 to 1.0.2
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-08 05:14:30 +00:00
40846b27d0 Fix sed call in parse_pecl_configure_options 2022-12-27 04:42:24 +05:30
77 changed files with 5593 additions and 2755 deletions

View File

@ -71,6 +71,7 @@ npm test
Creating a release means compiling all the TypeScript code to a single file which `setup-php` can run. Run this, before you push your changes. Creating a release means compiling all the TypeScript code to a single file which `setup-php` can run. Run this, before you push your changes.
```bash ```bash
npm run build
npm run release npm run release
``` ```

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 2 fetch-depth: 2

View File

@ -15,7 +15,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04, windows-2022, macos-11] operating-system: [ubuntu-22.04, ubuntu-20.04, windows-2022, macos-11]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
steps: steps:
- name: Setup PHP - name: Setup PHP
@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
repository: ${{ github.repository }}.wiki repository: ${{ github.repository }}.wiki
- name: Download artifacts - name: Download artifacts
@ -70,7 +70,7 @@ jobs:
git config --local user.name "${{ github.repository_owner }}" git config --local user.name "${{ github.repository_owner }}"
- name: Combine - name: Combine
run: | run: |
for os in ubuntu-22.04 ubuntu-20.04 ubuntu-18.04 windows-2022 windows-2019 macos-11 macos-10.15; do for os in ubuntu-22.04 ubuntu-20.04 windows-2022 windows-2019 macos-11 macos-10.15; do
echo "These are extensions which are loaded by default on the following PHP versions. More extensions which are available as packages and available on pecl are supported by setup-php. Refer to [php extension support](https://github.com/shivammathur/setup-php#heavy_plus_sign-php-extension-support) for more details." > Php-extensions-loaded-on-"$os".md echo "These are extensions which are loaded by default on the following PHP versions. More extensions which are available as packages and available on pecl are supported by setup-php. Refer to [php extension support](https://github.com/shivammathur/setup-php#heavy_plus_sign-php-extension-support) for more details." > Php-extensions-loaded-on-"$os".md
for version in 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2; do for version in 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2; do
if [ "$os" = "macos-10.15" ]; then if [ "$os" = "macos-10.15" ]; then

View File

@ -29,7 +29,7 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
fetch-depth: 2 fetch-depth: 2

View File

@ -19,7 +19,8 @@ on:
- 'examples/**' - 'examples/**'
permissions: permissions:
contents: read contents: read
env:
default-php-version: '8.2'
jobs: jobs:
run: run:
name: Run name: Run
@ -27,20 +28,24 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-22.04, ubuntu-20.04, ubuntu-18.04, windows-2019, macos-latest] operating-system: [ubuntu-22.04, ubuntu-20.04, windows-2019, macos-latest]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
include:
- operating-system: ubuntu-22.04
php-versions: ''
php-version-file: 'php-version-file'
env: env:
extensions: xml, opcache, xdebug, pcov, gd extensions: xml, opcache, xdebug, pcov, gd
key: cache-v5 key: cache-v5
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup cache environment - name: Setup cache environment
id: cache-env id: cache-env
uses: shivammathur/cache-extensions@develop uses: shivammathur/cache-extensions@develop
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions || env.default-php-version }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
key: ${{ env.key }} key: ${{ env.key }}
@ -51,17 +56,23 @@ jobs:
key: ${{ steps.cache-env.outputs.key }} key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }} restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Stage php-version-file
if: ${{ matrix.php-version-file == 'php-version-file' }}
run: |
echo ${{ env.default-php-version }} > php-version-file
- name: Setup PHP with extensions and custom config - name: Setup PHP with extensions and custom config
run: node dist/index.js run: node dist/index.js
env: env:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
php-version-file: ${{ matrix.php-version-file }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata
- name: Testing PHP version - name: Testing PHP version
run: | run: |
php -v php -v
php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}" php -r "if(strpos(phpversion(), '${{ matrix.php-versions || env.default-php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}"
- name: Testing Composer version - name: Testing Composer version
run: | run: |

View File

@ -19,10 +19,10 @@ jobs:
steps: steps:
- name: Checkout release - name: Checkout release
if: github.event_name != 'workflow_dispatch' if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v3 uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch' if: github.event_name == 'workflow_dispatch'
with: with:
ref: ${{ github.event.inputs.tag }} ref: ${{ github.event.inputs.tag }}

View File

@ -9,8 +9,8 @@
<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://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></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?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a> <a href="https://github.com/shivammathur/setup-php/blob/main/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.3-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.4-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
</p> </p>
<p align="center"> <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://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>
@ -75,11 +75,10 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|---------------------|------------------------------------|------------------------| |---------------------|------------------------------------|------------------------|
| Ubuntu 22.04 | `ubuntu-latest` or `ubuntu-22.04` | `PHP 8.1` | | Ubuntu 22.04 | `ubuntu-latest` or `ubuntu-22.04` | `PHP 8.1` |
| Ubuntu 20.04 | `ubuntu-20.04` | `PHP 7.4` to `PHP 8.2` | | Ubuntu 20.04 | `ubuntu-20.04` | `PHP 7.4` to `PHP 8.2` |
| Ubuntu 18.04 | `ubuntu-18.04` | `PHP 7.2` to `PHP 8.2` |
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.2` | | Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.2` |
| Windows Server 2019 | `windows-2019` | `PHP 8.2` | | Windows Server 2019 | `windows-2019` | `PHP 8.2` |
| macOS Monterey 12.x | `macos-12` | `PHP 8.2` | | macOS Ventura 13.x | `macos-13` | `PHP 8.2` |
| macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.2` | | macOS Monterey 12.x | `macos-latest` or `macos-12` | `PHP 8.2` |
### Self-Hosted Runners ### Self-Hosted Runners
@ -87,14 +86,13 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|----------------------------------|----------------------------| |----------------------------------|----------------------------|
| Ubuntu 22.04 | `self-hosted` or `Linux` | | Ubuntu 22.04 | `self-hosted` or `Linux` |
| Ubuntu 20.04 | `self-hosted` or `Linux` | | Ubuntu 20.04 | `self-hosted` or `Linux` |
| Ubuntu 18.04 | `self-hosted` or `Linux` |
| Debian 11 | `self-hosted` or `Linux` | | Debian 11 | `self-hosted` or `Linux` |
| Debian 10 | `self-hosted` or `Linux` | | Debian 10 | `self-hosted` or `Linux` |
| 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 Sonoma 14.x x86_64/arm64 | `self-hosted` or `macOS` |
| macOS Ventura 13.x x86_64/arm64 | `self-hosted` or `macOS` | | macOS Ventura 13.x x86_64/arm64 | `self-hosted` or `macOS` |
| macOS Monterey 12.x x86_64/arm64 | `self-hosted` or `macOS` | | macOS Monterey 12.x x86_64/arm64 | `self-hosted` or `macOS` |
| macOS Big Sur 11.x x86_64/arm64 | `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.
- Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis. - Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
@ -104,8 +102,8 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
On all supported OS/Platforms the following PHP versions can be set up as per the runner. On all supported OS/Platforms the following PHP versions can be set up as per the runner.
- PHP 5.3 to PHP 8.3 on GitHub-hosted runners. - PHP 5.3 to PHP 8.4 on GitHub-hosted runners.
- PHP 5.6 to PHP 8.3 on self-hosted runners. - PHP 5.6 to PHP 8.4 on self-hosted runners.
| PHP Version | Stability | Release Support | Runner Support | | PHP Version | Stability | Release Support | Runner Support |
|-------------|-----------|-----------------------|--------------------------------| |-------------|-----------|-----------------------|--------------------------------|
@ -122,9 +120,10 @@ On all supported OS/Platforms the following PHP versions can be set up as per th
| `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` | | `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.2` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` | | `8.2` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.3` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` | | `8.3` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
| `8.4` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
**Notes:** **Notes:**
- Specifying `8.3` in `php-version` input installs a nightly build of `PHP 8.3.0-dev`. See [nightly build setup](#nightly-build-setup) for more information. - Specifying `8.3` and `8.4` in `php-version` input installs a nightly build of `PHP 8.3.0-dev` and `PHP 8.4.0-dev` respectively. See [nightly build setup](#nightly-build-setup) for more information.
- To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section. - To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
@ -207,8 +206,8 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- These extensions have custom support: - These extensions have custom support:
- `cubrid` and `pdo_cubrid` on `Ubuntu`. - `cubrid` and `pdo_cubrid` on `Ubuntu`.
- `gearman`, `geos` and `event` on `Ubuntu` and `macOS`. - `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`.
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4` and `phalcon5` on all supported OS. - `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4`, `phalcon5`, and `zephir_parser` on all supported OS.
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`. - By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
@ -226,7 +225,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
These tools can be set up globally using the `tools` input. It accepts a string in csv-format. These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
[`behat`], [`blackfire`], [`blackfire-player`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`] [`behat`], [`blackfire`], [`blackfire-player`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
```yaml ```yaml
- name: Setup PHP with tools - name: Setup PHP with tools
@ -255,7 +254,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup. When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup.
Except for major versions of `composer`, For other tools when you specify only the `major` version or the version in `major.minor` format for any tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth"). With the exception of major versions of `composer`, if you specify only the `major` version or the version in `major.minor` format for a tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth").
You can do that by setting `GITHUB_TOKEN` environment variable. The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version. You can do that by setting `GITHUB_TOKEN` environment variable. The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
```yaml ```yaml
@ -294,7 +293,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
- Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`. - Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`.
- By default, expect `composer` tools which cannot be set up gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`. - By default, except `composer` tools which cannot be set up gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
```yaml ```yaml
- name: Setup PHP with fail-fast - name: Setup PHP with fail-fast
@ -391,14 +390,23 @@ Disable coverage for these reasons:
> Specify using `with` keyword > Specify using `with` keyword
#### `php-version` (required) #### `php-version` (optional)
- Specify the PHP version you want to set up. - Specify the PHP version you want to set up.
- Accepts a `string`. For example `'8.0'`. - Accepts a `string`. For example `'8.0'`.
- Accepts `latest` to set up the latest stable PHP version. - Accepts `latest` to set up the latest stable PHP version.
- Accepts `nightly` to set up a nightly build from the master branch of PHP. - Accepts `nightly` to set up a nightly build from the master branch of PHP.
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`. - Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
- See [PHP support](#tada-php-support) for supported PHP versions. - See [PHP support](#tada-php-support) for the supported PHP versions.
- If not specified, it looks for `php-version-file` input.
#### `php-version-file` (optional)
- Specify a file with the PHP version you want to set up.
- Accepts a `string`. For example `'.phpenv-version'`.
- See [PHP support](#tada-php-support) for the supported PHP versions.
- By default, `.php-version` file is used.
- If not specified and the default `.php-version` file is not found, the latest stable PHP version is set up.
#### `extensions` (optional) #### `extensions` (optional)
@ -505,12 +513,12 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest'] operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
php-versions: ['8.0', '8.1', '8.2'] php-versions: ['8.1', '8.2', '8.3']
phpunit-versions: ['latest'] phpunit-versions: ['latest']
include: include:
- operating-system: 'ubuntu-latest' - operating-system: 'ubuntu-latest'
php-versions: '7.2' php-versions: '8.0'
phpunit-versions: '8.5.21' phpunit-versions: 9
steps: steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
@ -520,13 +528,15 @@ jobs:
ini-values: post_max_size=256M, max_execution_time=180 ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug coverage: xdebug
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }} tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
### Nightly Build Setup ### Nightly Build Setup
> Set up a nightly build of `PHP 8.3`. > Set up a nightly build of `PHP 8.3` or `PHP 8.4`.
- This PHP version is currently in active development and might contain bugs and breaking changes. - These PHP versions are currently in active development and might contain bugs and breaking changes.
- Some user space extensions might not support this version currently. - Some user space extensions might not support this version currently.
```yaml ```yaml
@ -696,9 +706,6 @@ act -P ubuntu-22.04=shivammathur/node:2204
# For runs-on: ubuntu-20.04 # For runs-on: ubuntu-20.04
act -P ubuntu-20.04=shivammathur/node:2004 act -P ubuntu-20.04=shivammathur/node:2004
# For runs-on: ubuntu-18.04
act -P ubuntu-18.04=shivammathur/node:1804
``` ```
### JIT Configuration ### JIT Configuration
@ -736,7 +743,7 @@ If your project uses composer, you can persist the composer's internal cache dir
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -933,9 +940,10 @@ Examples of using `setup-php` with various PHP frameworks and packages.
- 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, security patches, new features and support for latest PHP 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, security patches, new features and support for latest PHP 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, security patches or new features. - Commit SHA can also be used, but are not recommended unless you set up tooling to update them with each release of the action.
- A new major version of the action will only be tagged when there are breaking changes in the setup-php API i.e. inputs, outputs, and environment flags.
- For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases. - For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
- It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes. - It is highly discouraged to use the `main` 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, 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. - 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
@ -1022,6 +1030,7 @@ These companies generously provide setup-php their products and services to aid
[`behat`]: https://docs.behat.org/en/latest/ [`behat`]: https://docs.behat.org/en/latest/
[`blackfire`]: https://blackfire.io/docs/php/index [`blackfire`]: https://blackfire.io/docs/php/index
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player [`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
[`castor`]: https://github.com/jolicode/castor
[`churn`]: https://github.com/bmitch/churn-php [`churn`]: https://github.com/bmitch/churn-php
[`codeception`]: https://codeception.com/ [`codeception`]: https://codeception.com/
[`composer`]: https://getcomposer.org/ [`composer`]: https://getcomposer.org/

View File

@ -19,12 +19,16 @@ describe('Extension tests', () => {
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'} ${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'} ${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
${'pecl_http'} | ${'7.4'} | ${'Add-Http'} ${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
${'pdo_sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv pdo_sqlsrv'}
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'} ${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'} ${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'}
${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'} ${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'}
${'sqlsrv'} | ${'5.6'} | ${'Add-Extension sqlsrv'}
${'sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv sqlsrv'}
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'} ${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'} ${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'} ${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
${'zephir_parser'} | ${'7.2'} | ${'Add-ZephirParser zephir_parser'}
`( `(
'checking addExtensionOnWindows for extension $extension on version $version', 'checking addExtensionOnWindows for extension $extension on version $version',
async ({extension, version, output}) => { async ({extension, version, output}) => {
@ -48,6 +52,7 @@ describe('Extension tests', () => {
${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'} ${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'}
${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'} ${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'}
${'ioncube'} | ${'7.3'} | ${'add_ioncube'} ${'ioncube'} | ${'7.3'} | ${'add_ioncube'}
${'memcache-8.2'} | ${'8.2'} | ${'add_pecl_extension memcache 8.2 extension'}
${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'} ${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'}
${'oci8'} | ${'7.3'} | ${'add_oci oci8'} ${'oci8'} | ${'7.3'} | ${'add_oci oci8'}
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'} ${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'}
@ -59,11 +64,14 @@ describe('Extension tests', () => {
${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'} ${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'}
${'pecl_http'} | ${'7.3'} | ${'add_http'} ${'pecl_http'} | ${'7.3'} | ${'add_http'}
${'phalcon3'} | ${'7.3'} | ${'add_phalcon phalcon3'} ${'phalcon3'} | ${'7.3'} | ${'add_phalcon phalcon3'}
${'relay'} | ${'7.4'} | ${'add_relay relay'}
${'relay-v1.2.3'} | ${'7.4'} | ${'add_relay relay-v1.2.3'}
${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'} ${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'}
${'sqlsrv-1.2.3-beta1'} | ${'7.4'} | ${'add_pecl_extension sqlsrv 1.2.3beta1 extension'} ${'sqlsrv-1.2.3-beta1'} | ${'7.4'} | ${'add_pecl_extension sqlsrv 1.2.3beta1 extension'}
${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'} ${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'}
${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'} ${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'}
${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'} ${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
${'zephir_parser-1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-1.2.3'}
`( `(
'checking addExtensionOnLinux for extension $extension on version $version', 'checking addExtensionOnLinux for extension $extension on version $version',
async ({extension, version, output}) => { async ({extension, version, output}) => {
@ -92,7 +100,9 @@ describe('Extension tests', () => {
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'} ${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'} ${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
${'pecl_http'} | ${'7.3'} | ${'add_http'} ${'pecl_http'} | ${'7.3'} | ${'add_http'}
${'relay-1.2.3'} | ${'7.4'} | ${'add_relay relay-1.2.3'}
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'} ${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
${'zephir_parser-v1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-v1.2.3'}
`( `(
'checking addExtensionOnDarwin for extension $extension on version $version', 'checking addExtensionOnDarwin for extension $extension on version $version',
async ({extension, version, output}) => { async ({extension, version, output}) => {

View File

@ -10,7 +10,7 @@ jest.mock('../src/install', () => ({
.mockImplementation(async (os: string): Promise<string> => { .mockImplementation(async (os: string): Promise<string> => {
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const version: string = await utils.parseVersion( const version: string = await utils.parseVersion(
await utils.getInput('php-version', true) await utils.readPHPVersion()
); );
const ini_file: string = await utils.parseIniFile( const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false) await utils.getInput('ini-file', false)

View File

@ -0,0 +1,50 @@
import * as packagist from '../src/packagist';
import nock = require('nock');
describe('search function', () => {
const mockResponse = {
packages: {
'test-package': [
{
require: {
php: '8.0.0'
},
version: '1.0.0'
},
{
version: '2.0.0'
}
]
}
};
test('should return the version if matching php version is found', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, mockResponse);
const result = await packagist.search('test-package', '8.0');
expect(result).toBe('1.0.0');
});
test('should return null if no matching php version is found', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, mockResponse);
const result = await packagist.search('test-package', '5.6');
expect(result).toBeNull();
});
test('should return null if fetch fails', async () => {
nock('https://repo.packagist.org').get('/p2/test-package.json').reply(404);
const result = await packagist.search('test-package', '8.0');
expect(result).toBeNull();
});
test('should return null if the response is empty', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, {error: true, data: '[]'});
const result = await packagist.search('test-package', '8.0');
expect(result).toBeNull();
});
});

View File

@ -1,3 +1,4 @@
import fs = require('fs');
import * as tools from '../src/tools'; import * as tools from '../src/tools';
interface IData { interface IData {
@ -70,6 +71,22 @@ jest.mock('../src/fetch', () => ({
) )
})); }));
jest.mock('../src/packagist', () => ({
search: jest
.fn()
.mockImplementation(
async (
package_name: string,
php_version: string
): Promise<string | null> => {
if (package_name === 'phpunit/phpunit') {
return php_version + '.0';
}
return null;
}
)
}));
describe('Tools tests', () => { describe('Tools tests', () => {
it.each` it.each`
token | version token | version
@ -222,11 +239,11 @@ describe('Tools tests', () => {
}); });
it.each` it.each`
os | script | scope os | script | scope
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'} ${'linux'} | ${'add_composer_tool tool tool:1.2.3 user/ global'} | ${'global'}
${'darwin'} | ${'add_composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'} ${'darwin'} | ${'add_composer_tool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
${'win32'} | ${'Add-Composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'} ${'win32'} | ${'Add-ComposerTool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'} ${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'}
`('checking addPackage: $os, $scope', async ({os, script, scope}) => { `('checking addPackage: $os, $scope', async ({os, script, scope}) => {
const data = getData({ const data = getData({
tool: 'tool', tool: 'tool',
@ -264,15 +281,18 @@ describe('Tools tests', () => {
); );
it.each` it.each`
version | php_version | url os | version | php_version | url
${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player.phar'} ${'linux'} | ${'latest'} | ${'8.1'} | ${'https://get.blackfire.io/blackfire-player.phar'}
${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'} ${'linux'} | ${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'}
${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'} ${'linux'} | ${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.22.0.phar'}
${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'} ${'linux'} | ${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'linux'} | ${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'win32'} | ${'latest'} | ${'7.0'} | ${'blackfire-player is not a windows tool'}
`( `(
'checking addBlackfirePlayer: $version, $php_version', 'checking addBlackfirePlayer: $os, $version, $php_version',
async ({version, php_version, url}) => { async ({os, version, php_version, url}) => {
const data = getData({ const data = getData({
os: os,
tool: 'blackfire-player', tool: 'blackfire-player',
domain: 'https://get.blackfire.io', domain: 'https://get.blackfire.io',
version_prefix: 'v', version_prefix: 'v',
@ -372,34 +392,36 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'blackfire, blackfire-player, churn, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp', 'blackfire, blackfire-player, box, churn, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, php-scoper, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp',
[ [
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer', 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'add_blackfire', 'add_blackfire',
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"', 'add_tool https://get.blackfire.io/blackfire-player-v1.22.0.phar blackfire-player "-V"',
'add_tool https://github.com/box-project/box/releases/latest/download/box.phar box "--version"',
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"', 'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"', 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
'add_composertool flex flex symfony/ global', 'add_composer_tool flex flex symfony/ global',
'add_grpc_php_plugin latest', 'add_grpc_php_plugin latest',
'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"', 'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"',
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"', 'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"',
'add_tool https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"',
'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"', 'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"',
'add_composertool phplint phplint overtrue/', 'add_composer_tool phplint phplint overtrue/',
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"', 'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"',
'add_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"', 'add_tool https://phar.phpunit.de/phpunit-7.4.0.phar phpunit "--version"',
'add_pecl', 'add_pecl',
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"', 'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
'add_composertool phinx phinx robmorgan/ scoped', 'add_composer_tool phinx phinx robmorgan/ scoped',
'add_composertool phinx phinx:1.2.3 robmorgan/ scoped', 'add_composer_tool phinx phinx:1.2.3 robmorgan/ scoped',
'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive "status"', 'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive "status"',
'add_composertool phpunit-bridge phpunit-bridge symfony/ global', 'add_composer_tool phpunit-bridge phpunit-bridge symfony/ global',
'add_composertool phpunit-polyfills phpunit-polyfills yoast/ global', 'add_composer_tool phpunit-polyfills phpunit-polyfills yoast/ global',
'add_tool https://github.com/laravel/pint/releases/latest/download/pint.phar pint "-V"', 'add_tool https://github.com/laravel/pint/releases/latest/download/pint.phar pint "-V"',
'add_devtools php-config', 'add_devtools php-config',
'add_devtools phpize', 'add_devtools phpize',
'add_protoc latest', 'add_protoc latest',
'add_symfony latest', 'add_symfony latest',
'add_composertool vapor-cli vapor-cli laravel/ scoped', 'add_composer_tool vapor-cli vapor-cli laravel/ scoped',
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"' 'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
] ]
] ]
@ -415,21 +437,21 @@ describe('Tools tests', () => {
'behat, blackfire, blackfire-player, churn, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, flex, grpc_php_plugin:1.2.3, infection, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, rector, symfony-cli, vapor-cli, wp-cli', 'behat, blackfire, blackfire-player, churn, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, flex, grpc_php_plugin:1.2.3, infection, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, rector, symfony-cli, vapor-cli, wp-cli',
[ [
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer', 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'add_composertool behat behat behat/ scoped', 'add_composer_tool behat behat behat/ scoped',
'add_blackfire', 'add_blackfire',
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"', 'add_tool https://get.blackfire.io/blackfire-player-v1.22.0.phar blackfire-player "-V"',
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"', 'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"', 'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"',
'add_composertool composer-require-checker composer-require-checker maglnet/ scoped', 'add_composer_tool composer-require-checker composer-require-checker maglnet/ scoped',
'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused "-V"', 'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused "-V"',
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"', 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"',
'add_composertool flex flex symfony/ global', 'add_composer_tool flex flex symfony/ global',
'add_grpc_php_plugin 1.2.3', 'add_grpc_php_plugin 1.2.3',
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"', 'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"',
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"', 'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"',
'add_tool https://github.com/phan/phan/releases/download/1.2.3/phan.phar phan "-v"', 'add_tool https://github.com/phan/phan/releases/download/1.2.3/phan.phar phan "-v"',
'add_tool https://www.phing.info/get/phing-1.2.3.phar,https://github.com/phingofficial/phing/releases/download/1.2.3/phing-1.2.3.phar phing "-v"', 'add_tool https://www.phing.info/get/phing-1.2.3.phar,https://github.com/phingofficial/phing/releases/download/1.2.3/phing-1.2.3.phar phing "-v"',
'add_composertool phinx phinx robmorgan/ scoped', 'add_composer_tool phinx phinx robmorgan/ scoped',
'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',
'add_devtools php-config', 'add_devtools php-config',
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"', 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"',
@ -439,13 +461,13 @@ describe('Tools tests', () => {
'add_devtools phpize', 'add_devtools phpize',
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"', 'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
'add_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"', 'add_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"',
'add_composertool phpunit-bridge phpunit-bridge:5.6.* symfony/ global', 'add_composer_tool phpunit-bridge phpunit-bridge:5.6.* symfony/ global',
'add_composertool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global', 'add_composer_tool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
'add_protoc 1.2.3', 'add_protoc 1.2.3',
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"', 'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
'add_composertool rector rector rector/ scoped', 'add_composer_tool rector rector rector/ scoped',
'add_symfony latest', 'add_symfony latest',
'add_composertool vapor-cli vapor-cli laravel/ scoped', 'add_composer_tool vapor-cli vapor-cli laravel/ scoped',
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"' 'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
] ]
] ]
@ -462,18 +484,18 @@ describe('Tools tests', () => {
[ [
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer', 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'Add-Blackfire', 'Add-Blackfire',
'Add-Tool https://get.blackfire.io/blackfire-player-v1.2.3.phar blackfire-player "-V"', 'blackfire-player is not a windows tool',
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"', 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"', 'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
'Add-Tool https://deployer.org/deployer.phar deployer "-V"', 'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
'Tool does_not_exist is not supported', 'Tool does_not_exist is not supported',
'Add-Composertool flex flex symfony/ global', 'Add-ComposerTool flex flex symfony/ global',
'Add-Composertool phinx phinx robmorgan/ scoped', 'Add-ComposerTool phinx phinx robmorgan/ scoped',
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive "status"', 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive "status"',
'php-config is not a windows tool', 'php-config is not a windows tool',
'phpize is not a windows tool', 'phpize is not a windows tool',
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"', 'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
'Add-Composertool phpunit-bridge phpunit-bridge symfony/ global', 'Add-ComposerTool phpunit-bridge phpunit-bridge symfony/ global',
'Add-Symfony', 'Add-Symfony',
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"' 'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
] ]
@ -490,13 +512,13 @@ describe('Tools tests', () => {
'composer:v1, codeception/codeception, prestissimo, hirak/prestissimo, composer-prefetcher, narrowspark/automatic-composer-prefetcher, phinx: 1.2, robmorgan/phinx: ^1.2, user/tool:1.2.3, user/tool:~1.2', 'composer:v1, codeception/codeception, prestissimo, hirak/prestissimo, composer-prefetcher, narrowspark/automatic-composer-prefetcher, phinx: 1.2, robmorgan/phinx: ^1.2, user/tool:1.2.3, user/tool:~1.2',
[ [
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer', 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer',
'Add-Composertool codeception codeception codeception/ global', 'Add-ComposerTool codeception codeception codeception/ global',
'Add-Composertool prestissimo prestissimo hirak/ global', 'Add-ComposerTool prestissimo prestissimo hirak/ global',
'Add-Composertool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global', 'Add-ComposerTool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global',
'Add-Composertool phinx phinx:1.2.* robmorgan/ scoped', 'Add-ComposerTool phinx phinx:1.2.* robmorgan/ scoped',
'Add-Composertool phinx phinx:^1.2 robmorgan/ global', 'Add-ComposerTool phinx phinx:^1.2 robmorgan/ global',
'Add-Composertool tool tool:1.2.3 user/ global', 'Add-ComposerTool tool tool:1.2.3 user/ global',
'Add-Composertool tool tool:~1.2 user/ global' 'Add-ComposerTool tool tool:~1.2 user/ global'
] ]
] ]
])( ])(
@ -509,10 +531,36 @@ describe('Tools tests', () => {
} }
); );
it.each`
version | os | uri
${'latest'} | ${'linux'} | ${'releases/latest/download/castor.linux-amd64.phar'}
${'0.5.1'} | ${'linux'} | ${'releases/download/v0.5.1/castor.linux-amd64.phar'}
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'}
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'}
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'}
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar castor -V'}
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
const data = getData({
tool: 'castor',
php_version: '8.1',
version_prefix: 'v',
version: version,
os: os
});
if (os === 'win32' && version === '0.5.1') {
fs.writeFileSync('castor.php', '');
expect(await tools.addCastor(data)).toContain(uri);
fs.unlinkSync('castor.php');
} else {
expect(await tools.addCastor(data)).toContain(uri);
}
});
it.each` it.each`
tools_csv | script tools_csv | script
${'none'} | ${''} ${'none'} | ${''}
${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'} ${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit-7.4.0.phar phpunit "--version"'}
${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'} ${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'}
${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'} ${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'}
${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'} ${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'}
@ -539,4 +587,22 @@ describe('Tools tests', () => {
process.env['GITHUB_TOKEN'] = token; process.env['GITHUB_TOKEN'] = token;
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script); expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
}); });
it.each`
tools_csv | php_version | resolved
${'phpunit'} | ${'8.2'} | ${'/phpunit-8.2.0.phar'}
${'phpunit'} | ${'8.1'} | ${'/phpunit-8.1.0.phar'}
${'phpunit'} | ${'8.0'} | ${'/phpunit-8.0.0.phar'}
${'phpunit'} | ${'7.3'} | ${'/phpunit-7.3.0.phar'}
${'phpunit'} | ${'7.2'} | ${'/phpunit-7.2.0.phar'}
${'phpunit'} | ${'7.1'} | ${'/phpunit-7.1.0.phar'}
${'phpunit'} | ${'7.0'} | ${'/phpunit-7.0.0.phar'}
`(
'checking error: $tools_csv',
async ({tools_csv, php_version, resolved}) => {
expect(await tools.addTools(tools_csv, php_version, 'linux')).toContain(
resolved
);
}
);
}); });

View File

@ -1,3 +1,4 @@
import fs = require('fs');
import * as path from 'path'; import * as path from 'path';
import * as utils from '../src/utils'; import * as utils from '../src/utils';
@ -7,7 +8,8 @@ import * as utils from '../src/utils';
jest.mock('@actions/core', () => ({ jest.mock('@actions/core', () => ({
getInput: jest.fn().mockImplementation(key => { getInput: jest.fn().mockImplementation(key => {
return ['setup-php'].indexOf(key) !== -1 ? key : ''; return ['setup-php'].indexOf(key) !== -1 ? key : '';
}) }),
info: jest.fn()
})); }));
/** /**
@ -193,6 +195,7 @@ describe('Utils tests', () => {
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool '); expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool '); expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool '); expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await utils.getCommand('win32', 'tool_name')).toBe('Add-ToolName ');
expect(await utils.getCommand('openbsd', 'tool')).toContain( expect(await utils.getCommand('openbsd', 'tool')).toContain(
'Platform openbsd is not supported' 'Platform openbsd is not supported'
); );
@ -260,6 +263,47 @@ describe('Utils tests', () => {
); );
}); });
it('checking readPHPVersion', async () => {
expect(await utils.readPHPVersion()).toBe('latest');
process.env['php-version-file'] = '.phpenv-version';
await expect(utils.readPHPVersion()).rejects.toThrow(
"Could not find '.phpenv-version' file."
);
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation();
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation();
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('8.1');
expect(await utils.readPHPVersion()).toBe('8.1');
process.env['php-version'] = '8.2';
expect(await utils.readPHPVersion()).toBe('8.2');
delete process.env['php-version-file'];
delete process.env['php-version'];
existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
readFileSync.mockReturnValue(
'{ "platform-overrides": { "php": "7.3.25" } }'
);
expect(await utils.readPHPVersion()).toBe('7.3.25');
existsSync
.mockReturnValueOnce(false)
.mockReturnValueOnce(false)
.mockReturnValueOnce(true);
readFileSync.mockReturnValue(
'{ "config": { "platform": { "php": "7.4.33" } } }'
);
expect(await utils.readPHPVersion()).toBe('7.4.33');
existsSync.mockClear();
readFileSync.mockClear();
});
it('checking setVariable', async () => { it('checking setVariable', async () => {
let script: string = await utils.setVariable('var', 'command', 'linux'); let script: string = await utils.setVariable('var', 'command', 'linux');
expect(script).toEqual('\nvar="$(command)"\n'); expect(script).toEqual('\nvar="$(command)"\n');

View File

@ -7,15 +7,17 @@ branding:
inputs: inputs:
php-version: php-version:
description: 'Setup PHP version.' description: 'Setup PHP version.'
default: '8.2' required: false
required: true php-version-file:
description: 'Setup PHP version from a file.'
required: false
extensions: extensions:
description: 'Setup PHP extensions.' description: 'Setup PHP extensions.'
required: false required: false
ini-file: ini-file:
description: 'Set base ini file.' description: 'Set base ini file.'
default: 'production'
required: false required: false
default: 'production'
ini-values: ini-values:
description: 'Add values to php.ini.' description: 'Add values to php.ini.'
required: false required: false
@ -29,5 +31,5 @@ outputs:
php-version: php-version:
description: 'PHP version in semver format' description: 'PHP version in semver format'
runs: runs:
using: 'node16' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'

489
dist/index.js vendored
View File

@ -127,19 +127,21 @@ async function checkXdebugError(extension, version) {
exports.checkXdebugError = checkXdebugError; exports.checkXdebugError = checkXdebugError;
async function addCoverageXdebug(extension, version, os, pipe) { async function addCoverageXdebug(extension, version, os, pipe) {
let script = '\n'; let script = '\n';
let message = await checkXdebugError(extension, version); const error = await checkXdebugError(extension, version);
let status = '$cross'; if (!error) {
if (!message) {
script += script +=
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe; (await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
extension = extension == 'xdebug3' ? 'xdebug' : extension; extension = extension == 'xdebug3' ? 'xdebug' : extension;
script += script +=
(await extensions.addExtension(extension, version, os, true)) + pipe; (await extensions.addExtension(extension, version, os, true)) + pipe;
script += await utils.setVariable('xdebug_version', 'php -r "echo phpversion(\'xdebug\');"', os); script += await utils.setVariable('xdebug_version', 'php -r "echo phpversion(\'xdebug\');"', os);
message = 'Xdebug $xdebug_version enabled as coverage driver'; script +=
status = '$tick'; (await utils.getCommand(os, 'extension_log')) +
'xdebug "Xdebug $xdebug_version enabled as coverage driver"';
}
else {
script += await utils.addLog('$cross', extension, error, os);
} }
script += await utils.addLog(status, extension, message, os);
return script; return script;
} }
exports.addCoverageXdebug = addCoverageXdebug; exports.addCoverageXdebug = addCoverageXdebug;
@ -154,7 +156,9 @@ async function addCoveragePCOV(version, os, pipe) {
(await extensions.addExtension('pcov', version, os, true)) + pipe; (await extensions.addExtension('pcov', version, os, true)) + pipe;
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n'; script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
script += await utils.setVariable('pcov_version', 'php -r "echo phpversion(\'pcov\');"', os); script += await utils.setVariable('pcov_version', 'php -r "echo phpversion(\'pcov\');"', os);
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV $pcov_version enabled as coverage driver', os); script +=
(await utils.getCommand(os, 'extension_log')) +
'pcov "PCOV $pcov_version enabled as coverage driver"';
break; break;
case /5\.[3-6]|7\.0/.test(version): case /5\.[3-6]|7\.0/.test(version):
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os); script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os);
@ -244,23 +248,25 @@ async function addExtensionDarwin(extension_csv, version) {
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension): case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension): case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin'); add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin');
return; return;
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension): case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix); add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
return; return;
case /.+-\d+\.\d+\.\d+.*/.test(extension): case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix); add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
return; return;
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;
case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(version_extension): case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|snmp|ssh2|swoole|uuid|xdebug|xdebug2|yaml|zmq)/.test(version_extension):
case /(?<!5\.[3-6])(ds|v8js)/.test(version_extension): case /(?<!5\.[3-6])(ds|v8js)/.test(version_extension):
case /(5\.6|7\.[0-4])(propro|lua)/.test(version_extension): case /(5\.6|7\.[0-4])(propro|lua)/.test(version_extension):
case /(?<!5\.[3-6]|7\.0)pcov/.test(version_extension): case /(?<!5\.[3-6]|7\.0)pcov/.test(version_extension):
@ -298,6 +304,8 @@ async function addExtensionWindows(extension_csv, version) {
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension): case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32'); add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
return; return;
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension): case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
@ -306,13 +314,13 @@ async function addExtensionWindows(extension_csv, version) {
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.getUnsupportedLog(extension, version, 'win32'); add_script += await utils.getUnsupportedLog(extension, version, 'win32');
break; break;
case /.+-\d+\.\d+\.\d+$/.test(extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
break;
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension): case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\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].replace('preview', 'devel'), matches[1]); add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]);
break; break;
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
break;
case /7\.[2-4]xdebug2/.test(version_extension): case /7\.[2-4]xdebug2/.test(version_extension):
add_script += '\nAdd-Extension xdebug stable 2.9.8'; add_script += '\nAdd-Extension xdebug stable 2.9.8';
break; break;
@ -358,6 +366,7 @@ async function addExtensionLinux(extension_csv, version) {
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension):
case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension): case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
@ -365,12 +374,13 @@ async function addExtensionLinux(extension_csv, version) {
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux'); add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
return; return;
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension): case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix); add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
return; return;
case /.+-\d+\.\d+\.\d+.*/.test(extension): case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix); add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
return; return;
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
@ -466,7 +476,8 @@ async function fetch(input_url, auth_token, redirect_count = 5) {
const options = { const options = {
hostname: url_object.hostname, hostname: url_object.hostname,
path: url_object.pathname, path: url_object.pathname,
headers: headers headers: headers,
agent: new https.Agent({ keepAlive: false })
}; };
const req = https.get(options, (res) => { const req = https.get(options, (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
@ -548,7 +559,7 @@ async function getScript(os) {
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 tools_csv = await utils.getInput('tools', false); const tools_csv = await utils.getInput('tools', false);
const version = await utils.parseVersion(await utils.getInput('php-version', true)); const version = await utils.parseVersion(await utils.readPHPVersion());
const ini_file = await utils.parseIniFile(await utils.getInput('ini-file', false)); const ini_file = await utils.parseIniFile(await utils.getInput('ini-file', false));
let script = await utils.joins('.', script_path, version, ini_file); let script = await utils.joins('.', script_path, version, ini_file);
if (extension_csv) { if (extension_csv) {
@ -583,6 +594,64 @@ exports.run = run;
/***/ }), /***/ }),
/***/ 5151:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.search = void 0;
const cv = __importStar(__nccwpck_require__(4773));
const fetch = __importStar(__nccwpck_require__(2387));
async function search(package_name, php_version) {
const response = await fetch.fetch(`https://repo.packagist.org/p2/${package_name}.json`);
if (response.error || response.data === '[]') {
return null;
}
const data = JSON.parse(response['data']);
if (data && data.packages) {
const versions = data.packages[package_name];
versions.sort((a, b) => cv.compareVersions(b.version, a.version));
const result = versions.find((versionData) => {
if (versionData?.require?.php) {
return versionData?.require?.php
.split('|')
.some(require => require && cv.satisfies(php_version + '.0', require));
}
return false;
});
return result ? result.version : null;
}
return null;
}
exports.search = search;
//# sourceMappingURL=packagist.js.map
/***/ }),
/***/ 7740: /***/ 7740:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
@ -615,10 +684,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0; exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addCastor = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const fetch = __importStar(__nccwpck_require__(2387)); const fetch = __importStar(__nccwpck_require__(2387));
const packagist = __importStar(__nccwpck_require__(5151));
const utils = __importStar(__nccwpck_require__(918)); const utils = __importStar(__nccwpck_require__(918));
async function getSemverVersion(data) { async function getSemverVersion(data) {
const search = data['version_prefix'] + data['version']; const search = data['version_prefix'] + data['version'];
@ -750,21 +820,40 @@ async function addArchive(data) {
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
async function addPackage(data) { async function addPackage(data) {
const command = await utils.getCommand(data['os'], 'composertool'); const command = await utils.getCommand(data['os'], 'composer_tool');
const parts = data['repository'].split('/'); const parts = data['repository'].split('/');
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']); const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
return command + args; return command + args;
} }
exports.addPackage = addPackage; exports.addPackage = addPackage;
async function addBlackfirePlayer(data) { async function addBlackfirePlayer(data) {
if (/5\.[5-6]|7\.0/.test(data['php_version']) && switch (data['os']) {
data['version'] == 'latest') { case 'win32':
data['version'] = '1.9.3'; return await utils.addLog('$cross', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
default:
if (data['version'] == 'latest') {
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
data['version'] = '1.9.3';
}
else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
data['version'] = '1.22.0';
}
}
data['url'] = await getPharUrl(data);
return addArchive(data);
} }
data['url'] = await getPharUrl(data);
return addArchive(data);
} }
exports.addBlackfirePlayer = addBlackfirePlayer; exports.addBlackfirePlayer = addBlackfirePlayer;
async function addCastor(data) {
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
data['url'] = await getUrl(data);
data['tool'] = 'castor';
data['version_parameter'] = fs_1.default.existsSync('castor.php')
? data['version_parameter']
: '';
return await addArchive(data);
}
exports.addCastor = addCastor;
async function addComposer(data) { async function addComposer(data) {
const channel = data['version'].replace('latest', 'stable'); const channel = data['version'].replace('latest', 'stable');
const github = data['github']; const github = data['github'];
@ -872,6 +961,11 @@ async function addPhive(data) {
} }
exports.addPhive = addPhive; exports.addPhive = addPhive;
async function addPHPUnitTools(data) { async function addPHPUnitTools(data) {
if (data['version'] === 'latest') {
data['version'] =
(await packagist.search(data['packagist'], data['php_version'])) ??
'latest';
}
data['url'] = await getPharUrl(data); data['url'] = await getPharUrl(data);
return await addArchive(data); return await addArchive(data);
} }
@ -923,6 +1017,7 @@ async function getData(release, php_version, os) {
data['extension'] ??= '.phar'; data['extension'] ??= '.phar';
data['os'] = os; data['os'] = os;
data['php_version'] = php_version; data['php_version'] = php_version;
data['packagist'] ??= data['repository'];
data['prefix'] = data['github'] === data['domain'] ? 'releases' : ''; data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
data['verb'] = data['github'] === data['domain'] ? 'download' : ''; data['verb'] = data['github'] === data['domain'] ? 'download' : '';
data['fetch_latest'] ??= 'false'; data['fetch_latest'] ??= 'false';
@ -937,6 +1032,7 @@ async function getData(release, php_version, os) {
} }
exports.getData = getData; exports.getData = getData;
exports.functionRecord = { exports.functionRecord = {
castor: addCastor,
composer: addComposer, composer: addComposer,
deployer: addDeployer, deployer: addDeployer,
dev_tools: addDevTools, dev_tools: addDevTools,
@ -1019,8 +1115,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setVariable = exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseIniFile = exports.parseVersion = exports.getManifestURL = exports.getInput = exports.readEnv = void 0; exports.setVariable = exports.readPHPVersion = exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseIniFile = exports.parseVersion = exports.getManifestURL = exports.getInput = exports.readEnv = void 0;
const fs_1 = __importDefault(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const fetch = __importStar(__nccwpck_require__(2387)); const fetch = __importStar(__nccwpck_require__(2387));
@ -1055,10 +1155,9 @@ async function getManifestURL() {
} }
exports.getManifestURL = getManifestURL; exports.getManifestURL = getManifestURL;
async function parseVersion(version) { async function parseVersion(version) {
const manifest = await getManifestURL();
switch (true) { switch (true) {
case /^(latest|nightly|\d+\.x)$/.test(version): case /^(latest|nightly|\d+\.x)$/.test(version):
return JSON.parse((await fetch.fetch(manifest))['data'])[version]; return JSON.parse((await fetch.fetch(await getManifestURL()))['data'])[version];
default: default:
switch (true) { switch (true) {
case version.length > 1: case version.length > 1:
@ -1173,7 +1272,8 @@ async function CSVArray(values_csv) {
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'") .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
.replace(/=(.*?)(=.*)/, "='$1$2'"); .replace(/=(.*?)(=.*)/, "='$1$2'")
.replace(/:\s*["'](.*?)/g, ':$1');
}) })
.filter(Boolean); .filter(Boolean);
} }
@ -1212,7 +1312,12 @@ async function getCommand(os, suffix) {
case 'darwin': case 'darwin':
return 'add_' + suffix + ' '; return 'add_' + suffix + ' ';
case 'win32': case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; return ('Add-' +
suffix
.split('_')
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join('') +
' ');
default: default:
return await log('Platform ' + os + ' is not supported', os, 'error'); return await log('Platform ' + os + ' is not supported', os, 'error');
} }
@ -1261,6 +1366,38 @@ async function parseExtensionSource(extension, prefix) {
return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix); return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix);
} }
exports.parseExtensionSource = parseExtensionSource; exports.parseExtensionSource = parseExtensionSource;
async function readPHPVersion() {
const version = await getInput('php-version', false);
if (version) {
return version;
}
const versionFile = (await getInput('php-version-file', false)) || '.php-version';
if (fs_1.default.existsSync(versionFile)) {
return fs_1.default.readFileSync(versionFile, 'utf8').replace(/[\r\n]/g, '');
}
else if (versionFile !== '.php-version') {
throw new Error(`Could not find '${versionFile}' file.`);
}
const composerLock = 'composer.lock';
if (fs_1.default.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs_1.default.readFileSync(composerLock, 'utf8'));
if (lockFileContents['platform-overrides'] &&
lockFileContents['platform-overrides']['php']) {
return lockFileContents['platform-overrides']['php'];
}
}
const composerJson = 'composer.json';
if (fs_1.default.existsSync(composerJson)) {
const composerFileContents = JSON.parse(fs_1.default.readFileSync(composerJson, 'utf8'));
if (composerFileContents['config'] &&
composerFileContents['config']['platform'] &&
composerFileContents['config']['platform']['php']) {
return composerFileContents['config']['platform']['php'];
}
}
return 'latest';
}
exports.readPHPVersion = readPHPVersion;
async function setVariable(variable, command, os) { async function setVariable(variable, command, os) {
switch (os) { switch (os) {
case 'win32': case 'win32':
@ -1833,7 +1970,7 @@ class OidcClient {
.catch(error => { .catch(error => {
throw new Error(`Failed to get ID Token. \n throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`); Error Message: ${error.message}`);
}); });
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) { if (!id_token) {
@ -3807,11 +3944,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
var _a; var _a;
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; _a = fs.promises
// export const {open} = 'fs'
, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
// export const {open} = 'fs'
exports.IS_WINDOWS = process.platform === 'win32'; exports.IS_WINDOWS = process.platform === 'win32';
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
exports.UV_FS_O_EXLOCK = 0x10000000;
exports.READONLY = fs.constants.O_RDONLY;
function exists(fsPath) { function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@ -3992,12 +4135,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
const assert_1 = __nccwpck_require__(9491); const assert_1 = __nccwpck_require__(9491);
const childProcess = __importStar(__nccwpck_require__(2081));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const util_1 = __nccwpck_require__(3837);
const ioUtil = __importStar(__nccwpck_require__(1962)); const ioUtil = __importStar(__nccwpck_require__(1962));
const exec = util_1.promisify(childProcess.exec);
const execFile = util_1.promisify(childProcess.execFile);
/** /**
* Copies a file or folder. * Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@ -4078,61 +4217,23 @@ exports.mv = mv;
function rmRF(inputPath) { function rmRF(inputPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (ioUtil.IS_WINDOWS) { if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
// Check for invalid characters // Check for invalid characters
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
if (/[*"<>|]/.test(inputPath)) { if (/[*"<>|]/.test(inputPath)) {
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows'); throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
} }
try {
const cmdPath = ioUtil.getCmdPath();
if (yield ioUtil.isDirectory(inputPath, true)) {
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: { inputPath }
});
}
else {
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: { inputPath }
});
}
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try {
yield ioUtil.unlink(inputPath);
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
} }
else { try {
let isDir = false; // note if path does not exist, error is silent
try { yield ioUtil.rm(inputPath, {
isDir = yield ioUtil.isDirectory(inputPath); force: true,
} maxRetries: 3,
catch (err) { recursive: true,
// if you try to delete a file that doesn't exist, desired result is achieved retryDelay: 300
// other errors are valid });
if (err.code !== 'ENOENT') }
throw err; catch (err) {
return; throw new Error(`File was unable to be removed ${err}`);
}
if (isDir) {
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
}
else {
yield ioUtil.unlink(inputPath);
}
} }
}); });
} }
@ -4302,6 +4403,228 @@ function copyFile(srcFile, destFile, force) {
} }
//# sourceMappingURL=io.js.map //# sourceMappingURL=io.js.map
/***/ }),
/***/ 4773:
/***/ (function(__unused_webpack_module, exports) {
(function (global, factory) {
true ? factory(exports) :
0;
})(this, (function (exports) { 'use strict';
const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
const validateAndParse = (version) => {
if (typeof version !== 'string') {
throw new TypeError('Invalid argument expected string');
}
const match = version.match(semver);
if (!match) {
throw new Error(`Invalid argument not valid semver ('${version}' received)`);
}
match.shift();
return match;
};
const isWildcard = (s) => s === '*' || s === 'x' || s === 'X';
const tryParse = (v) => {
const n = parseInt(v, 10);
return isNaN(n) ? v : n;
};
const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
const compareStrings = (a, b) => {
if (isWildcard(a) || isWildcard(b))
return 0;
const [ap, bp] = forceType(tryParse(a), tryParse(b));
if (ap > bp)
return 1;
if (ap < bp)
return -1;
return 0;
};
const compareSegments = (a, b) => {
for (let i = 0; i < Math.max(a.length, b.length); i++) {
const r = compareStrings(a[i] || '0', b[i] || '0');
if (r !== 0)
return r;
}
return 0;
};
/**
* Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
* This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
* @param v1 - First version to compare
* @param v2 - Second version to compare
* @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
*/
const compareVersions = (v1, v2) => {
// validate input and split into segments
const n1 = validateAndParse(v1);
const n2 = validateAndParse(v2);
// pop off the patch
const p1 = n1.pop();
const p2 = n2.pop();
// validate numbers
const r = compareSegments(n1, n2);
if (r !== 0)
return r;
// validate pre-release
if (p1 && p2) {
return compareSegments(p1.split('.'), p2.split('.'));
}
else if (p1 || p2) {
return p1 ? -1 : 1;
}
return 0;
};
/**
* Compare [semver](https://semver.org/) version strings using the specified operator.
*
* @param v1 First version to compare
* @param v2 Second version to compare
* @param operator Allowed arithmetic operator to use
* @returns `true` if the comparison between the firstVersion and the secondVersion satisfies the operator, `false` otherwise.
*
* @example
* ```
* compare('10.1.8', '10.0.4', '>'); // return true
* compare('10.0.1', '10.0.1', '='); // return true
* compare('10.1.1', '10.2.2', '<'); // return true
* compare('10.1.1', '10.2.2', '<='); // return true
* compare('10.1.1', '10.2.2', '>='); // return false
* ```
*/
const compare = (v1, v2, operator) => {
// validate input operator
assertValidOperator(operator);
// since result of compareVersions can only be -1 or 0 or 1
// a simple map can be used to replace switch
const res = compareVersions(v1, v2);
return operatorResMap[operator].includes(res);
};
const operatorResMap = {
'>': [1],
'>=': [0, 1],
'=': [0],
'<=': [-1, 0],
'<': [-1],
'!=': [-1, 1],
};
const allowedOperators = Object.keys(operatorResMap);
const assertValidOperator = (op) => {
if (typeof op !== 'string') {
throw new TypeError(`Invalid operator type, expected string but got ${typeof op}`);
}
if (allowedOperators.indexOf(op) === -1) {
throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
}
};
/**
* Match [npm semver](https://docs.npmjs.com/cli/v6/using-npm/semver) version range.
*
* @param version Version number to match
* @param range Range pattern for version
* @returns `true` if the version number is within the range, `false` otherwise.
*
* @example
* ```
* satisfies('1.1.0', '^1.0.0'); // return true
* satisfies('1.1.0', '~1.0.0'); // return false
* ```
*/
const satisfies = (version, range) => {
// clean input
range = range.replace(/([><=]+)\s+/g, '$1');
// handle multiple comparators
if (range.includes('||')) {
return range.split('||').some((r) => satisfies(version, r));
}
else if (range.includes(' - ')) {
const [a, b] = range.split(' - ', 2);
return satisfies(version, `>=${a} <=${b}`);
}
else if (range.includes(' ')) {
return range
.trim()
.replace(/\s{2,}/g, ' ')
.split(' ')
.every((r) => satisfies(version, r));
}
// if no range operator then "="
const m = range.match(/^([<>=~^]+)/);
const op = m ? m[1] : '=';
// if gt/lt/eq then operator compare
if (op !== '^' && op !== '~')
return compare(version, range, op);
// else range of either "~" or "^" is assumed
const [v1, v2, v3, , vp] = validateAndParse(version);
const [r1, r2, r3, , rp] = validateAndParse(range);
const v = [v1, v2, v3];
const r = [r1, r2 !== null && r2 !== void 0 ? r2 : 'x', r3 !== null && r3 !== void 0 ? r3 : 'x'];
// validate pre-release
if (rp) {
if (!vp)
return false;
if (compareSegments(v, r) !== 0)
return false;
if (compareSegments(vp.split('.'), rp.split('.')) === -1)
return false;
}
// first non-zero number
const nonZero = r.findIndex((v) => v !== '0') + 1;
// pointer to where segments can be >=
const i = op === '~' ? 2 : nonZero > 1 ? nonZero : 1;
// before pointer must be equal
if (compareSegments(v.slice(0, i), r.slice(0, i)) !== 0)
return false;
// after pointer must be >=
if (compareSegments(v.slice(i), r.slice(i)) === -1)
return false;
return true;
};
/**
* Validate [semver](https://semver.org/) version strings.
*
* @param version Version number to validate
* @returns `true` if the version number is a valid semver version number, `false` otherwise.
*
* @example
* ```
* validate('1.0.0-rc.1'); // return true
* validate('1.0-rc.1'); // return false
* validate('foo'); // return false
* ```
*/
const validate = (version) => typeof version === 'string' && /^[v\d]/.test(version) && semver.test(version);
/**
* Validate [semver](https://semver.org/) version strings strictly. Will not accept wildcards and version ranges.
*
* @param version Version number to validate
* @returns `true` if the version number is a valid semver version number `false` otherwise
*
* @example
* ```
* validate('1.0.0-rc.1'); // return true
* validate('1.0-rc.1'); // return false
* validate('foo'); // return false
* ```
*/
const validateStrict = (version) => typeof version === 'string' &&
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/.test(version);
exports.compare = compare;
exports.compareVersions = compareVersions;
exports.satisfies = satisfies;
exports.validate = validate;
exports.validateStrict = validateStrict;
}));
//# sourceMappingURL=index.js.map
/***/ }), /***/ }),
/***/ 4294: /***/ 4294:

View File

@ -11,7 +11,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -19,7 +19,7 @@ jobs:
# blackfire-player supports PHP >= 5.5 # blackfire-player supports PHP >= 5.5
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -19,7 +19,7 @@ jobs:
# Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows # Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -28,7 +28,7 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -28,7 +28,7 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -79,7 +79,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -37,7 +37,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -39,7 +39,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -12,7 +12,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -37,7 +37,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -39,7 +39,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -12,7 +12,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -36,7 +36,7 @@ jobs:
# php-versions: ['7.0', '7.1', '7.2', '7.3'] # php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -37,7 +37,7 @@ jobs:
# php-versions: ['7.0', '7.1', '7.2', '7.3'] # php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -9,10 +9,10 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
node-versions: [16'] node-versions: ['16']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -23,7 +23,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -23,7 +23,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -12,7 +12,7 @@ jobs:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -29,7 +29,7 @@ jobs:
php-versions: ['7.4', '8.0'] php-versions: ['7.4', '8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -29,7 +29,7 @@ jobs:
php-versions: ['7.4', '8.0'] php-versions: ['7.4', '8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

6464
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.23.0", "version": "2.27.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "lib/install.js", "main": "lib/install.js",
@ -34,28 +34,29 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2" "@actions/io": "^1.1.3",
"compare-versions": "^6.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.2.4", "@types/jest": "^29.5.7",
"@types/node": "^18.11.17", "@types/node": "^20.8.10",
"@typescript-eslint/eslint-plugin": "^5.47.0", "@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^5.47.0", "@typescript-eslint/parser": "^6.9.1",
"@vercel/ncc": "^0.36.0", "@vercel/ncc": "^0.38.1",
"eslint": "^8.30.0", "eslint": "^8.52.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.1.7", "eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^5.0.1",
"jest": "^29.3.1", "jest": "^29.7.0",
"jest-circus": "^29.3.1", "jest-circus": "^29.7.0",
"nock": "^13.2.9", "nock": "^13.3.7",
"prettier": "^2.8.1", "prettier": "^3.0.3",
"simple-git-hooks": "^2.8.1", "simple-git-hooks": "^2.9.0",
"ts-jest": "^29.0.3", "ts-jest": "^29.1.1",
"typescript": "^4.9.4" "typescript": "^5.2.2"
}, },
"bugs": { "bugs": {
"url": "https://github.com/shivammathur/setup-php/issues" "url": "https://github.com/shivammathur/setup-php/issues"

View File

@ -30,9 +30,11 @@ psr=psr
raphf=raphf raphf=raphf
rdkafka=rdkafka rdkafka=rdkafka
redis=redis redis=redis
snmp=snmp
sqlsrv=sqlsrv sqlsrv=sqlsrv
ssh2=ssh2 ssh2=ssh2
swoole=swoole swoole=swoole
uuid=uuid
v8js=v8js v8js=v8js
vips=vips vips=vips
xdebug=xdebug xdebug=xdebug

30
src/configs/mod_priority Normal file
View File

@ -0,0 +1,30 @@
apc=25
apcu_bc=25
apcu-bc=25
blackfire=30
couchbase=30
decimal=30
ds=30
event=30
grpc=30
http=25
pecl_http=25
pecl-http=25
psr=15
inotify=30
libvirt-php=40
mailparse=25
maxminddb=30
memcached=25
mysqlnd=10
mysqlnd_ms=30
opcache=10
pdo=10
phalcon=35
protobuf=30
psr=15
rdkafka=30
swoole=25
vips=30
xml=15
zstd=30

View File

@ -1,4 +1,13 @@
{ {
"box": {
"type": "phar",
"repository": "box-project/box",
"packagist": "humbug/box",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "--version"
},
"churn": { "churn": {
"type": "phar", "type": "phar",
"repository": "bmitch/churn-php", "repository": "bmitch/churn-php",
@ -64,6 +73,15 @@
"version_prefix": "v", "version_prefix": "v",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"php-scoper": {
"type": "phar",
"repository": "humbug/php-scoper",
"packagist": "humbug/php-scoper",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "--version"
},
"phpcbf": { "phpcbf": {
"type": "phar", "type": "phar",
"repository": "squizlabs/PHP_CodeSniffer", "repository": "squizlabs/PHP_CodeSniffer",
@ -222,6 +240,14 @@
"version_prefix": "v", "version_prefix": "v",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"castor": {
"type": "custom-function",
"domain": "https://github.com",
"repository": "jolicode/castor",
"function": "castor",
"version_prefix": "v",
"version_parameter": "-V"
},
"composer": { "composer": {
"type": "custom-function", "type": "custom-function",
"domain": "https://getcomposer.org", "domain": "https://getcomposer.org",
@ -268,6 +294,7 @@
"phpunit": { "phpunit": {
"type": "custom-function", "type": "custom-function",
"repository": "sebastianbergmann/phpunit", "repository": "sebastianbergmann/phpunit",
"packagist": "phpunit/phpunit",
"domain": "https://phar.phpunit.de", "domain": "https://phar.phpunit.de",
"function": "phpunit", "function": "phpunit",
"version_prefix": "", "version_prefix": "",

View File

@ -13,6 +13,7 @@
"fetch_latest": "true", "fetch_latest": "true",
"function": "function_name", "function": "function_name",
"repository": "user/tool", "repository": "user/tool",
"packagist": "user/tool",
"scope": "global, scoped", "scope": "global, scoped",
"type": "phar, composer, custom-package or custom-function", "type": "phar, composer, custom-package or custom-function",
"version_parameter": "--version", "version_parameter": "--version",
@ -77,6 +78,15 @@
"user/tool" "user/tool"
] ]
}, },
"packagist": {
"$id": "#/items/properties/packagist",
"type": "string",
"title": "The repository schema",
"description": "Packagist repository of the tool in case different from repository.",
"examples": [
"user/tool"
]
},
"scope": { "scope": {
"$id": "#/items/properties/scope", "$id": "#/items/properties/scope",
"type": "string", "type": "string",

View File

@ -16,7 +16,7 @@ export async function checkXdebugError(
} }
/** /**
* Function to setup Xdebug * Function to set up Xdebug
* *
* @param extension * @param extension
* @param version * @param version
@ -30,9 +30,8 @@ export async function addCoverageXdebug(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
let message: string = await checkXdebugError(extension, version); const error: string = await checkXdebugError(extension, version);
let status = '$cross'; if (!error) {
if (!message) {
script += script +=
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe; (await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
extension = extension == 'xdebug3' ? 'xdebug' : extension; extension = extension == 'xdebug3' ? 'xdebug' : extension;
@ -43,15 +42,17 @@ export async function addCoverageXdebug(
'php -r "echo phpversion(\'xdebug\');"', 'php -r "echo phpversion(\'xdebug\');"',
os os
); );
message = 'Xdebug $xdebug_version enabled as coverage driver'; script +=
status = '$tick'; (await utils.getCommand(os, 'extension_log')) +
'xdebug "Xdebug $xdebug_version enabled as coverage driver"';
} else {
script += await utils.addLog('$cross', extension, error, os);
} }
script += await utils.addLog(status, extension, message, os);
return script; return script;
} }
/** /**
* Function to setup PCOV * Function to set up PCOV
* *
* @param version * @param version
* @param os * @param os
@ -76,14 +77,9 @@ export async function addCoveragePCOV(
'php -r "echo phpversion(\'pcov\');"', 'php -r "echo phpversion(\'pcov\');"',
os os
); );
// success script +=
script += await utils.addLog( (await utils.getCommand(os, 'extension_log')) +
'$tick', 'pcov "PCOV $pcov_version enabled as coverage driver"';
'coverage: pcov',
'PCOV $pcov_version enabled as coverage driver',
os
);
// version is not supported
break; break;
case /5\.[3-6]|7\.0/.test(version): case /5\.[3-6]|7\.0/.test(version):

View File

@ -31,11 +31,14 @@ export async function addExtensionDarwin(
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
// match 7.4relay...8.3relay
// match 5.3blackfire...8.2blackfire // match 5.3blackfire...8.2blackfire
// match 5.3blackfire-(semver)...8.1blackfire-(semver) // match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http // match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5 // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
// match 7.0zephir_parser...8.2zephir_parser
case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -47,6 +50,9 @@ export async function addExtensionDarwin(
version_extension version_extension
): ):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -64,7 +70,7 @@ export async function addExtensionDarwin(
); );
return; return;
// match semver // match semver
case /.+-\d+\.\d+\.\d+.*/.test(extension): case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins( add_script += await utils.joins(
'\nadd_pecl_extension', '\nadd_pecl_extension',
ext_name, ext_name,
@ -77,7 +83,7 @@ export async function addExtensionDarwin(
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin'); add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match brew extensions // match brew extensions
case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test( case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|snmp|ssh2|swoole|uuid|xdebug|xdebug2|yaml|zmq)/.test(
version_extension version_extension
): ):
case /(?<!5\.[3-6])(ds|v8js)/.test(version_extension): case /(?<!5\.[3-6])(ds|v8js)/.test(version_extension):
@ -134,6 +140,7 @@ export async function addExtensionWindows(
// match 5.3ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5 // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http // match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
// match 7.0zephir_parser...8.2zephir_parser
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -143,6 +150,10 @@ export async function addExtensionWindows(
version_extension version_extension
): ):
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension): case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -166,15 +177,6 @@ export async function addExtensionWindows(
'win32' 'win32'
); );
break; break;
// match semver without state
case /.+-\d+\.\d+\.\d+$/.test(extension):
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
'stable',
ext_version
);
break;
// match semver with state // match semver with state
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension): case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec( matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec(
@ -187,6 +189,15 @@ export async function addExtensionWindows(
matches[1] matches[1]
); );
break; break;
// match semver without state
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
'stable',
ext_version
);
break;
// match 7.2xdebug2 to 7.4xdebug2 // match 7.2xdebug2 to 7.4xdebug2
case /7\.[2-4]xdebug2/.test(version_extension): case /7\.[2-4]xdebug2/.test(version_extension):
add_script += '\nAdd-Extension xdebug stable 2.9.8'; add_script += '\nAdd-Extension xdebug stable 2.9.8';
@ -252,12 +263,15 @@ export async function addExtensionLinux(
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
// match 7.4relay...8.3relay
// match 5.3blackfire...8.2blackfire // match 5.3blackfire...8.2blackfire
// match 5.3blackfire-(semver)...8.1blackfire-(semver) // match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// match couchbase, geos, pdo_oci, oci8, http, pecl_http // match couchbase, geos, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5 // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
// match 7.0zephir_parser...8.2zephir_parser
case /^(7\.4|8\.[0-3])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -273,6 +287,9 @@ export async function addExtensionLinux(
version_extension version_extension
): ):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -290,7 +307,7 @@ export async function addExtensionLinux(
); );
return; return;
// match semver versions // match semver versions
case /.+-\d+\.\d+\.\d+.*/.test(extension): case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins( add_script += await utils.joins(
'\nadd_pecl_extension', '\nadd_pecl_extension',
ext_name, ext_name,

View File

@ -26,7 +26,8 @@ export async function fetch(
const options: https.RequestOptions = { const options: https.RequestOptions = {
hostname: url_object.hostname, hostname: url_object.hostname,
path: url_object.pathname, path: url_object.pathname,
headers: headers headers: headers,
agent: new https.Agent({keepAlive: false})
}; };
const req = https.get(options, (res: IncomingMessage) => { const req = https.get(options, (res: IncomingMessage) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {

View File

@ -24,7 +24,7 @@ export async function getScript(os: string): Promise<string> {
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
const tools_csv: string = await utils.getInput('tools', false); const tools_csv: string = await utils.getInput('tools', false);
const version: string = await utils.parseVersion( const version: string = await utils.parseVersion(
await utils.getInput('php-version', true) await utils.readPHPVersion()
); );
const ini_file: string = await utils.parseIniFile( const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false) await utils.getInput('ini-file', false)

37
src/packagist.ts Normal file
View File

@ -0,0 +1,37 @@
import * as cv from 'compare-versions';
import * as fetch from './fetch';
type RS = Record<string, string>;
type RSRS = Record<string, RS>;
export async function search(
package_name: string,
php_version: string
): Promise<string | null> {
const response = await fetch.fetch(
`https://repo.packagist.org/p2/${package_name}.json`
);
if (response.error || response.data === '[]') {
return null;
}
const data = JSON.parse(response['data']);
if (data && data.packages) {
const versions = data.packages[package_name];
versions.sort((a: RS, b: RS) => cv.compareVersions(b.version, a.version));
const result = versions.find((versionData: RSRS) => {
if (versionData?.require?.php) {
return versionData?.require?.php
.split('|')
.some(
require => require && cv.satisfies(php_version + '.0', require)
);
}
return false;
});
return result ? result.version : null;
}
return null;
}

View File

@ -43,7 +43,9 @@ copy_brew_extensions() {
extension_file="${brew_prefix:?}/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so" extension_file="${brew_prefix:?}/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so"
[ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir" [ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir"
done done
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \; if [ -d "$brew_prefix"/Cellar/"$formula"@"$version" ]; then
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
fi
} }
# Function to install a php extension from shivammathur/extensions tap. # Function to install a php extension from shivammathur/extensions tap.
@ -60,8 +62,7 @@ add_brew_extension() {
sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true
update_dependencies >/dev/null 2>&1 update_dependencies >/dev/null 2>&1
disable_dependency_extensions "$extension" >/dev/null 2>&1 disable_dependency_extensions "$extension" >/dev/null 2>&1
brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1 (brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1
copy_brew_extensions "$formula"
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
} }
@ -104,6 +105,15 @@ link_libraries() {
done done
} }
# Link opcache extension to extensions directory.
link_opcache() {
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
if [ -e "$opcache_ini" ]; then
opcache_ext=$(grep -Eo "zend_extension.*opcache.*\.so" "$opcache_ini" | cut -d '"' -f 2)
sudo ln -sf "$opcache_ext" "$ext_dir"
fi
}
# Patch brew to overwrite packages. # Patch brew to overwrite packages.
patch_brew() { patch_brew() {
formula_installer="${brew_repo:?}"/Library/Homebrew/formula_installer.rb formula_installer="${brew_repo:?}"/Library/Homebrew/formula_installer.rb
@ -153,8 +163,11 @@ fix_dependencies() {
# Function to get PHP version if it is already installed using Homebrew. # Function to get PHP version if it is already installed using Homebrew.
get_brewed_php() { get_brewed_php() {
php_cellar="$brew_prefix"/Cellar/php cellar="$brew_prefix"/Cellar
if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then php_cellar="$cellar"/php
if [ -d "$cellar" ] && ! [[ "$(find "$cellar" -maxdepth 1 -name "php@$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
php_semver | cut -c 1-3
elif [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
php_semver | cut -c 1-3 php_semver | cut -c 1-3
else else
echo 'false'; echo 'false';
@ -233,6 +246,7 @@ setup_php() {
semver="$(php_semver)" semver="$(php_semver)"
extra_version="$(php_extra_version)" extra_version="$(php_extra_version)"
configure_php configure_php
link_opcache
set_output "php-version" "$semver" set_output "php-version" "$semver"
if [ "${semver%.*}" != "$version" ]; then if [ "${semver%.*}" != "$version" ]; then
add_log "${cross:?}" "PHP" "Could not setup PHP $version" add_log "${cross:?}" "PHP" "Could not setup PHP $version"

View File

@ -1,3 +1,32 @@
# Function to check if extension is enabled.
Function Test-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
return $null -ne $extension_info
}
# Function to add extension log.
Function Add-ExtensionLog() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
$extension,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
$message
)
if (Test-Extension $extension) {
Add-Log $tick $extension $message
} else {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
}
}
# Function to link dependencies to PHP directory. # Function to link dependencies to PHP directory.
Function Set-ExtensionPrerequisites Function Set-ExtensionPrerequisites
{ {
@ -48,7 +77,7 @@ Function Add-NightlyExtension {
if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' } if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
$repo = "$github/shivammathur/php-extensions-windows" $repo = "$github/shivammathur/php-extensions-windows"
$url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll" $url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile "$ext_dir\php_$extension.dll" Get-File -Url $url -OutFile "$ext_dir\php_$extension.dll"
if(Test-Path "$ext_dir\php_$extension.dll") { if(Test-Path "$ext_dir\php_$extension.dll") {
Enable-Extension $extension > $null Enable-Extension $extension > $null
} else { } else {

View File

@ -48,7 +48,19 @@ enable_extension() {
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete [ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
enable_extension_dependencies "$1" "$2" enable_extension_dependencies "$1" "$2"
enable_cache_extension_dependencies "$1" "$2" enable_cache_extension_dependencies "$1" "$2"
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod >/dev/null 2>&1; then
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "$pecl_file"
mod="${ini_dir:?}"/../mods-available/"$1".ini
if ! [ -e "$mod" ]; then
priority="${3:-20}";
mod_priority_line="$(grep -E "^$1=" "${src:?}/configs/mod_priority")";
[ -n "$mod_priority_line" ] && priority=$(echo "$mod_priority_line" | cut -d'=' -f 2)
(echo "; priority=$priority"; echo "$2=${ext_dir:?}/$1.so") | sudo tee "$mod" >/dev/null
fi
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
else
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
fi
fi fi
} }
@ -114,7 +126,7 @@ disable_all_shared() {
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
mkdir -p /tmp/extdisabled/"$version" mkdir -p /tmp/extdisabled/"$version"
sudo rm -f /tmp/php"$version"_extensions sudo rm -f /tmp/php"$version"_extensions
sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -n 1 -I{} touch /tmp/extdisabled/"$version"/{} sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -I{} touch /tmp/extdisabled/"$version"/{}
add_log "${tick:?}" "none" "Disabled all shared extensions" add_log "${tick:?}" "none" "Disabled all shared extensions"
} }
@ -123,7 +135,6 @@ configure_pecl() {
[ -z "${pecl_file:-${ini_file[@]}}" ] && return [ -z "${pecl_file:-${ini_file[@]}}" ] && return
if ! [ -e /tmp/pecl_config ]; then if ! [ -e /tmp/pecl_config ]; then
for script in pear pecl; do for script in pear pecl; do
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
sudo "$script" channel-update "$script".php.net sudo "$script" channel-update "$script".php.net
done done
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1 echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
@ -163,17 +174,23 @@ get_pecl_version() {
# Function to install PECL extensions and accept default options # Function to install PECL extensions and accept default options
pecl_install() { pecl_install() {
local extension=$1 local extension=$1
local prefix=${2:-extension}
add_pecl >/dev/null 2>&1 add_pecl >/dev/null 2>&1
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')" cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'" prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)" suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)" IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1 (( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
disable_extension_helper "${extension%-*}" >/dev/null 2>&1
if [ "$version" = "5.3" ]; then if [ "$version" = "5.3" ]; then
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1 yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
else else
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1 yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
fi fi
local exit_code=$?
sudo pecl info "$extension" | grep -iq 'zend extension' && prefix=zend_extension
enable_extension "${extension%-*}" "$prefix"
return "$exit_code"
} }
# Function to install a specific version of PECL extension. # Function to install a specific version of PECL extension.
@ -186,10 +203,9 @@ add_pecl_extension() {
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
ext_version=$(php -r "echo phpversion('$extension');") ext_version=$(php -r "echo phpversion('$extension');")
if [ "${ext_version/-/}" = "$pecl_version" ]; then if check_extension "$extension" && [[ -z "$pecl_version" || (-n "$pecl_version" && "${ext_version/-/}" == "$pecl_version") ]]; then
add_log "${tick:?}" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
disable_extension_helper "$extension" >/dev/null 2>&1
[ -n "$pecl_version" ] && pecl_version="-$pecl_version" [ -n "$pecl_version" ] && pecl_version="-$pecl_version"
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1 pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1
extension_version="$(php -r "echo phpversion('$extension');")" extension_version="$(php -r "echo phpversion('$extension');")"

View File

@ -21,7 +21,7 @@ Function Add-Blackfire() {
$status="Enabled" $status="Enabled"
} else { } else {
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" } $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
Invoke-WebRequest -Uri "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1 Get-File -Url "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1
Enable-PhpExtension -Extension blackfire -Path $php_dir Enable-PhpExtension -Extension blackfire -Path $php_dir
$status="Installed and enabled" $status="Installed and enabled"
} }

View File

@ -17,12 +17,6 @@ add_couchbase_clibs() {
} }
add_couchbase_cxxlibs() { add_couchbase_cxxlibs() {
if [ "$VERSION_ID" = "18.04" ]; then
if ! command -v gcc-8 >/dev/null || ! command -v g++-8 >/dev/null; then
install_packages gcc-8 g++-8 -y
fi
printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-8 8
fi
if [ "${runner:?}" = "self-hosted" ]; then if [ "${runner:?}" = "self-hosted" ]; then
add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main
fi fi
@ -38,6 +32,8 @@ get_couchbase_version() {
echo couchbase-3.0.4 echo couchbase-3.0.4
elif [ "${version:?}" = '7.3' ]; then elif [ "${version:?}" = '7.3' ]; then
echo couchbase-3.2.2 echo couchbase-3.2.2
elif [ "${version:?}" = '7.4' ]; then
echo couchbase-4.1.0
else else
echo couchbase echo couchbase
fi fi
@ -61,6 +57,9 @@ add_couchbase() {
else else
if [ "$ext" = "couchbase" ]; then if [ "$ext" = "couchbase" ]; then
ext="couchbase-$(get_pecl_version "couchbase" "stable")" ext="couchbase-$(get_pecl_version "couchbase" "stable")"
n_proc="$(nproc)"
export COUCHBASE_SUFFIX_OPTS="CMAKE_BUILD_TYPE=Release"
export CMAKE_BUILD_PARALLEL_LEVEL="$n_proc"
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1 add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
else else
pecl_install "${ext}" >/dev/null 2>&1 pecl_install "${ext}" >/dev/null 2>&1

View File

@ -4,7 +4,7 @@ Function Add-Choco() {
# Source: https://docs.chocolatey.org/en-us/choco/setup # Source: https://docs.chocolatey.org/en-us/choco/setup
Set-ExecutionPolicy Bypass -Scope Process -Force Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
} }
} catch { } } catch { }
} }

View File

@ -13,7 +13,7 @@ Function Get-ICUUrl() {
$trunk = "https://windows.php.net" $trunk = "https://windows.php.net"
$urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}") $urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}")
foreach ($url in $urls) { foreach ($url in $urls) {
$web_content = Invoke-WebRequest -Uri $url $web_content = Get-File -Url $url
foreach ($link in $web_content.Links) { foreach ($link in $web_content.Links) {
if ($link -match "/.*ICU-${icu_version}.*/") { if ($link -match "/.*ICU-${icu_version}.*/") {
return $trunk + $link.HREF return $trunk + $link.HREF
@ -32,7 +32,7 @@ Function Repair-ICU() {
$zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs $zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs
if ($zip_url -ne '') { if ($zip_url -ne '') {
New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" -Force > $null 2>&1 New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" -Force > $null 2>&1
Invoke-WebRequest -Uri $zip_url -OutFile "$php_dir\icu\icu.zip" Get-File -Url $zip_url -OutFile "$php_dir\icu\icu.zip"
Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force
Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force
} }
@ -47,10 +47,5 @@ Function Add-Http() {
} }
Add-Extension pecl_http >$null 2>&1 Add-Extension pecl_http >$null 2>&1
Repair-ICU Repair-ICU
try { Add-ExtensionLog http "Installed and enabled"
php --ri "http" 2> $null | Out-Null
Add-Log $tick "http" "Installed and enabled"
} catch {
Add-Log $cross "http" "Could not install http on PHP $( $installed.FullVersion )"
}
} }

View File

@ -15,8 +15,9 @@ add_intl() {
if [ "$icu" != "$supported_version" ]; then if [ "$icu" != "$supported_version" ]; then
add_log "${cross:?}" "intl" "ICU $icu is not supported" add_log "${cross:?}" "intl" "ICU $icu is not supported"
else else
[ "${ts:?}" = 'zts' ] && suffix='-zts'
install_icu "$icu" >/dev/null 2>&1 install_icu "$icu" >/dev/null 2>&1
get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl/php${version:?}-intl-$icu.so" get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl/php${version:?}-intl-$icu$suffix.so"
enable_extension intl extension enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu" add_extension_log intl "Installed and enabled with ICU $icu"
fi fi

View File

@ -20,7 +20,7 @@ Function Add-Ioncube() {
if (-not($installed.ThreadSafe)) { if (-not($installed.ThreadSafe)) {
$ts_part = "_nonts" $ts_part = "_nonts"
} }
Invoke-WebRequest -Uri "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip Get-File -Url "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip
Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force
Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll
} }

View File

@ -14,7 +14,7 @@ Function Add-InstantClient() {
if ($arch -eq 'x86') { if ($arch -eq 'x86') {
$suffix = 'nt' $suffix = 'nt'
} }
Invoke-WebRequest -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip Get-File -Url https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
Copy-Item $php_dir\instantclient*\* $php_dir Copy-Item $php_dir\instantclient*\* $php_dir
} }
@ -71,7 +71,7 @@ Function Add-Oci() {
Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll
} else { } else {
$status = 'Installed and enabled' $status = 'Installed and enabled'
Invoke-WebRequest -Uri (Get-Oci8Url) -OutFile $php_dir\oci8.zip Get-File -Url (Get-Oci8Url) -OutFile $php_dir\oci8.zip
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
} }
} }

View File

@ -13,14 +13,14 @@ Function Get-PhalconReleaseAssetUrl() {
try { try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)" $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
} catch { } catch {
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)" $match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
} }
} else { } else {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" } $nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
try { try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)" $match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { } catch {
$match = (Invoke-WebRequest -Uri "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)" $match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
} }
} }
if($NULL -ne $match) { if($NULL -ne $match) {
@ -39,7 +39,7 @@ Function Add-PhalconFromGitHub() {
) )
$zip_url = Get-PhalconReleaseAssetUrl $Semver $zip_url = Get-PhalconReleaseAssetUrl $Semver
if($zip_url) { if($zip_url) {
Invoke-WebRequest -Uri $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1 Get-File -Url $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1 Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll" Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir Enable-PhpExtension -Extension phalcon -Path $php_dir

View File

@ -0,0 +1,146 @@
# Get relay version
get_relay_version() {
local ext=$1
if [[ "$ext" =~ ^relay$ ]]; then
get -s -n "" "${relay_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
else
relay_version="${ext##*-}"
echo "v${relay_version/v//}"
fi
}
# Get OS suffix in relay artifact URL.
get_os_suffix() {
if [ "$os" = "Linux" ]; then
if [[ "$ID" =~ ubuntu|debian ]]; then
echo debian
elif [ "$ID" = "centos" ]; then
echo centos"$VERSION_ID"
else
echo "$ID"
fi
else
echo darwin
fi
}
# Get openssl suffix in relay artifact URL.
get_openssl_suffix() {
openssl_3=$(php -r "echo strpos(OPENSSL_VERSION_TEXT, 'SSL 3') !== false;")
[ "$openssl_3" = "1" ] && echo '+libssl3' || echo ''
}
# Change library paths in relay binary.
change_library_paths() {
if [ "$os" = "Darwin" ]; then
otool -L "${ext_dir:?}"/relay.so | grep -q 'ssl.1' && openssl_version='1.1' || openssl_version='3'
[ -e "${brew_prefix:?}"/opt/openssl@"$openssl_version" ] || brew install openssl@"$openssl_version"
dylibs="$(otool -L "${ext_dir:?}"/relay.so | grep -Eo '.*\.dylib' | cut -f1 -d ' ')"
install_name_tool -change "$(echo "${dylibs}" | grep -E "libzstd.*dylib" | xargs)" "$brew_prefix"/opt/zstd/lib/libzstd.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "liblz4.*dylib" | xargs)" "$brew_prefix"/opt/lz4/lib/liblz4.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "libssl.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libssl.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "libcrypto.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libcrypto.dylib "$ext_dir"/relay.so
fi
}
# Add relay dependencies
add_relay_dependencies() {
add_extension json
add_extension msgpack
add_extension igbinary
if [ "$os" = "Darwin" ]; then
. "${0%/*}"/tools/brew.sh
configure_brew
brew install hiredis lz4 zstd
fi
}
# Initialize relay extension ini configuration
init_relay_ini() {
relay_ini=$1
if [ -e "$relay_ini" ]; then
if [[ -n "$RELAY_KEY" ]]; then
sudo sed -i.bak "s/^; relay.key =.*/relay.key = $RELAY_KEY/" "$relay_ini"
fi
if [[ -n "$RELAY_ENVIRONMENT" ]]; then
sudo sed -i.bak "s/^; relay.environment =.*/relay.environment = $RELAY_ENVIRONMENT/" "$relay_ini"
fi
if [[ -n "$RELAY_EVICTION_POLICY" ]]; then
sudo sed -i.bak "s/^; relay.eviction_policy =.*/relay.eviction_policy = $RELAY_EVICTION_POLICY/" "$relay_ini"
fi
if [[ -n "$RELAY_MAX_MEMORY" ]]; then
sudo sed -i.bak "s/^; relay.maxmemory =.*/relay.maxmemory = $RELAY_MAX_MEMORY/" "$relay_ini"
fi
sudo rm -rf "$relay_ini".bak
fi
}
# Enable relay extension
enable_relay() {
relay_ini=$1
if [ -e "$relay_ini" ]; then
init_relay_ini "$relay_ini"
if [ "$os" = "Linux" ]; then
sudo cp "$relay_ini" "${ini_dir:?}"/../mods-available/relay.ini
sudo phpenmod -v "${version:?}" relay
else
sudo cp "${relay_ini}" "${scan_dir:?}"/60-relay.ini
fi
fi
}
# Patch binary id in relay extension
init_relay_binary_id() {
if [ -e "${ext_dir:?}"/relay.so ]; then
grep -aq 00000000 "${ext_dir:?}"/relay.so && \
sudo LC_ALL=C sed -i.bak "s/00000000-0000-0000-0000-000000000000/$(uuidgen)/" "$ext_dir"/relay.so
fi
}
# Configure relay extension
configure_relay() {
change_library_paths
init_relay_binary_id
enable_relay "${ext_dir}"/relay.ini
}
# Helper function to add relay extension
add_relay_helper() {
arch="$(uname -m | sed 's/_/-/')"
os_suffix="$(get_os_suffix)"
openssl_suffix="$(get_openssl_suffix)"
artifact_file_name="relay-$relay_version-php${version:?}-$os_suffix-$arch$openssl_suffix.tar.gz"
url="$relay_trunk"/"$relay_version"/"$artifact_file_name"
get -q -n /tmp/relay.tar.gz "$url"
if (! [ -e /tmp/relay.tar.gz ] || ! file /tmp/relay.tar.gz | grep -q 'gzip'); then
if [ "$openssl_suffix" = '+libssl3' ]; then
get -q -n /tmp/relay.tar.gz "${url/+libssl3/}"
else
get -q -n /tmp/relay.tar.gz "${url/.tar/+libssl3.tar}"
fi
fi
if [ -e /tmp/relay.tar.gz ] && file /tmp/relay.tar.gz | grep -q 'gzip'; then
sudo tar --strip-components=1 -xzf /tmp/relay.tar.gz -C "${ext_dir:?}"
sudo mv "${ext_dir:?}"/relay-pkg.so "${ext_dir:?}"/relay.so
fi
}
# Add relay extension
add_relay() {
local ext=$1
local arch
local url
os=$(uname -s)
relay_releases=https://github.com/cachewerk/relay/releases
relay_trunk=https://builds.r2.relay.so
relay_version=$(get_relay_version "$ext")
add_relay_dependencies >/dev/null 2>&1
if shared_extension relay; then
message="Enabled"
else
add_relay_helper >/dev/null 2>&1
message="Installed and enabled"
fi
configure_relay >/dev/null 2>&1
add_extension_log relay "$message"
}

View File

@ -13,7 +13,7 @@ parse_args() {
# Function to parse configure options for pecl # Function to parse configure options for pecl
# Make sure we have all options in name="value" form i.e XML properties. # Make sure we have all options in name="value" form i.e XML properties.
parse_pecl_configure_options() { parse_pecl_configure_options() {
configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g") configure_opts=$(echo "$1" | sed -E -e "s#['\"]|--##g")
IFS=' ' read -r -a opts_array <<< "$configure_opts" IFS=' ' read -r -a opts_array <<< "$configure_opts"
output_opts=() output_opts=()
for opt in "${opts_array[@]}"; do for opt in "${opts_array[@]}"; do

View File

@ -0,0 +1,69 @@
# Function to get sqlsrv extension version.
Function Get-SqlsrvReleaseVersion() {
if ($version -le '7.2') {
# Use the releases from PECL for these versions
return null;
} elseif($version -eq '7.3') {
return '5.9.0'
} elseif ($version -eq '7.4') {
return '5.10.1'
} else {
return 'latest'
}
}
# Function to get sqlsrv extension release URL.
Function Get-SqlsrvReleaseUrl()
{
$extensionVersion = Get-SqlsrvReleaseVersion
if($extensionVersion) {
$repo = "$github/microsoft/msphpsql"
if($extensionVersion -eq 'latest') {
return "$repo/releases/latest/download/Windows-$version.zip"
} else {
return "$repo/releases/download/v$extensionVersion/Windows-$version.zip"
}
}
}
# Function to add sqlsrv extension from GitHub.
Function Add-SqlsrvFromGithub()
{
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$zipUrl = SqlsrvReleaseUrl
if($zipUrl) {
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
$noDotVersion = $version.replace('.', '')
$extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll"
Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll"
Enable-PhpExtension -Extension $extension -Path $php_dir
}
}
# Function to add sqlsrv extension.
Function Add-Sqlsrv() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$status = 'Enabled'
if (Test-Path $ext_dir\php_$extension.dll) {
Enable-PhpExtension -Extension $extension -Path $php_dir
} else {
Add-SqlsrvFromGithub $extension >$null 2>&1
if (-not(Test-Extension $extension)) {
Add-Extension $extension >$null 2>&1
}
$status = 'Installed and enabled'
}
Add-ExtensionLog $extension $status
}

View File

@ -2,8 +2,11 @@
get_sqlsrv_version() { get_sqlsrv_version() {
if [[ "${version:?}" =~ 7.[0-3] ]]; then if [[ "${version:?}" =~ 7.[0-3] ]]; then
echo '5.9.0' echo '5.9.0'
else elif [[ "${version:?}" =~ 7.4 ]]; then
echo '5.10.1' echo '5.10.1'
else
# Return an empty string so that pecl will install the latest version.
echo ''
fi fi
} }

View File

@ -0,0 +1,80 @@
# Function to get the url of the phalcon release asset.
Function Get-ZephirParserReleaseAssetUrl() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension_version
)
$repo = 'zephir-lang/php-zephir-parser'
$zp_releases = "$github/$repo/releases"
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
try {
$match = (Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/tags/$extension_version").assets | Select-String -Pattern "browser_download_url=.*(zephir_parser-php-${version}-$nts-windows.*.zip)"
} catch {
$match = (Get-File -Url "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}-$nts-windows.*.zip)"
}
if($NULL -ne $match) {
return "$zp_releases/download/$extension_version/$($match.Matches[0].Groups[1].Value)"
}
return false;
}
# Function to get zephir parser version using GitHub releases.
Function Get-ZephirParserVersion() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$repo = 'zephir-lang/php-zephir-parser'
$zp_releases = "$github/$repo/releases"
if($extension -eq 'zephir_parser') {
return (Get-File -Url $zp_releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} else {
return 'v' + ($extension.split('-')[1] -replace 'v')
}
}
# Function to add zephir parser using GitHub releases.
Function Add-ZephirParserFromGitHub() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$extension_version = Get-ZephirParserVersion $extension
$zip_url = Get-ZephirParserReleaseAssetUrl $extension_version
if($zip_url) {
Get-File -Url $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\zp.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\zp.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\zp -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\zp\php_zephir_parser.dll" -Destination "$ext_dir\php_zephir_parser.dll"
Enable-PhpExtension -Extension zephir_parser -Path $php_dir
} else {
throw "Unable to get zephir_parser release from the GitHub repo"
}
}
# Function to add zephir parser.
Function Add-ZephirParser() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
try {
$status = 'Enabled'
if (Test-Path $ext_dir\php_zephir_parser.dll) {
Enable-PhpExtension -Extension zephir_parser -Path $php_dir
} else {
$status = 'Installed and enabled'
Add-ZephirParserFromGitHub $extension
}
Add-ExtensionLog zephir_parser $status
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
}
}

View File

@ -0,0 +1,38 @@
# Get zephir_parser version
get_zephir_parser_version() {
local ext=$1
if [[ "$ext" =~ ^zephir_parser$ ]]; then
get -s -n "" "${zp_releases:?}"/latest 2<&1 | grep -m 1 -Eo "tag/(v?[0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2
else
zp_version="${ext##*-}"
echo "v${zp_version/v//}"
fi
}
# Add zephir_parser helper
add_zephir_parser_helper() {
local ext=$1
nts="${ts:?}" && nts="${nts/z/}"
ext_version=$(get_zephir_parser_version "$ext")
[ "$(uname -s)" = "Linux" ] && os_suffix=ubuntu || os_suffix=macos
build_name=$(get -s -n "" https://api.github.com/repos/"$repo"/releases/tags/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
[ -z "$build_name" ] && build_name=$(get -s -n "" "$zp_releases"/expanded_assets/"$ext_version" | grep -Eo "zephir_parser-php-${version:?}-$nts-$os_suffix-.*.zip" | head -n 1)
get -q -e "/tmp/zp.zip" "$zp_releases"/download/"$ext_version"/"$build_name"
sudo unzip -o "/tmp/zp.zip" -d "${ext_dir:?}"
enable_extension zephir_parser extension
}
# Add zephir_parser
add_zephir_parser() {
ext=$1
repo=zephir-lang/php-zephir-parser
zp_releases=https://github.com/"$repo"/releases
if ! shared_extension zephir_parser; then
message='Installed and enabled'
add_zephir_parser_helper "$ext" >/dev/null 2>&1
else
message='Enabled'
enable_extension zephir_parser extension
fi
add_extension_log zephir_parser "$message"
}

View File

@ -2,7 +2,7 @@
add_sudo() { add_sudo() {
if ! command -v sudo >/dev/null; then if ! command -v sudo >/dev/null; then
check_package sudo || apt-get update check_package sudo || apt-get update
apt-get install -y sudo apt-get install -y sudo || (apt-get update && apt-get install -y sudo)
fi fi
} }
@ -15,10 +15,15 @@ self_hosted_helper() {
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
} }
# Function to fix broken packages.
fix_broken_packages() {
sudo apt --fix-broken install >/dev/null 2>&1
}
# Function to install a package # Function to install a package
install_packages() { install_packages() {
packages=("$@") packages=("$@")
$apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1) $apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
} }
# Function to disable an extension. # Function to disable an extension.
@ -29,8 +34,8 @@ disable_extension_helper() {
if [ "$disable_dependents" = "true" ]; then if [ "$disable_dependents" = "true" ]; then
disable_extension_dependents "$extension" disable_extension_dependents "$extension"
fi fi
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file" sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "${ini_file[@]}" "$pecl_file"
sudo find "$ini_dir"/.. -name "*$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true sudo find "$ini_dir"/.. -name "*-$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
sudo rm -f /tmp/php"$version"_extensions sudo rm -f /tmp/php"$version"_extensions
mkdir -p /tmp/extdisabled/"$version" mkdir -p /tmp/extdisabled/"$version"
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1 echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
@ -96,7 +101,7 @@ add_devtools() {
# Function to setup the nightly build from shivammathur/php-builder # Function to setup the nightly build from shivammathur/php-builder
setup_nightly() { setup_nightly() {
run_script "php-builder" "${runner:?}" "$version" "${debug:?}" ${ts:?} run_script "php-builder" "${runner:?}" "$version" "${debug:?}" "${ts:?}"
} }
# 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.

View File

@ -17,7 +17,7 @@ Function Edit-ComposerConfig() {
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}" php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
if ($? -eq $False) { if ($? -eq $False) {
Add-Log "$cross" "composer" "Could not download composer" Add-Log "$cross" "composer" "Could not download composer"
exit 1; Write-Error "Could not download composer" -ErrorAction Stop
} }
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1 New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
if (-not(Test-Path $composer_json)) { if (-not(Test-Path $composer_json)) {
@ -57,7 +57,7 @@ Function Get-ToolVersion() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
$tool, $tool,
[Parameter(Position = 1, Mandatory = $true)] [Parameter(Position = 1, Mandatory = $false)]
$param $param
) )
$alp = "[a-zA-Z0-9\.]" $alp = "[a-zA-Z0-9\.]"
@ -72,7 +72,9 @@ Function Get-ToolVersion() {
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
return "$composer_version" return "$composer_version"
} }
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value } if($null -ne $param) {
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
}
} }
# Helper function to configure tools. # Helper function to configure tools.
@ -83,7 +85,9 @@ Function Add-ToolsHelper() {
$tool $tool
) )
$extensions = @(); $extensions = @();
if($tool -eq "codeception") { if($tool -eq "box") {
$extensions += @('iconv', 'mbstring', 'phar', 'sodium')
} elseif($tool -eq "codeception") {
$extensions += @('json', 'mbstring') $extensions += @('json', 'mbstring')
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
} elseif($tool -eq "composer") { } elseif($tool -eq "composer") {
@ -135,8 +139,7 @@ Function Add-Tool() {
[Parameter(Position = 1, Mandatory = $true)] [Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()] [ValidateNotNull()]
$tool, $tool,
[Parameter(Position = 2, Mandatory = $true)] [Parameter(Position = 2, Mandatory = $false)]
[ValidateNotNull()]
$ver_param $ver_param
) )
if (Test-Path $bin_dir\$tool) { if (Test-Path $bin_dir\$tool) {
@ -152,7 +155,7 @@ Function Add-Tool() {
} catch { } catch {
if($url -match '.*github.com.*releases.*latest.*') { if($url -match '.*github.com.*releases.*latest.*') {
try { try {
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0]) $url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Get-File -Url ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode $status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode
} catch { } } catch { }
} }
@ -183,7 +186,7 @@ Function Add-Tool() {
} }
} }
Function Add-ComposertoolHelper() { Function Add-ComposerToolHelper() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
[string] [string]
@ -234,7 +237,7 @@ Function Add-ComposertoolHelper() {
} }
# Function to setup a tool using composer. # Function to setup a tool using composer.
Function Add-Composertool() { Function Add-ComposerTool() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()] [ValidateNotNull()]
@ -267,7 +270,7 @@ Function Add-Composertool() {
} }
} }
Enable-PhpExtension -Extension curl, mbstring, openssl -Path $php_dir Enable-PhpExtension -Extension curl, mbstring, openssl -Path $php_dir
$log = Add-ComposertoolHelper $tool $release $prefix $scope $composer_args $log = Add-ComposerToolHelper $tool $release $prefix $scope $composer_args
if(Test-Path $composer_bin\composer) { if(Test-Path $composer_bin\composer) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
} }

View File

@ -19,7 +19,7 @@ get_tool_version() {
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")" composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
fi fi
echo "$composer_version" | sudo tee /tmp/composer_version echo "$composer_version" | sudo tee /tmp/composer_version
else elif [ -n "$param" ]; then
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1 $tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi fi
} }
@ -72,7 +72,11 @@ set_composer_auth() {
add_tools_helper() { add_tools_helper() {
tool=$1 tool=$1
extensions=() extensions=()
if [ "$tool" = "codeception" ]; then if [ "$tool" = "blackfire-player" ]; then
extensions+=(uuid)
elif [ "$tool" = "box" ]; then
extensions+=(iconv mbstring phar sodium)
elif [ "$tool" = "codeception" ]; then
extensions+=(json mbstring) extensions+=(json mbstring)
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
elif [ "$tool" = "composer" ]; then elif [ "$tool" = "composer" ]; then
@ -128,6 +132,9 @@ add_tool() {
tool=$2 tool=$2
ver_param=$3 ver_param=$3
tool_path="$tool_path_dir/$tool" tool_path="$tool_path_dir/$tool"
if ! [ -d "$tool_path_dir" ]; then
sudo mkdir -p "$tool_path_dir"
fi
add_path "$tool_path_dir" add_path "$tool_path_dir"
if [ -e "$tool_path" ]; then if [ -e "$tool_path" ]; then
sudo cp -aL "$tool_path" /tmp/"$tool" sudo cp -aL "$tool_path" /tmp/"$tool"
@ -153,7 +160,7 @@ add_tool() {
} }
# Function to setup a tool using composer in a different scope. # Function to setup a tool using composer in a different scope.
add_composertool_helper() { add_composer_tool_helper() {
tool=$1 tool=$1
release=$2 release=$2
prefix=$3 prefix=$3
@ -184,7 +191,7 @@ add_composertool_helper() {
} }
# Function to setup a tool using composer. # Function to setup a tool using composer.
add_composertool() { add_composer_tool() {
tool=$1 tool=$1
release=$2 release=$2
prefix=$3 prefix=$3
@ -199,7 +206,7 @@ add_composertool() {
return return
fi fi
fi fi
add_composertool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args" add_composer_tool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args"
tool_version=$(get_tool_version cat /tmp/composer.log) tool_version=$(get_tool_version cat /tmp/composer.log)
([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version" ([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"

View File

@ -6,7 +6,7 @@ Function Add-Blackfire() {
} }
$cli_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).cli $cli_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).cli
$url = "https://packages.blackfire.io/binaries/blackfire/${cli_version}/blackfire-windows_${arch_name}.zip" $url = "https://packages.blackfire.io/binaries/blackfire/${cli_version}/blackfire-windows_${arch_name}.zip"
Invoke-WebRequest -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1 Get-File -Url $url -OutFile $bin_dir\blackfire.zip >$null 2>&1
Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1 Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1
Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe" Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe"
if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) { if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {

View File

@ -7,7 +7,7 @@ Function Add-Msys2() {
return $msys_location return $msys_location
} }
Function Add-Grpc_php_plugin() { Function Add-GrpcPhpPlugin() {
$msys_location = Add-Msys2 $msys_location = Add-Msys2
$logs = . $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
$grpc_version = Get-ToolVersion 'Write-Output' "$logs" $grpc_version = Get-ToolVersion 'Write-Output' "$logs"

View File

@ -31,10 +31,6 @@ set_base_version() {
else else
set_base_version_codename set_base_version_codename
set_base_version_id set_base_version_id
# Remove once PPAs start having bookworm releases
[ "$VERSION_CODENAME" = 'bookworm' ] && VERSION_CODENAME="bullseye"
printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1 printf "ID=%s\nVERSION_ID=%s\nVERSION_CODENAME=%s\n" "$ID" "$VERSION_ID" "$VERSION_CODENAME" | tee /tmp/os-release >/dev/null 2>&1
fi fi
} }
@ -59,7 +55,7 @@ update_lists() {
if [[ -n "$ppa" && -n "$ppa_search" ]]; then if [[ -n "$ppa" && -n "$ppa_search" ]]; then
list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")" list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
status_file=/tmp/"${ppa/\//_}" status_file=/tmp/"${ppa/\//_}"
elif grep -Eq '^deb ' "$list_file"; then elif [ -e "$list_file" ] && grep -Eq '^deb ' "$list_file"; then
list="$list_file" list="$list_file"
fi fi
if [ ! -e "$status_file" ]; then if [ ! -e "$status_file" ]; then

View File

@ -1,7 +1,7 @@
Function Get-ProtobufTag() { Function Get-ProtobufTag() {
$releases = 'https://github.com/protocolbuffers/protobuf/releases' $releases = 'https://github.com/protocolbuffers/protobuf/releases'
if("$protobuf_tag" -eq "latest") { if("$protobuf_tag" -eq "latest") {
$protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] $protobuf_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} else { } else {
try { try {
$protobuf_tag = $protobuf_tag -replace '^v', '' $protobuf_tag = $protobuf_tag -replace '^v', ''
@ -11,7 +11,7 @@ Function Get-ProtobufTag() {
$response.Close() $response.Close()
$protobuf_tag = "v$protobuf_tag" $protobuf_tag = "v$protobuf_tag"
} catch { } catch {
$protobuf_tag = (Invoke-WebRequest -UseBasicParsing -Uri $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1] $protobuf_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} }
} }
return $protobuf_tag return $protobuf_tag
@ -29,7 +29,7 @@ Function Add-Protoc() {
$arch_num = '32' $arch_num = '32'
} }
$url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip" $url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip"
Invoke-WebRequest -Uri $url -OutFile $bin_dir\protoc.zip >$null 2>&1 Get-File -Url $url -OutFile $bin_dir\protoc.zip >$null 2>&1
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"

View File

@ -4,7 +4,7 @@ Function Add-Symfony() {
$arch_name = '386' $arch_name = '386'
} }
$url = "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_windows_${arch_name}.zip" $url = "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_windows_${arch_name}.zip"
Invoke-WebRequest -Uri $url -OutFile $bin_dir\symfony.zip >$null 2>&1 Get-File -Url $url -OutFile $bin_dir\symfony.zip >$null 2>&1
Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force >$null 2>&1 Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force >$null 2>&1
if(Test-Path $bin_dir\symfony.exe) { if(Test-Path $bin_dir\symfony.exe) {
Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1 Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1

View File

@ -53,7 +53,7 @@ read_env() {
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release [ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
[ "${phpts:-${PHPTS:-nts}}" = "ts" ] && ts=zts && update=true || ts=nts [ "${phpts:-${PHPTS:-nts}}" = "ts" ] && ts=zts && update=true || ts=nts
fail_fast="${fail_fast:-${FAIL_FAST:-false}}" fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
[[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github [[ -z "${ImageOS}" && -z "${ImageVersion}" || -n ${ACT} ]] && _runner=self-hosted || _runner=github
runner="${runner:-${RUNNER:-$_runner}}" runner="${runner:-${RUNNER:-$_runner}}"
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
@ -173,9 +173,10 @@ configure_php() {
add_php_config add_php_config
ini_config_dir="${src:?}"/configs/ini ini_config_dir="${src:?}"/configs/ini
ini_config_files=("$ini_config_dir"/php.ini) ini_config_files=("$ini_config_dir"/php.ini)
[[ "$version" =~ $jit_versions ]] && ini_config_files+=("$ini_config_dir"/jit.ini) jit_config_files=("$ini_config_dir"/jit.ini)
[[ "$version" =~ $xdebug3_versions ]] && ini_config_files+=("$ini_config_dir"/xdebug.ini) [[ "$version" =~ $xdebug3_versions ]] && ini_config_files+=("$ini_config_dir"/xdebug.ini)
cat "${ini_config_files[@]}" | sudo tee -a "${ini_file[@]:?}" >/dev/null 2>&1 cat "${ini_config_files[@]}" | sudo tee -a "${ini_file[@]:?}" >/dev/null 2>&1
[[ "$version" =~ $jit_versions ]] && cat "${jit_config_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
} }
# Function to get PHP version in semver format. # Function to get PHP version in semver format.

View File

@ -23,7 +23,7 @@ Function Add-Log($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
if($env:fail_fast -eq 'true') { if($env:fail_fast -eq 'true') {
exit 1; Write-Error $message -ErrorAction Stop
} }
} }
} }
@ -128,13 +128,51 @@ Function Add-EnvPATH {
$env_data | Add-Content -Path $env_file -Encoding utf8 $env_data | Add-Content -Path $env_file -Encoding utf8
} }
# Function to fetch a file from a URL.
Function Get-File {
param (
[string]$Url,
[string]$FallbackUrl,
[string]$OutFile,
[int]$Retries = 3,
[int]$TimeoutSec = 0
)
for ($i = 0; $i -lt $Retries; $i++) {
try {
if($null -ne $OutFile) {
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
} else {
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
}
break;
} catch {
if ($i -eq ($Retries - 1)) {
if($FallbackUrl) {
try {
if($null -ne $OutFile) {
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
} else {
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
}
} catch {
throw "Failed to download the assets from $Url and $FallbackUrl"
}
} else {
throw "Failed to download the assets from $Url"
}
}
}
}
}
# Function to make sure printf is in PATH. # Function to make sure printf is in PATH.
Function Add-Printf { Function Add-Printf {
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) { if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
if(Test-Path "C:\msys64\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 -Force > $null 2>&1 New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe -Force > $null 2>&1
} else { } else {
Invoke-WebRequest -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip" Get-File -Url "$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 Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
} }
} else { } else {
@ -166,7 +204,7 @@ Function Install-PSPackage() {
$module_path = "$bin_dir\$psm1_path.psm1" $module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { if(-not (Test-Path $module_path -PathType Leaf)) {
$zip_file = "$bin_dir\$package.zip" $zip_file = "$bin_dir\$package.zip"
Invoke-WebRequest -Uri $url -OutFile $zip_file Get-File -Url $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
@ -224,40 +262,49 @@ Function Set-PhpCache {
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") { if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name return $_.name
} }
} } | Select-Object -Last 1
if($null -eq $asset) { if($null -eq $asset) {
throw "Asset not found" throw "Asset not found"
} }
} catch { } catch {
$release = Invoke-WebRequest $php_builder/releases/expanded_assets/php$version $release = Get-File -Url $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object { $asset = $release.links.href | ForEach-Object {
if($_ -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") { if($_ -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.split('/')[-1] return $_.split('/')[-1]
} }
} } | Select-Object -Last 1
} }
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset Get-File -Url $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Set-PhpDownloadCache -Path $php_dir CurrentUser Set-PhpDownloadCache -Path $php_dir CurrentUser
} catch { } } catch { }
} }
# Function to add debug symbols to PHP. # Function to add debug symbols to PHP.
Function Add-DebugSymbols { Function Add-DebugSymbols {
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
$dev = if ($version -match $nightly_versions) { '-dev' } else { '' } $dev = if ($version -match $nightly_versions) { '-dev' } else { '' }
$asset = $release.assets | ForEach-Object { try {
if($_.name -match "php-debug-pack-$version.[0-9]+$dev$env:PHPTS-Win32-.*-$arch.zip") { $release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
return $_.name $asset = $release.assets | ForEach-Object {
} if($_.name -match "php-debug-pack-$version.[0-9]+$dev$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name
}
} | Select-Object -Last 1
} catch {
$release = Get-File -Url $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object {
if($_ -match "php-debug-pack-$version.[0-9]+$dev$env:PHPTS-Win32-.*-$arch.zip") {
return $_.split('/')[-1]
}
} | Select-Object -Last 1
} }
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset Get-File -Url $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Expand-Archive -Path $php_dir\$asset -DestinationPath $php_dir -Force Expand-Archive -Path $php_dir\$asset -DestinationPath $php_dir -Force
Get-ChildItem -Path $php_dir -Filter php_*.pdb | Move-Item -Destination $ext_dir Get-ChildItem -Path $php_dir -Filter php_*.pdb | Move-Item -Destination $ext_dir
} }
# Function to install nightly version of PHP # Function to install nightly version of PHP
Function Install-PhpNightly { Function Install-PhpNightly {
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1 Get-File -Url $php_builder/releases/latest/download/Get-PhpNightly.ps1 -FallbackUrl https://dl.cloudsmith.io/public/shivammathur/php-builder-windows/raw/files/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1 & $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
if(Test-Path $php_dir\COMMIT) { if(Test-Path $php_dir\COMMIT) {
return " ($( Get-Content $php_dir\COMMIT ))" return " ($( Get-Content $php_dir\COMMIT ))"
@ -303,7 +350,7 @@ if ( $env:GITHUB_ACTIONS -eq 'true') {
if(-not($env:ImageOS) -and -not($env:ImageVersion)) { if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
if($env:RUNNER -eq 'github') { if($env:RUNNER -eq 'github') {
Add-Log $cross "Runner" "Runner set as github in self-hosted environment" Add-Log $cross "Runner" "Runner set as github in self-hosted environment"
exit 1 Write-Error "Runner set as github in self-hosted environment" -ErrorAction Stop
} }
$bin_dir = 'C:\tools\bin' $bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version" $php_dir = "$php_dir$version"
@ -314,7 +361,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
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
exit 1 Write-Error "PHP $version is not supported on self-hosted runner" -ErrorAction Stop
} }
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) { if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
@ -384,10 +431,10 @@ if($env:DEBUG -eq 'true') {
$installed = Get-Php -Path $php_dir $installed = Get-Php -Path $php_dir
if($installed.MajorMinorVersion -ne $version) { if($installed.MajorMinorVersion -ne $version) {
Add-Log $cross "PHP" "Could not setup PHP $version" Add-Log $cross "PHP" "Could not setup PHP $version"
exit 1 Write-Error "Could not setup PHP $version" -ErrorAction Stop
} }
if($version -lt "5.5") { if($version -lt "5.5") {
('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 } ('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Get-File -Url "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }
} else { } else {
$enable_extensions += ('opcache') $enable_extensions += ('opcache')
} }

View File

@ -1,6 +1,7 @@
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import * as fetch from './fetch'; import * as fetch from './fetch';
import * as packagist from './packagist';
import * as utils from './utils'; import * as utils from './utils';
type RS = Record<string, string>; type RS = Record<string, string>;
@ -201,7 +202,7 @@ export async function addArchive(data: RS): Promise<string> {
* @param data * @param data
*/ */
export async function addPackage(data: RS): Promise<string> { export async function addPackage(data: RS): Promise<string> {
const command = await utils.getCommand(data['os'], 'composertool'); const command = await utils.getCommand(data['os'], 'composer_tool');
const parts: string[] = data['repository'].split('/'); const parts: string[] = data['repository'].split('/');
const args: string = await utils.joins( const args: string = await utils.joins(
parts[1], parts[1],
@ -218,14 +219,40 @@ export async function addPackage(data: RS): Promise<string> {
* @param data * @param data
*/ */
export async function addBlackfirePlayer(data: RS): Promise<string> { export async function addBlackfirePlayer(data: RS): Promise<string> {
if ( switch (data['os']) {
/5\.[5-6]|7\.0/.test(data['php_version']) && case 'win32':
data['version'] == 'latest' return await utils.addLog(
) { '$cross',
data['version'] = '1.9.3'; data['tool'],
data['tool'] + ' is not a windows tool',
'win32'
);
default:
if (data['version'] == 'latest') {
if (/5\.[5-6]|7\.0/.test(data['php_version'])) {
data['version'] = '1.9.3';
} else if (/7\.[1-4]|8\.0/.test(data['php_version'])) {
data['version'] = '1.22.0';
}
}
data['url'] = await getPharUrl(data);
return addArchive(data);
} }
data['url'] = await getPharUrl(data); }
return addArchive(data);
/**
* Function to add Castor
*
* @param data
*/
export async function addCastor(data: RS): Promise<string> {
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
data['url'] = await getUrl(data);
data['tool'] = 'castor';
data['version_parameter'] = fs.existsSync('castor.php')
? data['version_parameter']
: '';
return await addArchive(data);
} }
/** /**
@ -391,6 +418,11 @@ export async function addPhive(data: RS): Promise<string> {
* @param data * @param data
*/ */
export async function addPHPUnitTools(data: RS): Promise<string> { export async function addPHPUnitTools(data: RS): Promise<string> {
if (data['version'] === 'latest') {
data['version'] =
(await packagist.search(data['packagist'], data['php_version'])) ??
'latest';
}
data['url'] = await getPharUrl(data); data['url'] = await getPharUrl(data);
return await addArchive(data); return await addArchive(data);
} }
@ -457,6 +489,7 @@ export async function getData(
data['extension'] ??= '.phar'; data['extension'] ??= '.phar';
data['os'] = os; data['os'] = os;
data['php_version'] = php_version; data['php_version'] = php_version;
data['packagist'] ??= data['repository'];
data['prefix'] = data['github'] === data['domain'] ? 'releases' : ''; data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
data['verb'] = data['github'] === data['domain'] ? 'download' : ''; data['verb'] = data['github'] === data['domain'] ? 'download' : '';
data['fetch_latest'] ??= 'false'; data['fetch_latest'] ??= 'false';
@ -471,6 +504,7 @@ export async function getData(
} }
export const functionRecord: Record<string, (data: RS) => Promise<string>> = { export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
castor: addCastor,
composer: addComposer, composer: addComposer,
deployer: addDeployer, deployer: addDeployer,
dev_tools: addDevTools, dev_tools: addDevTools,

View File

@ -1,3 +1,4 @@
import 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';
import * as fetch from './fetch'; import * as fetch from './fetch';
@ -44,8 +45,8 @@ export async function getInput(
} }
} }
/** Function to get manifest URL /**
* * Function to get manifest URL
*/ */
export async function getManifestURL(): Promise<string> { export async function getManifestURL(): Promise<string> {
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json'; return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
@ -57,10 +58,11 @@ export async function getManifestURL(): Promise<string> {
* @param version * @param version
*/ */
export async function parseVersion(version: string): Promise<string> { export async function parseVersion(version: string): Promise<string> {
const manifest = await getManifestURL();
switch (true) { switch (true) {
case /^(latest|nightly|\d+\.x)$/.test(version): case /^(latest|nightly|\d+\.x)$/.test(version):
return JSON.parse((await fetch.fetch(manifest))['data'])[version]; return JSON.parse((await fetch.fetch(await getManifestURL()))['data'])[
version
];
default: default:
switch (true) { switch (true) {
case version.length > 1: case version.length > 1:
@ -247,7 +249,8 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
.trim() .trim()
.replace(/^["']|["']$|(?<==)["']/g, '') .replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'") .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
.replace(/=(.*?)(=.*)/, "='$1$2'"); .replace(/=(.*?)(=.*)/, "='$1$2'")
.replace(/:\s*["'](.*?)/g, ':$1');
}) })
.filter(Boolean); .filter(Boolean);
} }
@ -320,7 +323,14 @@ export async function getCommand(os: string, suffix: string): Promise<string> {
case 'darwin': case 'darwin':
return 'add_' + suffix + ' '; return 'add_' + suffix + ' ';
case 'win32': case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; return (
'Add-' +
suffix
.split('_')
.map((part: string) => part.charAt(0).toUpperCase() + part.slice(1))
.join('') +
' '
);
default: default:
return await log('Platform ' + os + ' is not supported', os, 'error'); return await log('Platform ' + os + ' is not supported', os, 'error');
} }
@ -415,6 +425,50 @@ export async function parseExtensionSource(
); );
} }
/**
* Read php version from input or file
*/
export async function readPHPVersion(): Promise<string> {
const version = await getInput('php-version', false);
if (version) {
return version;
}
const versionFile =
(await getInput('php-version-file', false)) || '.php-version';
if (fs.existsSync(versionFile)) {
return fs.readFileSync(versionFile, 'utf8').replace(/[\r\n]/g, '');
} else if (versionFile !== '.php-version') {
throw new Error(`Could not find '${versionFile}' file.`);
}
const composerLock = 'composer.lock';
if (fs.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
if (
lockFileContents['platform-overrides'] &&
lockFileContents['platform-overrides']['php']
) {
return lockFileContents['platform-overrides']['php'];
}
}
const composerJson = 'composer.json';
if (fs.existsSync(composerJson)) {
const composerFileContents = JSON.parse(
fs.readFileSync(composerJson, 'utf8')
);
if (
composerFileContents['config'] &&
composerFileContents['config']['platform'] &&
composerFileContents['config']['platform']['php']
) {
return composerFileContents['config']['platform']['php'];
}
}
return 'latest';
}
/** /**
* Log to console * Log to console
* *