Compare commits

...

188 Commits

Author SHA1 Message Date
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
8e2ac35f63 Update README 2022-12-26 03:45:00 +05:30
a1e6789a94 Improve Get-PhalconReleaseAssetUrl 2022-12-25 21:52:32 +05:30
9114b007ae Restore stability workaround for PHP 8.1 on Windows 2022-12-25 21:26:22 +05:30
cb0c293f02 Fix typo in blackfire regex on Windows 2022-12-25 21:14:03 +05:30
387ec95b46 Improve fetching phalcon release url on Windows 2022-12-25 20:48:17 +05:30
3514d30f93 Allow major.minor protoc versions 2022-12-25 20:03:40 +05:30
e186e47261 Bump version to 2.23.0
Update Node.js dependencies
2022-12-25 19:18:47 +05:30
e51e662ef0 Add support to install extensions from shivammathur/php-extensions-windows 2022-12-23 18:40:56 +05:30
5afd8a1842 Fix error in darwin.sh while updating dependencies 2022-12-23 18:11:26 +05:30
1a42045d48 Use ls-remote to get default branch
Calling GitHub API on macOS without the token hits rate limit
2022-12-19 08:19:07 +05:30
b3a12ce01e Add fallback in PHP build cache in Windows 2022-12-19 07:19:21 +05:30
04b2ed5b3e Fix protoc support on Windows 2022-12-19 06:57:44 +05:30
189e8e6ec0 Update pre-installed PHP versions on GitHub runners
Minor fixes in README
2022-12-18 08:20:18 +05:30
3407e6019c Quote ini values with equal sign 2022-12-15 05:32:32 +05:30
f20012026f Bump nightly versions in unix.sh 2022-12-15 05:32:31 +05:30
7743b7976f Update version in actions.yml 2022-12-15 05:32:31 +05:30
b7b50ce742 Fix extension support on php 8.2 on windows
Add PHP 8.2 support for backfire extension
2022-12-15 05:32:30 +05:30
aa9b80f158 Fix extension support on php 8.2 on windows
Add PHP 8.2 support for backfire extension
2022-12-08 19:58:40 +05:30
53adb47562 Mark PHP 8.2 as stable
Update OS support in README
2022-12-08 19:37:49 +05:30
f7d3c00320 Merge pull request #673 from jrfnl/feature/readme-update-php-list
README: update for release of PHP 8.2
2022-12-08 19:35:28 +05:30
b359d922e7 README: update code samples 2022-12-08 14:59:54 +01:00
01aa440f0b README: update for release of PHP 8.2
I also realized that - while not mentioned in the changelog or the readme - PHP 8.3 _is_ already available via the `setup-php` action runner, so I've added it to the README now.

Ref: https://www.php.net/supported-versions.php
2022-12-08 14:49:16 +01:00
51f83e019c Switch composer-unused back to phar 2022-12-01 04:45:59 +05:30
173ca15c9b Fix get_extension_from_formula in darwin.sh 2022-11-16 10:40:40 +05:30
4704ad638a Improve extension support on macOS 2022-11-14 15:17:12 +05:30
1a18b2267f Add note about updating PHP if ppa is missing on Ubuntu 2022-10-28 15:45:12 +05:30
e9704839e9 Update Node.js dependencies 2022-10-28 12:28:34 +05:30
5178fac634 Update PHP if ppa:ondrej/php is missing ref: actions/runner-images#6331 2022-10-28 12:24:37 +05:30
388883d4bf Fix support for firebird and couchbase 2022-10-25 15:29:26 +05:30
cae6d06e69 Improve phalcon support 2022-10-24 19:05:14 +05:30
89f4f7e8be Run configure_pecl only when ini_files are set 2022-10-24 10:30:28 +05:30
d2efbcd126 Fix debug support on Linux 2022-10-24 10:28:08 +05:30
98e3af0bff Configure brew on linux on grpc_php_plugin setup 2022-10-24 09:37:13 +05:30
e8836c6d46 Fix logs on failure in add_pecl_extension 2022-10-24 09:37:13 +05:30
9068f2e46f Update sqlsrv and pdo_sqlsrv to 5.10.1 2022-10-24 09:37:12 +05:30
5bbbd3fdf6 Update Node.js packages 2022-10-24 09:37:12 +05:30
7622357ff1 Improve phalcon5 support 2022-10-24 09:37:07 +05:30
6652a09da6 Add debug builds section in the README 2022-10-24 03:34:36 +05:30
48fb8e1194 Add debug symbols support to Windows 2022-10-17 18:00:08 +05:30
bbc6e9069b Merge branch 'flavioheleno-improv/zts' into develop 2022-10-17 17:04:24 +05:30
37dcd1cf8c Merge branch 'improv/zts' of https://github.com/flavioheleno/setup-php into flavioheleno-improv/zts 2022-10-17 17:03:20 +05:30
12b1efad4b Bump version to 2.22.0
Bump Node.js dependencies
2022-10-12 16:35:02 +05:30
0575a32108 Switch to $GITHUB_OUTPUT 2022-10-12 16:34:58 +05:30
71b0e09dbc Improve brew support on Linux 2022-10-10 16:24:35 +05:30
edff21f0a6 Fetch symfony-cli artifact url and fallback to brew 2022-10-10 15:35:30 +05:30
22035eb75b Fix version_prefix for laravel/pint 2022-10-10 15:35:29 +05:30
b556cf7292 Add support for debug builds 2022-10-10 15:34:36 +05:30
f99a9d4624 Add thread-safe setup support 2022-10-05 19:31:52 -03:00
a49dfe8457 Fix version_prefix for laravel/pint 2022-09-26 15:22:12 +05:30
7ff9ac44b4 Add support for debug builds 2022-09-26 09:42:27 +05:30
7aff4d7a22 Run switch_version before check_extensions on Linux 2022-09-11 09:19:35 +05:30
633321754d Merge pull request #641 from lmichelin/master
🐞 Bug Fix: make symfony-cli installation faster on Linux
2022-09-02 02:30:57 +05:30
40a4cb064f Improve fetching brew taps 2022-09-02 02:21:52 +05:30
45410ae8f0 fix: make symfony-cli installation faster on linux 2022-09-01 18:20:00 +02:00
56ad5977ba Merge pull request #636 from shivammathur/composer-no-audit
Set COMPOSER_NO_AUDIT environment variable by default
2022-08-22 09:54:07 +05:30
6353d20df2 Set COMPOSER_NO_AUDIT environment variable by default 2022-08-22 09:46:12 +05:30
e04e1d97f0 Bump Node.js dependencies 2022-08-17 17:05:01 +05:30
52685a348b Add support to install rector in tools input 2022-08-17 16:48:27 +05:30
44d81f9830 Fix symfony support 2022-08-17 14:41:01 +05:30
401bdecb71 Add support for ast from shivammathur/extensions on macOS 2022-08-10 13:19:47 +05:30
aa82ffc68f Fix logs in add_pecl_extension 2022-07-29 02:57:11 +05:30
7e03c76ef2 Fix extension setup using PECL on Linux and macOS 2022-07-29 02:39:20 +05:30
16011a795d Upgrade Node.js dependencies 2022-07-28 03:39:51 +05:30
66f24470dc Fix reading composer package type for older versions 2022-07-20 19:41:49 +05:30
e57ea715eb Fix scoped tool setup on Windows 2022-07-20 19:41:07 +05:30
e8ba27f3d2 Fail on npm audit again 2022-07-20 04:47:55 +05:30
945c34c175 Update README 2022-07-19 15:44:51 +05:30
c8c64c6cf9 Bump version to 2.21.0
Continue on npm audit failure
2022-07-19 15:24:35 +05:30
0d3f92f127 Add support for phalcon5 on Windows 2022-07-19 14:26:08 +05:30
4979d5b484 Add workaround for missing phalcon packages on Ubuntu 22.04 2022-07-16 02:40:47 +05:30
0d9a1ba5ae Add support for phalcon5 on Linux and macOS
Fix get_pecl_version
2022-07-16 00:46:28 +05:30
3ede7656cb Add check for gd in php.yml 2022-07-15 23:22:56 +05:30
f3cdc074ce Merge pull request #617 from ChristophWurst/demo/php82-gd
Demo PHP8.2+gd failure
2022-07-13 19:17:22 +05:30
109db648f1 Demo PHP8.2+gd failure
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2022-07-13 15:07:46 +02:00
3ccc00eece Merge pull request #614 from d8vjork/master
Add support for tool Laravel Pint
2022-07-11 15:57:41 +05:30
0f688a10cb Add support for tool Laravel Pint 2022-07-11 12:13:41 +02:00
3312ea6101 Bump version to 2.20.1
Fix format script in package.json
2022-07-08 04:55:53 +05:30
ce49f82dd8 Do not add composer plugins to allow list for composer v1 2022-07-08 04:55:44 +05:30
cf5cd90b4c Improve support for composer authenticating private respositories 2022-07-06 12:19:55 +05:30
cdb037c2a4 Bump version to 2.20.0 2022-07-06 00:43:26 +05:30
261f13a7c5 Add composer plugins to allow list before installing 2022-07-06 00:43:25 +05:30
9eaa66d89b Add support for event extension on unix 2022-07-05 16:22:07 +05:30
da9dfe4a71 Set RUNNER_TOOL_CACHE on self-hosted environments 2022-07-05 12:03:30 +05:30
a863ab6d3d Add support to allow composer plugins 2022-07-05 06:25:04 +05:30
050cb8061b Add coverage driver version in logs 2022-06-30 17:36:40 +05:30
3fda17f3fa Merge pull request #609 from dino182/develop
Fix Add-Path for self-hosted Windows
2022-06-27 17:24:50 +05:30
1a2cb4f872 Fix Add-Path for self-hosted Windows 2022-06-23 10:51:33 +01:00
4969814b69 Merge pull request #607 from markseuffert/patch-1
Updated documentation
2022-06-21 13:38:26 +05:30
07f2ea7d02 Updated documentation, review 2022-06-21 10:04:28 +02:00
a1c17b4b18 Updated documentation 2022-06-21 09:39:42 +02:00
3eda583472 Bump version to 2.19.1
Update Node.js dependencies
2022-06-06 08:22:16 +05:30
74d43be8a3 Fix support for deployer 2022-05-31 10:12:38 +05:30
aa1fe473f9 Bump version to 2.19.0 2022-05-30 07:52:31 +05:30
a92acf13e4 Remove years from LICENSE 2022-05-30 07:52:30 +05:30
0533892eb4 Fix jsdoc in fetch.ts 2022-05-30 07:52:30 +05:30
43fb4ad30e Bump ES version to 2021 2022-05-30 07:27:29 +05:30
b88a8c89d1 Fix protoc support 2022-05-26 10:21:36 +05:30
36d7f6c7c5 Set target-branch to develop in dependabot.yml 2022-05-26 09:47:27 +05:30
a1a52db9f3 Merge pull request #598 from shivammathur/dependabot/github_actions/codecov/codecov-action-3
Bump codecov/codecov-action from 2 to 3
2022-05-26 09:45:58 +05:30
88e54b10ca Merge pull request #599 from shivammathur/dependabot/github_actions/github/codeql-action-2
Bump github/codeql-action from 1 to 2
2022-05-26 09:45:50 +05:30
203099e007 Merge pull request #600 from shivammathur/dependabot/github_actions/actions/setup-node-3
Bump actions/setup-node from 1 to 3
2022-05-26 09:45:41 +05:30
4e9ea33f8d Bump actions/setup-node from 1 to 3
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 1 to 3.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-26 04:11:48 +00:00
68ba5ba947 Bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-26 04:11:43 +00:00
99af32331c Bump codecov/codecov-action from 2 to 3
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-26 04:11:36 +00:00
810a92a9b0 Merge pull request #597 from turrisxyz/Dependabot-GitHub-Actions
chore: Included githubactions in the dependabot config
2022-05-26 09:40:26 +05:30
9c760dd6e2 chore: Included githubactions in the dependabot config
This should help with keeping the GitHub actions updated on new releases. This will also help with keeping it secure.

Dependabot helps in keeping the supply chain secure https://docs.github.com/en/code-security/dependabot

GitHub actions up to date https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

https://github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2022-05-26 02:48:43 +00:00
dea233d702 Merge pull request #596 from turrisxyz/Pinned-Dependencies-GitHub
chore: Set permissions for GitHub actions
2022-05-26 06:59:24 +05:30
787285e08a chore: Set permissions for GitHub actions
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
2022-05-26 00:50:23 +00:00
ee065c5938 Append custom ini files to php.ini files 2022-05-25 20:43:46 +05:30
dbc8ba0844 Fix enabling cached dependent extensions on lower PHP versions 2022-05-25 19:44:02 +05:30
fe9e23a16a Add unixodbc if missing in sqlsrv setup 2022-05-25 10:16:23 +05:30
16de39288a Fix couchbase cache on macOS 2022-05-24 18:59:36 +05:30
67ff09364d Fix support for couchbase 4.x 2022-05-24 15:45:18 +05:30
1dfe0dc4a4 Add support to specify couchbase version 2022-05-19 23:56:27 +05:30
6f83b63bf5 Fix couchbase setup
Fix couchbase version to 3.x till 4.x is stable

The couchbase 4.x is based on a C++ client library and it shipped with the extension. So we only add the C client library for earlier versions
2022-05-19 15:09:52 +05:30
f0db57dcab Fix pecl support on PHP 5.3
Remove pecl suffix option support from PHP 5.3 as Console_Getopt version used does not support it
2022-05-19 11:56:00 +05:30
6cba851606 Add support for Ubuntu 22.04 2022-05-06 05:43:20 +05:30
209324abab Prefix extension formula with tap name on macOS 2022-05-05 23:43:11 +05:30
846135c190 Create empty composer.json in scoped directory
When installing composer based tools in a scoped directory with old composer versions it breaks if a composer.json is not present in the scoped directory
2022-05-02 11:22:58 +05:30
32d20248ae Improve support for composer fallback URLs 2022-04-23 11:57:06 +05:30
ba8485d89f Update OS support for self-hosted runners in README 2022-04-21 17:13:31 +05:30
97721a77b9 Fix shivammathur/node image tag in README 2022-04-21 17:06:25 +05:30
7dfee150df Remove fs dependency 2022-04-17 10:53:49 +05:30
251330ef7f Switch to node16 in actions.yml 2022-04-15 06:20:31 +05:30
86 changed files with 6194 additions and 4420 deletions

View File

@ -1,7 +1,7 @@
{
"env": { "node": true, "jest": true },
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 2019, "sourceType": "module" },
"parserOptions": { "ecmaVersion": 2021, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",

7
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "develop"
schedule:
interval: "weekly"

View File

@ -3,8 +3,15 @@ on:
workflow_dispatch:
schedule:
- cron: '0 15 * * 6'
permissions:
contents: read
jobs:
codeql:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
runs-on: ubuntu-latest
steps:
- name: Checkout
@ -13,13 +20,13 @@ jobs:
fetch-depth: 2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
config-file: ./.github/codeql/codeql-configuration.yml
languages: javascript
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@ -3,14 +3,19 @@ on:
workflow_dispatch:
schedule:
- cron: '0 15 * * 6'
permissions:
contents: read
jobs:
create:
permissions:
contents: none
name: Create
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [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']
steps:
- name: Setup PHP
@ -45,6 +50,8 @@ jobs:
name: lists
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
update:
permissions:
contents: write # for Git to git push
name: Update
needs: create
runs-on: ubuntu-latest
@ -63,7 +70,7 @@ jobs:
git config --local user.name "${{ github.repository_owner }}"
- name: Combine
run: |
for os in 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
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

View File

@ -16,6 +16,9 @@ on:
paths-ignore:
- '**.md'
- 'examples/**'
permissions:
contents: read
jobs:
run:
name: Run
@ -31,7 +34,7 @@ jobs:
fetch-depth: 2
- name: Setup Node.js 16.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x
@ -51,7 +54,7 @@ jobs:
run: npm audit
- name: Send Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info

View File

@ -17,6 +17,10 @@ on:
paths-ignore:
- '**.md'
- 'examples/**'
permissions:
contents: read
env:
default-php-version: '8.2'
jobs:
run:
name: Run
@ -24,10 +28,17 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.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']
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']
include:
- operating-system: ubuntu-22.04
php-versions: ''
php-version-file: 'php-version-file'
exclude:
- operating-system: macos-latest
php-versions: '8.3'
env:
extensions: xml, opcache, xdebug, pcov
extensions: xml, opcache, xdebug, pcov, gd
key: cache-v5
steps:
- name: Checkout
@ -37,7 +48,7 @@ jobs:
id: cache-env
uses: shivammathur/cache-extensions@develop
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-versions || env.default-php-version }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
@ -48,17 +59,23 @@ jobs:
key: ${{ 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
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
php-version-file: ${{ matrix.php-version-file }}
extensions: ${{ env.extensions }}
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata
- name: Testing PHP version
run: |
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
run: |
@ -67,6 +84,7 @@ jobs:
- name: Testing Extensions
run: |
php -m
php -r "if(! extension_loaded('gd')) {throw new Exception('gd not found');}"
php -r "if(! extension_loaded('xml')) {throw new Exception('xml not found');}"
php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"

View File

@ -28,7 +28,7 @@ jobs:
ref: ${{ github.event.inputs.tag }}
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org
@ -46,7 +46,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Change to GitHub Packages registry
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
registry-url: https://npm.pkg.github.com
scope: '@shivammathur'

View File

@ -1,7 +1,7 @@
The MIT License (MIT)
Copyright (c) 2019-2021 shivammathur and contributors
Copyright (c) shivammathur and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

245
README.md
View File

@ -10,7 +10,7 @@
<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://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.2-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.3-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
</p>
<p align="center">
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
@ -42,6 +42,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup)
- [Nightly Build Setup](#nightly-build-setup)
- [Debug Build Setup](#debug-build-setup)
- [Thread Safe Setup](#thread-safe-setup)
- [Force Update Setup](#force-update-setup)
- [Verbose Setup](#verbose-setup)
@ -51,7 +52,9 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [JIT Configuration](#jit-configuration)
- [Cache Extensions](#cache-extensions)
- [Cache Composer Dependencies](#cache-composer-dependencies)
- [Composer GitHub OAuth](#composer-github-oauth)
- [GitHub Composer Authentication](#github-composer-authentication)
- [Private Packagist Authentication](#private-packagist-authentication)
- [Manual Composer Authentication](#manual-composer-authentication)
- [Inline PHP Scripts](#inline-php-scripts)
- [Problem Matchers](#problem-matchers)
- [Examples](#examples)
@ -68,31 +71,28 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
### GitHub-Hosted Runners
| Virtual environment | YAML workflow label | Pre-installed PHP |
|----------------------|------------------------------------|------------------------|
| Ubuntu 20.04 | `ubuntu-latest` or `ubuntu-20.04` | `PHP 7.4` to `PHP 8.1` |
| Ubuntu 18.04 | `ubuntu-18.04` | `PHP 7.2` to `PHP 8.1` |
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.1` |
| Windows Server 2019 | `windows-2019` | `PHP 8.1` |
| macOS Monterey 12.x | `macos-12` | `PHP 8.1` |
| macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.1` |
| macOS Catalina 10.15 | `macos-10.15` | `PHP 8.1` |
| Virtual environment | YAML workflow label | Pre-installed PHP |
|---------------------|------------------------------------|------------------------|
| 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` |
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.2` |
| Windows Server 2019 | `windows-2019` | `PHP 8.2` |
| macOS Monterey 12.x | `macos-12` | `PHP 8.2` |
| macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.2` |
### Self-Hosted Runners
| Host OS/Virtual environment | YAML workflow label |
|----------------------------------|----------------------------|
| Ubuntu 21.04 | `self-hosted` or `Linux` |
| Ubuntu 22.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 10 | `self-hosted` or `Linux` |
| Debian 9 | `self-hosted` or `Linux` |
| Windows 7 and newer | `self-hosted` or `Windows` |
| Windows Server 2012 R2 and newer | `self-hosted` or `Windows` |
| macOS Ventura 13.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` |
| macOS Catalina 10.15 | `self-hosted` or `macOS` |
- 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.
@ -100,10 +100,10 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
## :tada: PHP Support
On all supported OS/Platforms the following PHP versions are supported 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.2 on GitHub-hosted runners.
- PHP 5.6 to PHP 8.2 on self-hosted runners.
- PHP 5.3 to PHP 8.3 on GitHub-hosted runners.
- PHP 5.6 to PHP 8.3 on self-hosted runners.
| PHP Version | Stability | Release Support | Runner Support |
|-------------|-----------|-----------------------|--------------------------------|
@ -115,13 +115,14 @@ On all supported OS/Platforms the following PHP versions are supported as per th
| `7.1` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
| `7.2` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
| `7.3` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
| `7.4` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` |
| `8.0` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `7.4` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
| `8.0` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` |
| `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.2` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
| `8.2` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.3` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
**Notes:**
- Specifying `8.2` in `php-version` input installs a nightly build of `PHP 8.2.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
- 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.
- To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
## :heavy_plus_sign: PHP Extension Support
@ -134,7 +135,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: imagick, swoole
```
@ -162,7 +163,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP with pre-release PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: xdebug-beta
```
@ -174,7 +175,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP and disable opcache
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: :opcache
```
@ -186,7 +187,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP without any shared extensions except mbstring
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: none, mbstring
```
@ -196,16 +197,16 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP with intl
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: intl-70.1
```
- Extensions loaded by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
- These extensions have custom support:
- `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`.
- `geos` on `Ubuntu` and `macOS`.
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3` and `phalcon4` on all supported OS.
- `cubrid` and `pdo_cubrid` on `Ubuntu`.
- `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`.
- `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`.
@ -213,7 +214,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- name: Setup PHP with fail-fast
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: oci8
env:
fail-fast: true
@ -223,13 +224,13 @@ 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.
[`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`], [`prestissimo`], [`protoc`], [`psalm`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
[`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`]
```yaml
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: php-cs-fixer, phpunit
```
@ -239,7 +240,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: vimeo/psalm
```
@ -252,25 +253,26 @@ 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.
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"). You can do that by setting `COMPOSER_TOKEN` environment variable.
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.
```yaml
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: php-cs-fixer:3.5, phpunit:9.5
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
- The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format, Additionally for composer `snapshot` and `preview` can also be specified to set up the respective releases.
- The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format. Additionally, for composer `snapshot` and `preview` can also be specified to set up the respective releases.
```yaml
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: composer:v2
```
@ -280,7 +282,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
- name: Setup PHP without composer
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: none
```
@ -290,13 +292,13 @@ 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`.
- 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
- name: Setup PHP with fail-fast
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: deployer
env:
fail-fast: true
@ -306,6 +308,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
- Input `tools` is useful to set up tools which are only used in CI workflows, thus keeping your `composer.json` tidy.
- If you do not want to use all your dev-dependencies in workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
- By default, `COMPOSER_NO_INTERACTION` is set to `1` and `COMPOSER_PROCESS_TIMEOUT` is set to `0`. In effect, this means that Composer commands in your scripts do not need to specify `--no-interaction`.
- Also, `COMPOSER_NO_AUDIT` is set to `1`. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a `composer audit` step before you install them.
## :signal_strength: Coverage Support
@ -318,7 +321,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: xdebug
```
@ -346,7 +349,7 @@ Runs on PHP 7.1 and newer PHP versions.
- name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov
```
@ -376,7 +379,7 @@ Disable coverage for these reasons:
- name: Setup PHP with no coverage driver
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: none
```
@ -386,14 +389,23 @@ Disable coverage for these reasons:
> Specify using `with` keyword
#### `php-version` (required)
#### `php-version` (optional)
- Specify the PHP version you want to set up.
- Accepts a `string`. For example `'8.0'`.
- 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 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)
@ -425,7 +437,7 @@ Disable coverage for these reasons:
- Specify the tools you want to set up.
- Accepts a `string` in csv-format. For example: `phpunit, phpcs`
- See [tools Support](#wrench-tools-support) for tools supported.
- See [tools support](#wrench-tools-support) for tools supported.
### Outputs
@ -440,7 +452,7 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
- name: Print PHP version
run: echo ${{ steps.setup-php.outputs.php-version }}
@ -459,7 +471,7 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
#### `phpts` (optional)
- Specify to set up thread-safe version of PHP on Windows.
- Specify to set up a thread-safe build of PHP on Linux and Windows.
- Accepts `ts` and `nts`.
- By default, it is set to `nts`.
- See [thread safe setup](#thread-safe-setup) for more info.
@ -482,7 +494,7 @@ steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: mbstring, intl
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
@ -500,12 +512,12 @@ jobs:
strategy:
matrix:
operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.1', '8.2', '8.3']
phpunit-versions: ['latest']
include:
- operating-system: 'ubuntu-latest'
php-versions: '7.2'
phpunit-versions: '8.5.21'
- operating-system: 'ubuntu-latest'
php-versions: '8.0'
phpunit-versions: 9
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
@ -515,11 +527,13 @@ jobs:
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Nightly Build Setup
> Set up a nightly build of `PHP 8.2`.
> Set up a nightly build of `PHP 8.3`.
- This PHP version is currently in active development and might contain bugs and breaking changes.
- Some user space extensions might not support this version currently.
@ -529,31 +543,48 @@ steps:
- name: Setup nightly PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
extensions: mbstring
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer, phpunit
```
### Debug Build Setup
> Set up a PHP build with debugging symbols.
- Production release builds of PHP without debugging symbols are set up by default.
- You can use the `debug` environment variable to set up a build with debugging symbols for PHP 5.6 and above.
```yaml
steps:
- name: Setup PHP with debugging symbols
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
env:
debug: true # specify true or false
```
### Thread Safe Setup
> Set up `TS` or `NTS` PHP on `Windows`.
> Set up `TS` or `NTS` PHP on `Linux` and `Windows`.
- `NTS` versions are set up by default.
- On `Ubuntu` and `macOS` only `NTS` versions are supported.
- On `Windows` both `TS` and `NTS` versions are supported.
- On `macOS` only `NTS` versions are supported currently.
- On `Linux` and `Windows` both `TS` and `NTS` versions are supported.
```yaml
jobs:
run:
runs-on: windows-latest
name: Setup PHP TS on Windows
runs-on: [ubuntu-latest, windows-latest]
name: Setup PHP TS
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
env:
phpts: ts # specify ts or nts
```
@ -563,13 +594,14 @@ jobs:
> Update to the latest patch of PHP versions.
- Pre-installed PHP versions are not updated to their latest patch release by default.
- If `ppa:ondrej/php` is missing on the Ubuntu GitHub environment, the PHP version is updated to the latest patch release.
- You can specify the `update` environment variable to `true` for updating to the latest release.
```yaml
- name: Setup PHP with latest versions
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
env:
update: true # specify true or false
```
@ -584,14 +616,14 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.
- name: Setup PHP with logs
uses: shivammathur/setup-php@verbose
with:
php-version: '8.1'
php-version: '8.2'
```
### Multi-Arch Setup
> Set up PHP on multiple architecture on Ubuntu GitHub Runners.
- `PHP 5.6` to `PHP 8.1` are supported by `setup-php` on multiple architecture on `Ubuntu`.
- `PHP 5.6` to `PHP 8.2` are supported by `setup-php` on multiple architecture on `Ubuntu`.
- For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` installed for `setup-php`.
- Currently, for `ARM` based setup, you will need [self-hosted runners](#self-hosted-setup).
@ -607,7 +639,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
```
### Self Hosted Setup
@ -629,7 +661,7 @@ jobs:
runs-on: self-hosted
strategy:
matrix:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
name: PHP ${{ matrix.php-versions }}
steps:
- name: Setup PHP
@ -657,27 +689,27 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
```
Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker images.
Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-20.04` in your workflow, run `act -P ubuntu-20.04=shivammathur/node:20.04`.
Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-20.04` in your workflow, run `act -P ubuntu-20.04=shivammathur/node:2004`.
```bash
# For runs-on: ubuntu-latest
act -P ubuntu-latest=shivammathur/node:latest
# For runs-on: ubuntu-22.04
act -P ubuntu-22.04=shivammathur/node:2204
# For runs-on: ubuntu-20.04
act -P ubuntu-20.04=shivammathur/node:2004
# For runs-on: ubuntu-18.04
act -P ubuntu-18.04=shivammathur/node:1804
```
### JIT Configuration
> Enable Just-in-time(JIT) on PHP 8.0 and above.
> Enable Just-in-time (JIT) on PHP 8.0 and above.
- To enable JIT, enable `opcache` in cli mode by setting `opcache.enable_cli=1`.
- JIT conflicts with `Xdebug`, `PCOV`, and other extensions which override `zend_execute_ex` function, so set `coverage: none` and disable any such extension if added.
@ -690,7 +722,7 @@ For example to enable JIT in `tracing` mode with buffer size of `64 MB`.
- name: Setup PHP with JIT in tracing mode
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: none
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
```
@ -707,10 +739,10 @@ If your project uses composer, you can persist the composer's internal cache dir
```yaml
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -733,17 +765,54 @@ key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.l
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
```
### Composer GitHub OAuth
### GitHub Composer Authentication
If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `GITHUB_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Private Packagist Authentication
If you use Private Packagist for your private composer dependencies, you can set the `PACKAGIST_TOKEN` environment variable to authenticate.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
env:
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
```
### Manual Composer Authentication
In addition to GitHub or Private Packagist, if you want to authenticate private repositories hosted elsewhere, you can set the `COMPOSER_AUTH_JSON` environment variable with the authentication methods and the credentials in json format.
Please refer to the authentication section in [`composer documentation`](https://getcomposer.org/doc/articles/authentication-for-private-packages.md "composer documentation") for more details.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
env:
COMPOSER_AUTH_JSON: |
{
"http-basic": {
"example.org": {
"username": "${{ secrets.EXAMPLE_ORG_USERNAME }}",
"password": "${{ secrets.EXAMPLE_ORG_PASSWORD }}"
}
}
}
```
### Inline PHP Scripts
@ -756,7 +825,7 @@ Put the code in the run property of a step and specify the shell as `php {0}`.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
- name: Run PHP code
shell: php {0}
@ -796,7 +865,7 @@ PHPStan supports error reporting in GitHub Actions, so it does not require probl
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: phpstan
- name: Run PHPStan
@ -811,7 +880,7 @@ Psalm supports error reporting in GitHub Actions with an output format `github`.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: psalm
- name: Run Psalm
@ -821,7 +890,7 @@ Psalm supports error reporting in GitHub Actions with an output format `github`.
#### Tools with checkstyle support
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
For examples refer to the [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpcs`.
@ -829,7 +898,7 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: cs2pr, phpcs
- name: Run phpcs
@ -838,7 +907,7 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
### Examples
Examples of using `setup-php` with various PHP Frameworks and Packages.
Examples of using `setup-php` with various PHP frameworks and packages.
| Framework/Package | Runs on | Workflow |
|----------------------------------------|---------------------------------|---------------------------------------------------------------------------------------------------------------|
@ -992,9 +1061,11 @@ These companies generously provide setup-php their products and services to aid
[`phpunit`]: https://phpunit.de/
[`phpunit-bridge`]: https://symfony.com/doc/current/components/phpunit_bridge.html
[`phpunit-polyfills`]: https://github.com/Yoast/PHPUnit-Polyfills
[`pint`]: https://github.com/laravel/pint
[`prestissimo`]: https://github.com/hirak/prestissimo
[`protoc`]: https://developers.google.com/protocol-buffers/
[`psalm`]: https://psalm.dev/
[`rector`]: https://getrector.org/
[`symfony`]: https://symfony.com/download
[`symfony-cli`]: https://symfony.com/download
[`vapor`]: https://docs.vapor.build/

View File

@ -4,6 +4,8 @@ describe('Config tests', () => {
it.each`
driver | php | os | output
${'PCOV'} | ${'7.4'} | ${'win32'} | ${'Add-Extension pcov,Disable-Extension xdebug false'}
${'pcov'} | ${'7.4'} | ${'win32'} | ${'$pcov_version = php -r "echo phpversion(\'pcov\');"'}
${'pcov'} | ${'7.4'} | ${'win32'} | ${'PCOV $pcov_version enabled as coverage driver'}
${'pcov'} | ${'7.0'} | ${'win32'} | ${'PHP 7.1 or newer is required'}
${'pcov'} | ${'5.6'} | ${'win32'} | ${'PHP 7.1 or newer is required'}
${'pcov'} | ${'7.4'} | ${'win32'} | ${'Add-Extension pcov,Disable-Extension xdebug false'}
@ -15,6 +17,8 @@ describe('Config tests', () => {
${'xdebug'} | ${'8.0'} | ${'linux'} | ${'add_extension xdebug'}
${'xdebug3'} | ${'8.0'} | ${'linux'} | ${'add_extension xdebug'}
${'xdebug2'} | ${'7.4'} | ${'linux'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
${'xdebug'} | ${'7.4'} | ${'linux'} | ${'xdebug_version="$(php -r "echo phpversion(\'xdebug\');")"'}
${'xdebug'} | ${'7.4'} | ${'linux'} | ${'Xdebug $xdebug_version enabled as coverage driver'}
${'xdebug'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension xdebug'}
${'xdebug3'} | ${'7.1'} | ${'darwin'} | ${'xdebug3 is not supported on PHP 7.1'}
${'xdebug2'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension xdebug2'}

View File

@ -25,6 +25,7 @@ describe('Extension tests', () => {
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
${'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',
async ({extension, version, output}) => {
@ -48,6 +49,7 @@ describe('Extension tests', () => {
${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'}
${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'}
${'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'}
${'oci8'} | ${'7.3'} | ${'add_oci oci8'}
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'}
@ -59,11 +61,14 @@ describe('Extension tests', () => {
${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'}
${'pecl_http'} | ${'7.3'} | ${'add_http'}
${'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'}
${'sqlsrv-1.2.3-beta1'} | ${'7.4'} | ${'add_pecl_extension sqlsrv 1.2.3beta1 extension'}
${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'}
${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha 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',
async ({extension, version, output}) => {
@ -92,8 +97,9 @@ describe('Extension tests', () => {
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
${'pecl_http'} | ${'7.3'} | ${'add_http'}
${'relay-1.2.3'} | ${'7.4'} | ${'add_relay relay-1.2.3'}
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
${'sqlsrv'} | ${'7.3'} | ${'add_sqlsrv sqlsrv'}
${'zephir_parser-v1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-v1.2.3'}
`(
'checking addExtensionOnDarwin for extension $extension on version $version',
async ({extension, version, output}) => {
@ -112,12 +118,13 @@ describe('Extension tests', () => {
const [formula, extension]: string[] = line.split('=');
const prefix: string =
extension == 'xdebug' ? 'zend_extension' : 'extension';
const ext_name = extension.replace(/\d+|(pdo|pecl)[_-]/, '');
const output: string = fs.existsSync(
`src/scripts/extensions/${extension}.sh`
`src/scripts/extensions/${ext_name}.sh`
)
? `add_${extension}`
? `add_${ext_name}`
: `add_brew_extension ${formula} ${prefix}`;
return [formula, '7.3', output];
return [formula, formula === 'phalcon3' ? '7.3' : '7.4', output];
});
it.each(data)(

View File

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

View File

@ -45,7 +45,11 @@ jest.mock('../src/fetch', () => ({
.fn()
.mockImplementation(
async (url: string, token?: string): Promise<Record<string, string>> => {
if (url.includes('atom') && !url.includes('no-')) {
if (url.includes('deployer')) {
return {
data: '[{"version": "1.2.3", "url": "https://deployer.org/releases/v1.2.3/deployer.phar"}]'
};
} else if (url.includes('atom') && !url.includes('no-')) {
return {
data: '"releases/tag/1.2.3", "releases/tag/3.2.1", "releases/tag/2.3.1"'
};
@ -218,11 +222,11 @@ describe('Tools tests', () => {
});
it.each`
os | script | scope
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
${'darwin'} | ${'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'}
os | script | scope
${'linux'} | ${'add_composer_tool tool tool:1.2.3 user/ global'} | ${'global'}
${'darwin'} | ${'add_composer_tool 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'}
`('checking addPackage: $os, $scope', async ({os, script, scope}) => {
const data = getData({
tool: 'tool',
@ -261,8 +265,9 @@ describe('Tools tests', () => {
it.each`
version | php_version | url
${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player.phar'}
${'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'}
${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.22.0.phar'}
${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
`(
@ -283,6 +288,7 @@ describe('Tools tests', () => {
version | url
${'latest'} | ${'https://deployer.org/deployer.phar'}
${'1.2.3'} | ${'https://deployer.org/releases/v1.2.3/deployer.phar'}
${'3.2.1'} | ${'Version missing in deployer manifest'}
`('checking addDeployer: $version', async ({version, url}) => {
const data = getData({
tool: 'deployer',
@ -293,31 +299,41 @@ describe('Tools tests', () => {
});
it.each`
version | no_tool_cache | cache_url | source_url
${'latest'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'stable'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'snapshot'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar'} | ${'https://getcomposer.org/composer.phar'}
${'preview'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'}
${'1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'}
${'1.2.3'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3.phar'}
${'1.2.3-RC1'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3-RC1/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3-RC1.phar'}
version | php_version | no_tool_cache | cache_url | source_url
${'latest'} | ${'7.4'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'stable'} | ${'7.4'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'snapshot'} | ${'7.4'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar'} | ${'https://getcomposer.org/composer.phar'}
${'preview'} | ${'7.4'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'}
${'1'} | ${'7.4'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.4'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'}
${'latest'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'stable'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'snapshot'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar'} | ${'https://getcomposer.org/composer.phar'}
${'preview'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'}
${'1'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'}
${'latest'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'stable'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'snapshot'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-snapshot.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'preview'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-preview.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'1'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-2.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'1.2.3'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3.phar'}
${'1.2.3-RC1'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3-RC1/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3-RC1.phar'}
`(
'checking addComposer: $version, $no_tool_cache',
async ({version, no_tool_cache, cache_url, source_url}) => {
'checking addComposer: $version, $php_version, $no_tool_cache',
async ({version, php_version, no_tool_cache, cache_url, source_url}) => {
const data = getData({
tool: 'composer',
php_version: php_version,
domain: 'https://getcomposer.org',
repository: 'composer/composer',
version: version
});
process.env['no_tools_cache'] = no_tool_cache;
expect(await tools.addComposer(data)).toContain(source_url);
if (no_tool_cache !== 'true') {
expect(await tools.addComposer(data)).toContain(
`${cache_url},${source_url}`
);
} else {
expect(await tools.addComposer(data)).toContain(source_url);
expect(await tools.addComposer(data)).toContain(cache_url);
}
}
);
@ -357,33 +373,34 @@ describe('Tools tests', () => {
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, php-config, phpize, protoc, symfony, vapor, wp',
'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',
[
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/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_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/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_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/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://phar.phpunit.de/phpunit.phar phpunit "--version"',
'add_pecl',
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
'add_composertool phinx phinx robmorgan/ scoped',
'add_composertool phinx phinx:1.2.3 robmorgan/ scoped',
'add_composer_tool phinx phinx 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_composertool phpunit-bridge phpunit-bridge symfony/ global',
'add_composertool phpunit-polyfills phpunit-polyfills yoast/ global',
'add_composer_tool phpunit-bridge phpunit-bridge symfony/ 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_devtools php-config',
'add_devtools phpize',
'add_protoc 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"'
]
]
@ -396,24 +413,24 @@ describe('Tools tests', () => {
it.each([
[
'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, 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://getcomposer.org/composer-stable.phar composer',
'add_composertool behat behat behat/ scoped',
'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_composer_tool behat behat behat/ scoped',
'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/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"',
'add_composertool composer-require-checker composer-require-checker maglnet/ scoped',
'add_composertool composer-unused composer-unused icanhazstring/ 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/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_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/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_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_devtools php-config',
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"',
@ -423,12 +440,13 @@ describe('Tools tests', () => {
'add_devtools phpize',
'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_composertool phpunit-bridge phpunit-bridge:5.6.* symfony/ global',
'add_composertool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
'add_composer_tool phpunit-bridge phpunit-bridge:5.6.* symfony/ global',
'add_composer_tool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
'add_protoc 1.2.3',
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
'add_composer_tool rector rector rector/ scoped',
'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"'
]
]
@ -443,20 +461,20 @@ describe('Tools tests', () => {
[
'blackfire, blackfire-player:1.2.3, cs2pr, churn, deployer, does_not_exist, flex, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp',
[
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/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-Tool https://get.blackfire.io/blackfire-player-v1.2.3.phar blackfire-player "-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://deployer.org/deployer.phar deployer "-V"',
'Tool does_not_exist is not supported',
'Add-Composertool flex flex symfony/ global',
'Add-Composertool phinx phinx robmorgan/ scoped',
'Add-ComposerTool flex flex symfony/ global',
'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"',
'php-config 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-Composertool phpunit-bridge phpunit-bridge symfony/ global',
'Add-ComposerTool phpunit-bridge phpunit-bridge symfony/ global',
'Add-Symfony',
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
]
@ -472,14 +490,14 @@ 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',
[
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer',
'Add-Composertool codeception codeception codeception/ global',
'Add-Composertool prestissimo prestissimo hirak/ 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/ global',
'Add-Composertool tool tool:1.2.3 user/ global',
'Add-Composertool tool tool:~1.2 user/ global'
'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 prestissimo prestissimo hirak/ 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/ global',
'Add-ComposerTool tool tool:1.2.3 user/ global',
'Add-ComposerTool tool tool:~1.2 user/ global'
]
]
])(
@ -495,10 +513,10 @@ describe('Tools tests', () => {
it.each`
tools_csv | script
${'none'} | ${''}
${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'}
${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/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://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://getcomposer.org/composer.phar composer snapshot'}
${'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"'}
${'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: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'}
`('checking composer setup: $tools_csv', async ({tools_csv, script}) => {
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
});
@ -512,4 +530,14 @@ describe('Tools tests', () => {
process.env['COMPOSER_TOKEN'] = token;
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
});
it.each`
tools_csv | token | script
${'cs2pr:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "cs2pr" "Invalid token"'}
${'phpunit:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "phpunit" "Invalid token"'}
${'phpunit:0.1'} | ${'no_data'} | ${'add_log "$cross" "phpunit" "No version found with prefix 0.1."'}
`('checking error: $tools_csv', async ({tools_csv, token, script}) => {
process.env['GITHUB_TOKEN'] = token;
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
});
});

View File

@ -1,3 +1,4 @@
import fs from 'fs';
import * as path from 'path';
import * as utils from '../src/utils';
@ -7,7 +8,8 @@ import * as utils from '../src/utils';
jest.mock('@actions/core', () => ({
getInput: jest.fn().mockImplementation(key => {
return ['setup-php'].indexOf(key) !== -1 ? key : '';
})
}),
info: jest.fn()
}));
/**
@ -109,6 +111,9 @@ describe('Utils tests', () => {
expect(
await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'')
).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']);
expect(
await utils.CSVArray('a="b=c;d=e", b=\'c=d,e\', c="g=h,i=j", d=g=h, a===')
).toEqual(["a='b=c;d=e'", "b='c=d,e'", "c='g=h,i=j'", "d='g=h'", "a='=='"]);
expect(await utils.CSVArray('')).toEqual([]);
expect(await utils.CSVArray(' ')).toEqual([]);
});
@ -190,6 +195,7 @@ describe('Utils tests', () => {
expect(await utils.getCommand('linux', '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_name')).toBe('Add-ToolName ');
expect(await utils.getCommand('openbsd', 'tool')).toContain(
'Platform openbsd is not supported'
);
@ -256,4 +262,36 @@ describe('Utils tests', () => {
'\nadd_extension_from_source ext https://sub.domain.XN--tld org repo release extension'
);
});
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');
existsSync.mockClear();
readFileSync.mockClear();
});
it('checking setVariable', async () => {
let script: string = await utils.setVariable('var', 'command', 'linux');
expect(script).toEqual('\nvar="$(command)"\n');
script = await utils.setVariable('var', 'command', 'darwin');
expect(script).toEqual('\nvar="$(command)"\n');
script = await utils.setVariable('var', 'command', 'win32');
expect(script).toEqual('\n$var = command\n');
});
});

View File

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

2083
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:

View File

@ -47,7 +47,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -86,7 +86,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -120,7 +120,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -47,7 +47,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -86,7 +86,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -120,7 +120,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -23,7 +23,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -57,7 +57,7 @@ jobs:
extensions: mbstring, intl
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
@ -91,7 +91,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -22,7 +22,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -21,7 +21,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -56,7 +56,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -24,7 +24,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -56,7 +56,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -24,7 +24,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -55,7 +55,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:

View File

@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
node-versions: [16']
node-versions: ['16']
steps:
- name: Checkout
uses: actions/checkout@v3
@ -31,7 +31,7 @@ jobs:
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -22,7 +22,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -25,7 +25,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -51,7 +51,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

View File

@ -51,7 +51,7 @@ jobs:
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3

6295
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "2.18.1",
"version": "2.25.2",
"private": false,
"description": "Setup PHP for use with GitHub Actions",
"main": "lib/install.js",
@ -17,7 +17,7 @@
"scripts": {
"build": "tsc",
"lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix",
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f src/",
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f __tests__/ ",
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
"release": "ncc build -o dist && git add -f dist/",
"test": "jest"
@ -34,29 +34,28 @@
"author": "shivammathur",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.6.0",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"fs": "0.0.1-security"
"@actions/io": "^1.1.3"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"@vercel/ncc": "^0.33.3",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.4",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.1",
"jest-circus": "^27.5.1",
"nock": "^13.2.4",
"prettier": "^2.6.2",
"simple-git-hooks": "^2.7.0",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
"@types/jest": "^29.5.1",
"@types/node": "^20.2.3",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@vercel/ncc": "^0.36.1",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"jest-circus": "^29.5.0",
"nock": "^13.3.1",
"prettier": "^2.8.8",
"simple-git-hooks": "^2.8.1",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
},
"bugs": {
"url": "https://github.com/shivammathur/setup-php/issues"

View File

@ -1,11 +1,17 @@
amqp=amqp
apcu=apcu
ast=ast
couchbase=couchbase
ds=ds
event=event
expect=expect
gearman=gearman
gnupg=gnupg
grpc=grpc
igbinary=igbinary
imagick=imagick
imap=imap
lua=lua
mailparse=mailparse
mcrypt=mcrypt
memcache=memcache
@ -13,17 +19,23 @@ memcached=memcached
mongodb=mongodb
msgpack=msgpack
pcov=pcov
pdo_sqlsrv=pdo_sqlsrv
pecl_http=http
phalcon3=phalcon
phalcon4=phalcon
phalcon5=phalcon
propro=propro
protobuf=protobuf
psr=psr
raphf=raphf
rdkafka=rdkafka
redis=redis
snmp=snmp
sqlsrv=sqlsrv
ssh2=ssh2
swoole=swoole
uuid=uuid
v8js=v8js
vips=vips
xdebug=xdebug
xdebug2=xdebug

View File

@ -1,2 +1,3 @@
COMPOSER_PROCESS_TIMEOUT=0
COMPOSER_NO_INTERACTION=1
COMPOSER_NO_AUDIT=1

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,7 +1,7 @@
{
"latest": "8.1",
"nightly": "8.2",
"latest": "8.2",
"nightly": "8.3",
"5.x": "5.6",
"7.x": "7.4",
"8.x": "8.1"
"8.x": "8.2"
}

View File

@ -0,0 +1,11 @@
cgi
cli
curl
fpm
intl
mbstring
mysql
opcache
pgsql
xml
zip

View File

@ -7,6 +7,14 @@
"version_prefix": "",
"version_parameter": "-V"
},
"composer-unused": {
"type": "phar",
"repository": "composer-unused/composer-unused",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "-V"
},
"composer-normalize": {
"type": "phar",
"repository": "ergebnis/composer-normalize",
@ -105,6 +113,14 @@
"version_prefix": "",
"version_parameter": "-V"
},
"pint": {
"type": "phar",
"repository": "laravel/pint",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "v",
"version_parameter": "-V"
},
"psalm": {
"type": "phar",
"repository": "vimeo/psalm",
@ -134,11 +150,6 @@
"repository": "maglnet/composer-require-checker",
"scope": "scoped"
},
"composer-unused": {
"type": "composer",
"repository": "icanhazstring/composer-unused",
"scope": "scoped"
},
"flex": {
"type": "composer",
"repository": "symfony/flex",
@ -176,6 +187,11 @@
"repository": "laravel/vapor-cli",
"scope": "scoped"
},
"rector": {
"type": "composer",
"repository": "rector/rector",
"scope": "scoped"
},
"blackfire": {
"type": "custom-package",
"alias": "blackfire-agent"

View File

@ -0,0 +1,2 @@
xdebug
pcov

View File

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

View File

@ -31,20 +31,28 @@ export async function addExtensionDarwin(
case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix);
return;
// match 5.3blackfire...8.1blackfire
// match 7.4relay...8.3relay
// match 5.3blackfire...8.2blackfire
// match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match couchbase, geos, pdo_oci, oci8, http, pecl_http
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(
// 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(
version_extension
):
case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
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\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.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 /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage(
ext_name,
'extensions',
@ -62,7 +70,7 @@ export async function addExtensionDarwin(
);
return;
// match semver
case /.+-\d+\.\d+\.\d+.*/.test(extension):
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins(
'\nadd_pecl_extension',
ext_name,
@ -74,16 +82,14 @@ export async function addExtensionDarwin(
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return;
// match 5.6 and newer - amqp, apcu, expect, gnupg, grpc, igbinary, imagick, imap, memcache, memcached, mongodb, msgpack, protobuf, raphf, rdkafka, redis, ssh2, swoole, xdebug, xdebug2, yaml, zmq
// match 7.1 and newer - pcov
// match 5.6 to 7.4 - propro
// match 7.0 and newer - vips, xlswriter
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(
// 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|snmp|ssh2|swoole|uuid|xdebug|xdebug2|yaml|zmq)/.test(
version_extension
):
case /(5\.6|7\.[0-4])propro/.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\.[3-6]|7\.0)pcov/.test(version_extension):
case /(?<!5\.[3-6])(vips|xlswriter)/.test(version_extension):
case /(?<!5\.[3-6])(ast|vips|xlswriter)/.test(version_extension):
add_script += await utils.joins(
'\nadd_brew_extension',
ext_name,
@ -128,19 +134,25 @@ export async function addExtensionWindows(
case /^none$/.test(ext_name):
add_script += '\nDisable-AllShared';
break;
// match 5.3blackfire...8.1blackfire
// match 5.3blackfire...8.2blackfire
// match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// 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
case /^(5\.[3-6]|7\.[0-4]|8\.1)blackfire(-\d+\.\d+\.\d+)?$/.test(
// match 7.0zephir_parser...8.2zephir_parser
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension
):
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(
version_extension
):
case /^(7\.[1-4]|8\.1)(pecl_)?http/.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',
@ -164,15 +176,6 @@ export async function addExtensionWindows(
'win32'
);
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
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec(
@ -185,6 +188,15 @@ export async function addExtensionWindows(
matches[1]
);
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
case /7\.[2-4]xdebug2/.test(version_extension):
add_script += '\nAdd-Extension xdebug stable 2.9.8';
@ -250,25 +262,33 @@ export async function addExtensionLinux(
case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix);
return;
// match 5.3blackfire...8.1blackfire
// match 7.4relay...8.3relay
// match 5.3blackfire...8.2blackfire
// match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// match couchbase, geos, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(
// 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(
version_extension
):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(
version_extension
):
case /^couchbase$|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
extension
):
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
case /(?<!5\.[3-5])intl-\d+\.\d+$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.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',
@ -286,7 +306,7 @@ export async function addExtensionLinux(
);
return;
// match semver versions
case /.+-\d+\.\d+\.\d+.*/.test(extension):
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins(
'\nadd_pecl_extension',
ext_name,

View File

@ -3,10 +3,11 @@ import * as https from 'https';
import * as url from 'url';
/**
* Function to fetch an URL
* Function to fetch a URL
*
* @param input_url
* @param auth_token
* @param redirect_count
*/
export async function fetch(
input_url: string,

View File

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

View File

@ -1,16 +1,7 @@
# Function to setup environment for self-hosted runners.
self_hosted_helper() {
if ! command -v brew >/dev/null; then
step_log "Setup Brew"
get -q -e "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" && /tmp/install.sh >/dev/null 2>&1
add_log "${tick:?}" "Brew" "Installed Homebrew"
fi
}
# Disable dependency extensions
disable_dependency_extensions() {
local extension=$1
formula_file="$tap_dir/$ext_tap/Formula/$extension@${version:?}.rb"
formula_file="${tap_dir:?}/$ext_tap/Formula/$extension@${version:?}.rb"
if [ -e "$formula_file" ]; then
IFS=" " read -r -a dependency_extensions <<< "$(grep -Eo "shivammathur.*@" "$formula_file" | xargs -I {} -n 1 basename '{}' | cut -d '@' -f 1 | tr '\n' ' ')"
for dependency_extension in "${dependency_extensions[@]}"; do
@ -33,38 +24,11 @@ disable_extension_helper() {
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
}
# Function to fetch a brew tap.
fetch_brew_tap() {
tap=$1
tap_user=$(dirname "$tap")
tap_name=$(basename "$tap")
mkdir -p "$tap_dir/$tap_user"
get -s -n "" "https://github.com/$tap/archive/master.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
if [ -d "$tap_dir/$tap_user/$tap_name-master" ]; then
sudo mv "$tap_dir/$tap_user/$tap_name-master" "$tap_dir/$tap_user/$tap_name"
fi
}
# Function to add a brew tap.
add_brew_tap() {
tap=$1
if ! [ -d "$tap_dir/$tap" ]; then
if [ "${runner:?}" = "self-hosted" ]; then
brew tap "$tap" >/dev/null 2>&1
else
fetch_brew_tap "$tap" >/dev/null 2>&1
if ! [ -d "$tap_dir/$tap" ]; then
brew tap "$tap" >/dev/null 2>&1
fi
fi
fi
}
# Function to get extension name from brew formula.
get_extension_from_formula() {
local formula=$1
local extension
extension=$(grep "$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2)
extension=$(grep -E "^$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2)
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
echo "$extension"
}
@ -76,9 +40,10 @@ copy_brew_extensions() {
deps="$(grep -Eo 'depends_on "shivammathur[^"]+' "$formula_file" | cut -d '/' -f 3 | tr '\n' ' ')"
IFS=' ' read -r -a deps <<< "$formula@$version $deps"
for dependency in "${deps[@]}"; do
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"
done
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
}
# Function to install a php extension from shivammathur/extensions tap.
@ -92,10 +57,10 @@ add_brew_extension() {
else
add_brew_tap "$php_tap"
add_brew_tap "$ext_tap"
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
disable_dependency_extensions "$extension" >/dev/null 2>&1
brew install -f "$formula@$version" >/dev/null 2>&1
brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1
copy_brew_extensions "$formula"
add_extension_log "$extension" "Installed and enabled"
fi
@ -141,7 +106,7 @@ link_libraries() {
# Patch brew to overwrite packages.
patch_brew() {
formula_installer="$brew_repo"/Library/Homebrew/formula_installer.rb
formula_installer="${brew_repo:?}"/Library/Homebrew/formula_installer.rb
code=" keg.link\(verbose: verbose\?"
sudo sed -Ei '' "s/$code.*/$code, overwrite: true\)/" "$formula_installer"
# shellcheck disable=SC2064
@ -160,10 +125,13 @@ update_dependencies() {
patch_brew
if ! [ -e /tmp/update_dependencies ]; then
if [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
while read -r dependency; do
update_dependencies_helper "$dependency" &
to_wait+=($!)
done <"$tap_dir/$php_tap/.github/deps/${ImageOS:?}_${ImageVersion:?}"
deps_file="$tap_dir/$php_tap/.github/deps/${ImageOS:?}_${ImageVersion:?}"
if [ -e "$deps_file" ]; then
while read -r dependency; do
update_dependencies_helper "$dependency" &
to_wait+=($!)
done <"$deps_file"
fi
wait "${to_wait[@]}"
else
git -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
@ -199,6 +167,7 @@ add_php() {
existing_version=$2
add_brew_tap "$php_tap"
update_dependencies
[ "${debug:?}" = "debug" ] && php_formula="$php_formula-debug"
if [ "$existing_version" != "false" ]; then
([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula"
else
@ -275,16 +244,10 @@ setup_php() {
}
# Variables
version=${1:-'8.1'}
version=${1:-'8.2'}
ini=${2:-'production'}
src=${0%/*}/..
php_formula=shivammathur/php/php@"$version"
brew_path="$(command -v brew)"
brew_path_dir="$(dirname "$brew_path")"
brew_prefix="$brew_path_dir"/..
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
tap_dir="$brew_repo"/Library/Taps
core_repo="$tap_dir"/homebrew/homebrew-core
scripts="$src"/scripts
ext_tap=shivammathur/homebrew-extensions
php_tap=shivammathur/homebrew-php
@ -297,9 +260,11 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
# shellcheck source=.
. "${scripts:?}"/unix.sh
. "${scripts:?}"/tools/brew.sh
. "${scripts:?}"/tools/add_tools.sh
. "${scripts:?}"/extensions/source.sh
. "${scripts:?}"/extensions/add_extensions.sh
configure_brew
read_env
self_hosted_setup
setup_php

View File

@ -1,3 +1,20 @@
Function Add-ExtensionLog() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
$extension,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
$message
)
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
if ($null -ne $extension_info -and ($extension_info.State -eq 'Enabled' -or $extension_info.State -eq 'Builtin')) {
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 Set-ExtensionPrerequisites
{
@ -6,8 +23,9 @@ Function Set-ExtensionPrerequisites
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$deps_dir
$extension
)
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
$deps = Get-ChildItem -Recurse -Path $deps_dir
if ($deps.Count -ne 0) {
# Symlink dependencies instead of adding the directory to PATH ...
@ -20,6 +38,41 @@ Function Set-ExtensionPrerequisites
}
}
# Function to enable extension.
Function Enable-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
Enable-ExtensionDependencies $extension
Enable-PhpExtension -Extension $extension -Path $php_dir
Set-ExtensionPrerequisites $extension
Add-Log $tick $extension "Enabled"
}
# Function to add custom built PHP extension for nightly builds.
Function Add-NightlyExtension {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
$repo = "$github/shivammathur/php-extensions-windows"
$url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
Get-File -Url $url -OutFile "$ext_dir\php_$extension.dll"
if(Test-Path "$ext_dir\php_$extension.dll") {
Enable-Extension $extension > $null
} else {
throw "Failed to download the $extension"
}
}
# Function to add PHP extensions.
Function Add-Extension {
Param (
@ -52,31 +105,32 @@ Function Add-Extension {
Add-Log $tick $extension "Enabled"
}
default {
Enable-ExtensionDependencies $extension
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
Set-ExtensionPrerequisites $deps_dir
Add-Log $tick $extension "Enabled"
Enable-Extension $extension_info.Handle
}
}
}
else {
# Patch till PHP 8.1 DLLs are released as stable.
$minimumStability = $stability
if($version -eq '8.1' -and $stability -eq 'stable') {
$minimumStability = 'snapshot'
}
if(($version -match $nightly_versions) -and (Select-String -Path $src\configs\windows_extensions -Pattern $extension -SimpleMatch -Quiet)) {
Add-NightlyExtension $extension
} else {
# Patch till DLLs for PHP 8.1 and 8.2 are released as stable.
$minimumStability = $stability
if ($version -match '8.[1-2]' -and $stability -eq 'stable') {
$minimumStability = 'snapshot'
}
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
if($extension_version -ne '') {
$params["Version"] = $extension_version
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
if ($extension_version -ne '')
{
$params["Version"] = $extension_version
}
Install-PhpExtension @params
Set-ExtensionPrerequisites $extension
}
Install-PhpExtension @params
Set-ExtensionPrerequisites $deps_dir
Add-Log $tick $extension "Installed and enabled"
}
}
catch {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
}
}

View File

@ -30,7 +30,8 @@ enable_cache_extension_dependencies() {
cache_dir=$(find /tmp/extcache -maxdepth 1 -type d -regex ".*$1[0-9]*")
if [[ -n "$cache_dir" ]]; then
IFS=" " read -r -a deps <<<"$(find "$cache_dir" -maxdepth 1 -type f -name "*" -exec basename {} \; | tr '\n' ' ')"
if [[ -n "${deps[*]}" ]] && php "${deps[@]/#/-d ${2}=}" -d "${2}=$1" -m 2>/dev/null | grep -i -q "$1"; then
IFS="#" read -r -a deps_enable <<<"$(printf -- "-d ${2}=%s.so#" "${deps[@]}")"
if [[ -n "${deps[*]}" ]] && php "${deps_enable[@]}" -d "${2}=$1.so" -m 2>/dev/null | grep -i -q "$1"; then
for ext in "${deps[@]}"; do
sudo rm -rf /tmp/extcache/"$ext"
enable_extension "$ext" "$2"
@ -47,7 +48,19 @@ enable_extension() {
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
enable_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
}
@ -113,15 +126,15 @@ 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
mkdir -p /tmp/extdisabled/"$version"
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"
}
# Function to configure PECL.
configure_pecl() {
[ -z "${pecl_file:-${ini_file[@]}}" ] && return
if ! [ -e /tmp/pecl_config ]; then
for script in pear pecl; do
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
sudo "$script" channel-update "$script".php.net
done
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
@ -143,26 +156,40 @@ add_extension() {
# Function to get the PECL version of an extension.
get_pecl_version() {
local extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
states=("stable" "rc" "preview" "beta" "alpha" "snapshot")
stability="$(echo "$2" | grep -m 1 -Eio "($(IFS='|' ; echo "${states[*]}"))")"
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo "$stability.*")"
major_version=${3:-'[0-9]+'}
pecl_rest='https://pecl.php.net/rest/r/'
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
fi
for state in "${states[@]}"; do
pecl_version=$(echo "$response" | grep -m 1 -Eio "($major_version\.[0-9]+\.[0-9]+${state}[0-9]+<)" | cut -d '<' -f 1)
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eio "v>(.*)<\/v>.*$state<" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+.*)<" | cut -d '<' -f 1)
[ -n "$pecl_version" ] && break;
done
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+)<" | cut -d '<' -f 1)
echo "$pecl_version"
}
# Function to install PECL extensions and accept default options
pecl_install() {
local extension=$1
local prefix=${2:-extension}
add_pecl >/dev/null 2>&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'"
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)"
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/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
disable_extension_helper "${extension%-*}" >/dev/null 2>&1
if [ "$version" = "5.3" ]; then
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
else
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
fi
local exit_code=$?
enable_extension "${extension%-*}" "$prefix"
return "$exit_code"
}
# Function to install a specific version of PECL extension.
@ -178,9 +205,11 @@ add_pecl_extension() {
if [ "${ext_version/-/}" = "$pecl_version" ]; then
add_log "${tick:?}" "$extension" "Enabled"
else
disable_extension_helper "$extension" >/dev/null 2>&1
pecl_install "$extension-$pecl_version"
add_extension_log "$extension-$pecl_version" "Installed and enabled"
[ -n "$pecl_version" ] && pecl_version="-$pecl_version"
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1
extension_version="$(php -r "echo phpversion('$extension');")"
[ -n "$extension_version" ] && extension_version="-$extension_version"
add_extension_log "$extension$extension_version" "Installed and enabled"
fi
}
@ -192,3 +221,8 @@ add_unstable_extension() {
pecl_version=$(get_pecl_version "$extension" "$stability")
add_pecl_extension "$extension" "$pecl_version" "$prefix"
}
# Function to get extension prefix
get_extension_prefix() {
echo "$1" | grep -Eq "xdebug([2-3])?$|opcache|ioncube|eaccelerator" && echo zend_extension || echo extension
}

View File

@ -21,7 +21,7 @@ Function Add-Blackfire() {
$status="Enabled"
} 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
$status="Installed and enabled"
}

View File

@ -1,43 +1,70 @@
# Function to install libraries required by couchbase
add_couchbase_libs() {
if [ "$(uname -s)" = "Linux" ]; then
trunk="https://github.com/couchbase/libcouchbase/releases"
if [[ ${version:?} =~ 5.[3-6]|7.[0-1] ]]; then
release="2.10.9"
else
release="$(curl -sL $trunk/latest | grep -Eo "libcouchbase-[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -d'-' -f 2)"
fi
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${VERSION_ID/./}_${VERSION_CODENAME}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url"
sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4 libevent-dev
sudo dpkg -i /tmp/libcouchbase-*/*.deb
add_couchbase_clibs() {
ext=$1
trunk="https://github.com/couchbase/libcouchbase/releases"
if [[ "$ext" =~ couchbase-2.+ ]]; then
release="2.10.9"
else
if [[ ${version:?} =~ 5.[3-6]|7.[0-1] ]]; then
brew install libcouchbase@2
brew link --overwrite --force libcouchbase@2
else
brew install libcouchbase
fi
release=$(get -s -n "" "$trunk"/latest | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)
fi
[ "$VERSION_ID" = "22.04" ] && vid=20.04 || vid="$VERSION_ID"
[ "$VERSION_CODENAME" = "jammy" ] && vcn=focal || vcn="$VERSION_CODENAME"
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${vid/./}_${vcn}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url"
sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4 libevent-dev
sudo dpkg -i /tmp/libcouchbase-*/*.deb
}
add_couchbase_cxxlibs() {
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
fi
install_packages cmake ccache
}
get_couchbase_version() {
if [[ "${version:?}" =~ ${old_versions:?} ]]; then
echo couchbase-2.2.3
elif [[ "${version:?}" =~ 5.6|7.[0-1] ]]; then
echo couchbase-2.6.2
elif [ "${version:?}" = '7.2' ]; then
echo couchbase-3.0.4
elif [ "${version:?}" = '7.3' ]; then
echo couchbase-3.2.2
else
echo couchbase
fi
}
# Function to add couchbase.
add_couchbase() {
add_couchbase_libs >/dev/null 2>&1
enable_extension "couchbase" "extension"
if check_extension "couchbase"; then
add_log "${tick:?}" "couchbase" "Enabled"
else
if [[ "${version:?}" =~ ${old_versions:?} ]]; then
pecl_install couchbase-2.2.3 >/dev/null 2>&1
elif [[ "${version:?}" =~ 5.6|7.[0-1] ]]; then
pecl_install couchbase-2.6.2 >/dev/null 2>&1
elif [[ "${version:?}" =~ 7.2 ]]; then
pecl_install couchbase-3.0.4 >/dev/null 2>&1
else
pecl_install couchbase >/dev/null 2>&1
ext=$1
if [ "$(uname -s)" = "Linux" ]; then
if [ "$ext" = "couchbase" ]; then
ext=$(get_couchbase_version)
fi
add_extension_log "couchbase" "Installed and enabled"
if [[ "$ext" =~ couchbase-[2-3].+ ]]; then
add_couchbase_clibs "$ext" >/dev/null 2>&1
else
add_couchbase_cxxlibs >/dev/null 2>&1
fi
enable_extension "couchbase" "extension"
if check_extension "couchbase"; then
add_log "${tick:?}" "couchbase" "Enabled"
else
if [ "$ext" = "couchbase" ]; then
ext="couchbase-$(get_pecl_version "couchbase" "stable")"
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
else
pecl_install "${ext}" >/dev/null 2>&1
fi
add_extension_log "couchbase" "Installed and enabled"
fi
else
if [ -e "${ext_dir:?}"/libcouchbase_php_core.dylib ]; then
sudo cp "${ext_dir:?}"/libcouchbase_php_core.dylib "${brew_prefix:?}"/lib
fi
add_brew_extension couchbase extension
fi
}

View File

@ -0,0 +1,50 @@
# Function to get event configure options
get_event_configure_opts() {
event_opts=(
--with-event-core
--with-event-extra
--with-event-openssl
--enable-event-sockets
)
if [ "$os" = 'Linux' ]; then
event_opts+=(
--with-openssl-dir=yes
--with-event-libevent-dir=/usr
)
else
event_opts+=(
--with-openssl-dir="$(brew --prefix openssl@1.1)"
--with-event-libevent-dir="$(brew --prefix libevent)"
)
fi
}
# Helper function to compile and install event
add_event_helper() {
local ext=$1
[[ "$ext" =~ ^event$ ]] && ext="event-$(get_pecl_version "event" "stable")"
event_opts=() && get_event_configure_opts
export EVENT_LINUX_LIBS='libevent-dev'
export EVENT_DARWIN_LIBS='libevent'
event_configure_opts="--with-php-config=$(command -v php-config) ${event_opts[*]}"
export EVENT_CONFIGURE_OPTS="$event_configure_opts"
add_extension_from_source event https://pecl.php.net event event "${ext##*-}" extension pecl
}
# Function to add event
add_event() {
local ext=$1
enable_extension "event" "extension"
if check_extension "event"; then
add_log "${tick:?}" "event" "Enabled"
else
if ! [[ "${version:?}" =~ ${old_versions:?} ]] && [ "$os" = "Darwin" ]; then
add_brew_extension event extension >/dev/null 2>&1
else
add_event_helper "$ext" >/dev/null 2>&1
fi
add_extension_log "event" "Installed and enabled"
fi
}
os="$(uname -s)"

View File

@ -4,7 +4,7 @@ Function Add-Choco() {
# Source: https://docs.chocolatey.org/en-us/choco/setup
Set-ExecutionPolicy Bypass -Scope Process -Force
[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 { }
}

View File

@ -1,6 +1,7 @@
add_firebird_client_darwin() {
firebird_tag='R3_0_7'
pkg_name=$(get -s -n "" https://github.com/FirebirdSQL/firebird/releases/tag/"$firebird_tag" | grep -Eo "Firebird-.*.pkg" | head -n 1)
pkg_name=$(get -s -n "" https://api.github.com/repos/FirebirdSQL/firebird/releases/tags/"$firebird_tag" | grep -Eo "Firebird-.*.pkg" | head -n 1)
[ -z "$pkg_name" ] && pkg_name=$(get -s -n "" https://github.com/FirebirdSQL/firebird/releases/expanded_assets/"$firebird_tag" | grep -Eo "Firebird-.*.pkg" | head -n 1)
get -q -e "/tmp/firebird.pkg" https://github.com/FirebirdSQL/firebird/releases/download/"$firebird_tag"/"$pkg_name"
sudo installer -pkg /tmp/firebird.pkg -target /
sudo mkdir -p /opt/firebird/include /opt/firebird/lib

View File

@ -17,6 +17,10 @@ add_gearman_helper() {
# Function to add gearman extension.
add_gearman() {
status="Enabled"
add_gearman_helper >/dev/null 2>&1
add_extension_log "gearman" "$status"
if [ "$(uname -s)" = 'Linux' ]; then
add_gearman_helper >/dev/null 2>&1
add_extension_log "gearman" "$status"
else
add_brew_extension gearman extension
fi
}

View File

@ -13,7 +13,7 @@ Function Get-ICUUrl() {
$trunk = "https://windows.php.net"
$urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}")
foreach ($url in $urls) {
$web_content = Invoke-WebRequest -Uri $url
$web_content = Get-File -Url $url
foreach ($link in $web_content.Links) {
if ($link -match "/.*ICU-${icu_version}.*/") {
return $trunk + $link.HREF
@ -32,7 +32,7 @@ Function Repair-ICU() {
$zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs
if ($zip_url -ne '') {
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
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
Repair-ICU
try {
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 )"
}
Add-ExtensionLog http "Installed and enabled"
}

View File

@ -20,7 +20,7 @@ Function Add-Ioncube() {
if (-not($installed.ThreadSafe)) {
$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
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') {
$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
Copy-Item $php_dir\instantclient*\* $php_dir
}
@ -71,7 +71,7 @@ Function Add-Oci() {
Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll
} else {
$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
}
}

View File

@ -1,24 +1,79 @@
# Function to install phalcon
Function Add-PhalconHelper() {
if ($extension_version -eq '4') {
Install-Phpextension -Extension phalcon -MinimumStability stable -Path $php_dir
} else {
$domain = 'https://github.com'
# Function to get the url of the phalcon release asset.
Function Get-PhalconReleaseAssetUrl() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$Semver
)
$domain = 'https://api.github.com/repos'
$releases = 'phalcon/cphalcon/releases'
if($extension_version -match '[3-4]') {
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v3.4.5" | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
$zip_file = $match.Matches[0].Groups[1].Value
Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
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)"
} catch {
$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 {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch {
$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) {
return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)"
}
return false;
}
# Function to add phalcon using GitHub releases.
Function Add-PhalconFromGitHub() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$Semver
)
$zip_url = Get-PhalconReleaseAssetUrl $Semver
if($zip_url) {
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
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir
} else {
throw "Unable to get Phalcon release from the GitHub release"
}
}
# Function to get phalcon semver.
Function Get-PhalconSemver() {
if($extension_version -eq '3') {
return '3.4.5'
} elseif (($extension_version -eq '4') -and ($version -eq '7.2')) {
return '4.1.0'
}
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
}
# Function to install phalcon
Function Add-PhalconHelper() {
$semver = Get-PhalconSemver
if (($extension_version -eq '3') -or ($extension_version -eq '5')) {
Add-PhalconFromGitHub $semver
} elseif ($extension_version -eq '4') {
Add-Extension -Extension phalcon -Stability stable -Extension_version $semver
}
}
# Function to add phalcon
Function Add-Phalcon() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('phalcon3', 'phalcon4')]
[ValidateSet('phalcon3', 'phalcon4', 'phalcon5')]
[string]
$extension
)

View File

@ -1,13 +1,38 @@
# Helper function to get phalcon version
get_phalcon_version() {
if [ "$extension" = "phalcon5" ]; then
get_pecl_version phalcon stable 5
elif [ "$extension" = "phalcon4" ]; then
echo '4.1.2'
elif [ "$extension" = "phalcon3" ]; then
echo '3.4.5'
fi
}
# Function to add phalcon from repo.
add_phalcon_from_repo(){
version=${version:?}
if [ "$extension" = "phalcon5" ]; then
PHALCON_PATH=build/phalcon
else
PHALCON_PATH=build/php"${version%.*}"/64bits
fi
PHALCON_CONFIGURE_OPTS="--enable-phalcon --with-php-config=$(command -v php-config)"
export PHALCON_PATH
export PHALCON_CONFIGURE_OPTS
add_extension_from_source phalcon https://github.com phalcon cphalcon v"$(get_phalcon_version)" extension
}
# Helper function to add phalcon.
add_phalcon_helper() {
status='Installed and enabled'
if [ "$(uname -s)" = "Darwin" ]; then
add_brew_extension "$extension" extension
else
packages=("php${version:?}-$extension")
[ "$extension" = "phalcon4" ] && packages+=("php${version:?}-psr")
package="php${version:?}-$extension"
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
check_package "${packages[0]}" && install_packages "${packages[@]}"
[ "$extension" = "phalcon4" ] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0)
(check_package "$package" && install_packages "$package") || pecl_install phalcon-"$(get_phalcon_version)" || add_phalcon_from_repo
fi
}
@ -44,15 +69,27 @@ add_phalcon4() {
fi
}
# Function to add phalcon3.
add_phalcon5() {
if shared_extension phalcon; then
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then
add_phalcon_helper
else
enable_extension phalcon extension
fi
else
add_phalcon_helper
fi
}
# Function to add phalcon.
add_phalcon() {
extension=$1
local extension=$1
status='Enabled'
extension_major_version=${extension: -1}
if [ "$extension_major_version" = "4" ]; then
add_phalcon4 >/dev/null 2>&1
elif [ "$extension_major_version" = "3" ]; then
add_phalcon3 >/dev/null 2>&1
if [[ "$extension_major_version" =~ [3-5] ]]; then
add_phalcon"$extension_major_version" >/dev/null 2>&1
fi
add_extension_log "phalcon" "$status"
}

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
# Make sure we have all options in name="value" form i.e XML properties.
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"
output_opts=()
for opt in "${opts_array[@]}"; do
@ -146,6 +146,7 @@ add_extension_from_source() {
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
else
[[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries"
[ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug"
patch_extension "$extension" >/dev/null 2>&1
run_group "phpize" "phpize"
run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure"

View File

@ -3,7 +3,7 @@ get_sqlsrv_version() {
if [[ "${version:?}" =~ 7.[0-3] ]]; then
echo '5.9.0'
else
echo '5.10.0'
echo '5.10.1'
fi
}
@ -11,5 +11,10 @@ get_sqlsrv_version() {
add_sqlsrv() {
ext=$1
ext_version=$(get_sqlsrv_version)
add_pecl_extension "$ext" "$ext_version" extension
if [ "$(uname -s)" = 'Linux' ]; then
install_packages unixodbc-dev
add_pecl_extension "$ext" "$ext_version" extension
else
add_brew_extension "$ext" extension
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() {
if ! command -v sudo >/dev/null; then
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
}
@ -15,10 +15,15 @@ self_hosted_helper() {
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
install_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.
@ -29,8 +34,8 @@ disable_extension_helper() {
if [ "$disable_dependents" = "true" ]; then
disable_extension_dependents "$extension"
fi
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 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 rm -f /tmp/php"$version"_extensions
mkdir -p /tmp/extdisabled/"$version"
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
@ -75,9 +80,10 @@ check_package() {
# Helper function to add an extension.
add_extension_helper() {
local extension=$1
package=php"$version"-"$extension"
packages=(php"$version"-"$extension")
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
[ "${debug:?}" = "debug" ] && check_package php"$version"-"$extension"-dbgsym && packages+=(php"$version"-"$extension"-dbgsym)
(check_package "${packages[0]}" && install_packages "${packages[@]}") || pecl_install "$extension"
add_extension_log "$extension" "Installed and enabled"
sudo chmod 777 "${ini_file[@]}"
}
@ -88,14 +94,14 @@ add_devtools() {
if ! command -v "$tool$version" >/dev/null; then
install_packages "php$version-dev"
fi
add_extension xml extension >/dev/null 2>&1
switch_version "phpize" "php-config"
add_extension xml extension >/dev/null 2>&1
add_log "${tick:?}" "$tool" "Added $tool $semver"
}
# Function to setup the nightly build from shivammathur/php-builder
setup_nightly() {
run_script "php-builder" "${runner:?}" "$version"
run_script "php-builder" "${runner:?}" "$version" "${debug:?}" "${ts:?}"
}
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
@ -133,15 +139,22 @@ switch_version() {
wait "${to_wait[@]}"
}
# Function to get packages to install
get_php_packages() {
sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' '
if [ "${debug:?}" = "debug" ]; then
sed "s/[^ ]*/php$version-&-dbgsym/g" "$src"/configs/php_debug_packages | tr '\n' ' '
fi
}
# Function to install packaged PHP
add_packaged_php() {
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')"
IFS=' ' read -r -a packages <<<"$(get_php_packages)"
install_packages "${packages[@]}"
add_pecl
else
run_script "php-ubuntu" "$version"
run_script "php-ubuntu" "$version" "${debug:?}"
fi
}
@ -159,13 +172,14 @@ update_php() {
# Function to install PHP.
add_php() {
if [[ "$version" =~ ${nightly_versions:?} ]]; then
if [[ "$version" =~ ${nightly_versions:?} ]] || [[ "${ts:?}" = "zts" ]]; then
setup_nightly
elif [[ "$version" =~ ${old_versions:?} ]]; then
setup_old_versions
else
add_packaged_php
switch_version >/dev/null 2>&1
add_pecl
fi
status="Installed"
}
@ -258,7 +272,7 @@ setup_php() {
}
# Variables
version=${1:-'8.1'}
version=${1:-'8.2'}
ini=${2:-'production'}
src=${0%/*}/..
debconf_fix="DEBIAN_FRONTEND=noninteractive"

View File

@ -1,7 +1,8 @@
# Variables
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
$composer_json = "$env:APPDATA\Composer\composer.json"
$composer_lock = "$env:APPDATA\Composer\composer.lock"
$composer_home = "$env:APPDATA\Composer"
$composer_bin = "$composer_home\vendor\bin"
$composer_json = "$composer_home\composer.json"
$composer_lock = "$composer_home\composer.lock"
# Function to configure composer.
Function Edit-ComposerConfig() {
@ -16,7 +17,7 @@ Function Edit-ComposerConfig() {
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
if ($? -eq $False) {
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
if (-not(Test-Path $composer_json)) {
@ -24,8 +25,30 @@ Function Edit-ComposerConfig() {
}
Add-EnvPATH $src\configs\composer.env
Add-Path $composer_bin
if (Test-Path env:COMPOSER_TOKEN) {
Add-Env COMPOSER_AUTH ('{"github-oauth": {"github.com": "' + $env:COMPOSER_TOKEN + '"}}')
Set-ComposerAuth
}
# Function to setup authentication in composer.
Function Set-ComposerAuth() {
if(Test-Path env:COMPOSER_AUTH_JSON) {
if(Test-Json -JSON $env:COMPOSER_AUTH_JSON) {
Set-Content -Path $composer_home\auth.json -Value $env:COMPOSER_AUTH_JSON
} else {
Add-Log "$cross" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON"
}
}
$composer_auth = @()
if(Test-Path env:PACKAGIST_TOKEN) {
$composer_auth += '"http-basic": {"repo.packagist.com": { "username": "token", "password": "' + $env:PACKAGIST_TOKEN + '"}}'
}
if(-not(Test-Path env:GITHUB_TOKEN) -and (Test-Path env:COMPOSER_TOKEN)) {
$env:GITHUB_TOKEN = $env:COMPOSER_TOKEN
}
if (Test-Path env:GITHUB_TOKEN) {
$composer_auth += '"github-oauth": {"github.com": "' + $env:GITHUB_TOKEN + '"}'
}
if($composer_auth.length) {
Add-Env COMPOSER_AUTH ('{' + ($composer_auth -join ',') + '}')
}
}
@ -37,7 +60,7 @@ Function Get-ToolVersion() {
[Parameter(Position = 1, Mandatory = $true)]
$param
)
$alp = "[a-zA-Z0-9]"
$alp = "[a-zA-Z0-9\.]"
$version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
if($tool -eq 'composer') {
$composer_branch_alias = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
@ -67,6 +90,13 @@ Function Add-ToolsHelper() {
Edit-ComposerConfig $bin_dir\$tool
} elseif($tool -eq "cs2pr") {
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
} elseif($tool -eq "deployer") {
if(Test-Path $composer_bin\deployer.phar.bat) {
Copy-Item $composer_bin\deployer.phar.bat -Destination $composer_bin\dep.bat
}
if(Test-Path $composer_bin\dep.bat) {
Copy-Item $composer_bin\dep.bat -Destination $composer_bin\deployer.bat
}
} elseif($tool -eq "phan") {
$extensions += @('fileinfo', 'ast')
} elseif($tool -eq "phinx") {
@ -122,7 +152,7 @@ Function Add-Tool() {
} catch {
if($url -match '.*github.com.*releases.*latest.*') {
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
} catch { }
}
@ -153,7 +183,7 @@ Function Add-Tool() {
}
}
Function Add-ComposertoolHelper() {
Function Add-ComposerToolHelper() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[string]
@ -171,10 +201,17 @@ Function Add-ComposertoolHelper() {
[string]
$composer_args
)
$tool_version = $release.split(':')[1]
if($NULL -eq $tool_version) {
$tool_version = '*'
}
if($scope -eq 'global') {
if(Test-Path $composer_lock) {
Remove-Item -Path $composer_lock -Force
}
if((composer global show $prefix$tool $tool_version -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
composer global config --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
}
composer global require $prefix$release $composer_args >$null 2>&1
return composer global show $prefix$tool 2>&1 | findstr '^versions'
} else {
@ -184,6 +221,10 @@ Function Add-ComposertoolHelper() {
$unix_scoped_dir = $scoped_dir.replace('\', '/')
if(-not(Test-Path $scoped_dir)) {
New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1
Set-Content -Path $scoped_dir\composer.json -Value "{}"
if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
}
composer require $prefix$release -d $unix_scoped_dir $composer_args >$null 2>&1
}
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
@ -193,7 +234,7 @@ Function Add-ComposertoolHelper() {
}
# Function to setup a tool using composer.
Function Add-Composertool() {
Function Add-ComposerTool() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
@ -216,6 +257,7 @@ Function Add-Composertool() {
[string]
$scope
)
$composer_args = ""
if($composer_version.split('.')[0] -ne "1") {
$composer_args = "--ignore-platform-req=ext-*"
if($tool -match "prestissimo|composer-prefetcher") {
@ -225,7 +267,7 @@ Function Add-Composertool() {
}
}
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) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
}

View File

@ -9,7 +9,7 @@ export composer_lock="$composer_home/composer.lock"
get_tool_version() {
tool=$1
param=$2
alp="[a-zA-Z0-9]"
alp="[a-zA-Z0-9\.]"
version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
if [ "$tool" = "composer" ]; then
composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
@ -44,8 +44,27 @@ configure_composer() {
fi
add_env_path "${src:?}"/configs/composer.env
add_path "$composer_bin"
if [ -n "$COMPOSER_TOKEN" ]; then
add_env COMPOSER_AUTH '{"github-oauth": {"github.com": "'"$COMPOSER_TOKEN"'"}}'
set_composer_auth
}
# Function to setup authentication in composer.
set_composer_auth() {
if [ -n "$COMPOSER_AUTH_JSON" ]; then
if php -r "json_decode('$COMPOSER_AUTH_JSON'); if(json_last_error() !== JSON_ERROR_NONE) { throw new Exception('invalid json'); }"; then
echo "$COMPOSER_AUTH_JSON" | tee "$composer_home/auth.json" >/dev/null
else
add_log "${cross:?}" "composer" "Could not parse COMPOSER_AUTH_JSON as valid JSON"
fi
fi
composer_auth=()
if [ -n "$PACKAGIST_TOKEN" ]; then
composer_auth+=( '"http-basic": {"repo.packagist.com": { "username": "token", "password": "'"$PACKAGIST_TOKEN"'"}}' )
fi
if [ -n "${GITHUB_TOKEN:-$COMPOSER_TOKEN}" ]; then
composer_auth+=( '"github-oauth": {"github.com": "'"${GITHUB_TOKEN:-$COMPOSER_TOKEN}"'"}' )
fi
if ((${#composer_auth[@]})); then
add_env COMPOSER_AUTH "{$(IFS=$','; echo "${composer_auth[*]}")}"
fi
}
@ -61,6 +80,13 @@ add_tools_helper() {
elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 2>/dev/null ||
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
elif [ "$tool" = "deployer" ]; then
if [ -e "$composer_bin"/deployer.phar ]; then
sudo ln -s "$composer_bin"/deployer.phar "$composer_bin"/dep
fi
if [ -e "$composer_bin"/dep ]; then
sudo ln -s "$composer_bin"/dep "$composer_bin"/deployer
fi
elif [ "$tool" = "phan" ]; then
extensions+=(fileinfo ast)
elif [ "$tool" = "phinx" ]; then
@ -127,21 +153,29 @@ add_tool() {
}
# Function to setup a tool using composer in a different scope.
add_composertool_helper() {
add_composer_tool_helper() {
tool=$1
release=$2
prefix=$3
scope=$4
composer_args=$5
enable_extensions curl mbstring openssl
tool_version=${release##*:}; [ "$tool_version" = "$tool" ] && tool_version="*"
if [ "$scope" = "global" ]; then
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
if composer global show "$prefix$tool" "$tool_version" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
composer global config --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
fi
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
else
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
if ! [ -d "$scoped_dir" ]; then
mkdir -p "$scoped_dir"
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
fi
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
fi
@ -150,11 +184,12 @@ add_composertool_helper() {
}
# Function to setup a tool using composer.
add_composertool() {
add_composer_tool() {
tool=$1
release=$2
prefix=$3
scope=$4
composer_args=
composer_major_version=$(cut -d'.' -f 1 /tmp/composer_version)
if [ "$composer_major_version" != "1" ]; then
composer_args="--ignore-platform-req=ext-*"
@ -164,7 +199,7 @@ add_composertool() {
return
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)
([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version"
) || 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
$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
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)) {

83
src/scripts/tools/brew.sh Normal file
View File

@ -0,0 +1,83 @@
# Function to fetch a brew tap.
fetch_brew_tap() {
tap=$1
tap_user=$(dirname "$tap")
tap_name=$(basename "$tap")
mkdir -p "$tap_dir/$tap_user"
branch="$(git ls-remote --symref "https://github.com/$tap" HEAD | grep -Eo 'refs/heads/.*' | tr '\t' '\n' | head -1 | cut -d '/' -f 3)"
get -s -n "" "https://github.com/$tap/archive/$branch.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
sudo mv "$tap_dir/$tap_user/$tap_name-$branch" "$tap_dir/$tap_user/$tap_name"
}
# Function to add a brew tap.
add_brew_tap() {
tap=$1
if ! [ -d "$tap_dir/$tap" ]; then
if [ "${runner:?}" = "self-hosted" ]; then
brew tap "$tap" >/dev/null 2>&1
else
fetch_brew_tap "$tap" >/dev/null 2>&1
if ! [ -d "$tap_dir/$tap" ]; then
brew tap "$tap" >/dev/null 2>&1
fi
fi
fi
}
# Function to get brew prefix.
get_brew_prefix() {
if [ "$(uname -s)" = "Linux" ]; then
echo /home/linuxbrew/.linuxbrew
else
if [ "$(uname -m)" = "arm64" ]; then
echo /opt/homebrew
else
echo /usr/local
fi
fi
}
# Function to add brew's bin directories to the PATH.
add_brew_bins_to_path() {
local brew_prefix=${1:-$(get_brew_prefix)}
add_path "$brew_prefix"/bin
add_path "$brew_prefix"/sbin
}
# Function to add brew.
add_brew() {
brew_prefix="$(get_brew_prefix)"
if ! [ -d "$brew_prefix"/bin ]; then
step_log "Setup Brew"
get -s "" "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" | bash -s >/dev/null 2>&1
add_log "${tick:?}" "Brew" "Installed Homebrew"
fi
add_brew_bins_to_path "$brew_prefix"
}
# Function to configure brew constants.
configure_brew() {
brew_path="$(command -v brew)"
if [ -z "$brew_path" ]; then
add_brew
brew_path="$(command -v brew)"
fi
brew_path_dir="$(dirname "$brew_path")"
brew_prefix="$brew_path_dir"/..
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
tap_dir="$brew_repo"/Library/Taps
core_repo="$tap_dir"/homebrew/homebrew-core
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
export HOMEBREW_DEVELOPER=1
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export brew_path
export brew_path_dir
export brew_prefix
export brew_repo
export tap_dir
export core_repo
}

View File

@ -7,7 +7,7 @@ Function Add-Msys2() {
return $msys_location
}
Function Add-Grpc_php_plugin() {
Function Add-GrpcPhpPlugin() {
$msys_location = Add-Msys2
$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"

View File

@ -22,6 +22,8 @@ get_grpc_tag() {
}
add_grpc_php_plugin_brew() {
. "${0%/*}"/tools/brew.sh
configure_brew
brew install grpc
brew link --force --overwrite grpc >/dev/null 2>&1
grpc_tag="v$(brew info grpc | grep "grpc:" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"

View File

@ -140,6 +140,20 @@ add_list() {
return 0;
}
# Function to check if a PPA exists
check_ppa() {
ppa=$1
ppa_url=${2:-"$lp_ppa/$ppa/ubuntu"}
package_dist=${3:-"$VERSION_CODENAME"}
branches=${4:-main}
ppa_search="deb .*$ppa_url $package_dist .*$branches"
if check_lists "$ppa" "$ppa_search"; then
return 0;
else
return 1;
fi
}
# Function to remove a PPA.
remove_list() {
ppa=${1-ondrej/php}
@ -153,8 +167,10 @@ add_ppa() {
set_base_version
ppa=${1:-ondrej/php}
if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$lp_ppa/$ppa/ubuntu" "$lp_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
add_list "$ppa"
elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug"
add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg
else
add_list "$ppa"

View File

@ -1,15 +1,17 @@
Function Get-ProtobufTag() {
$releases = 'https://github.com/protocolbuffers/protobuf/releases'
if("$protobuf_tag" -eq "latest") {
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
$protobuf_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} else {
try {
[net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
$req.Method = "HEAD"
$protobuf_tag = $protobuf_tag -replace '^v', ''
[net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/v$protobuf_tag")
$request.Method = "HEAD"
[net.httpWebResponse] $response = $request.getResponse()
$response.Close()
$protobuf_tag = "v$protobuf_tag"
} catch {
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
$protobuf_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
}
}
return $protobuf_tag
@ -18,7 +20,7 @@ Function Get-ProtobufTag() {
Function Add-Protoc() {
param(
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
[ValidatePattern('^latest$|^(v?)\d+\.\d+\.\d+$')]
[ValidatePattern('^latest$|^(v?)\d+\.\d+(\.\d+)?$')]
[string] $protobuf_tag
)
$protobuf_tag = Get-ProtobufTag
@ -27,7 +29,7 @@ Function Add-Protoc() {
$arch_num = '32'
}
$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
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"

View File

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

View File

@ -4,7 +4,7 @@ Function Add-Symfony() {
$arch_name = '386'
}
$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
if(Test-Path $bin_dir\symfony.exe) {
Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1

View File

@ -1,12 +1,35 @@
add_symfony() {
add_symfony_with_brew() {
add_brew_tap symfony-cli/homebrew-tap
brew install symfony-cli/tap/symfony-cli
}
get_symfony_artifact_url() {
arch=$(dpkg --print-architecture)
url=$(get -s -n "" https://raw.githubusercontent.com/symfony-cli/homebrew-tap/main/Formula/symfony-cli.rb 2<&1 | grep -m 1 "url.*linux.*${arch}" | cut -d\" -f 2)
if [ -z "$url" ]; then
url=$(get -s -n "" https://api.github.com/repos/symfony-cli/symfony-cli/releases 2<&1 | grep -m 1 "url.*linux.*${arch}.*gz\"" | cut -d\" -f 4)
fi
echo "$url"
}
add_symfony_helper() {
if [ "$(uname -s)" = "Linux" ]; then
echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | sudo tee /etc/apt/sources.list.d/symfony-cli.list >/dev/null 2>&1
update_lists symfony repo.symfony.com
install_packages symfony-cli
url="$(get_symfony_artifact_url)"
if [ -z "$url" ]; then
. "${0%/*}"/tools/brew.sh
configure_brew
add_symfony_with_brew
else
get -s -n "" "$url" | sudo tar -xz -C "${tool_path_dir:?}" 2>/dev/null
sudo chmod a+x /usr/local/bin/symfony
fi
elif [ "$(uname -s)" = "Darwin" ]; then
add_brew_tap symfony-cli/homebrew-tap
brew install symfony-cli/tap/symfony-cli >/dev/null 2>&1
add_symfony_with_brew
fi
}
add_symfony() {
add_symfony_helper >/dev/null 2>&1
symfony_path="$(command -v symfony)"
if [[ -n "$symfony_path" ]]; then
sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli

View File

@ -4,7 +4,7 @@ export cross="✗"
export curl_opts=(-sL)
export old_versions="5.[3-5]"
export jit_versions="8.[0-9]"
export nightly_versions="8.[2-9]"
export nightly_versions="8.[3-9]"
export xdebug3_versions="7.[2-4]|8.[0-9]"
export latest="releases/latest/download"
export github="https://github.com/shivammathur"
@ -43,13 +43,15 @@ set_output() {
name=$1
value=$2
if [ "${GITHUB_ACTIONS}" = "true" ]; then
echo "::set-output name=${name}::${value}"
echo "${name}=${value}" | tee -a "$GITHUB_OUTPUT" >/dev/null 2>&1
fi
}
# Function to read env inputs.
read_env() {
update="${update:-${UPDATE:-false}}"
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
[ "${phpts:-${PHPTS:-nts}}" = "ts" ] && ts=zts && update=true || ts=nts
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
[[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github
runner="${runner:-${RUNNER:-$_runner}}"
@ -58,6 +60,16 @@ read_env() {
fail_fast=true
add_log "$cross" "Runner" "Runner set as github in self-hosted environment"
fi
# Set Update to true if the ubuntu github image does not have PHP PPA.
if [[ "$runner" = "github" && "${ImageOS}" =~ ubuntu.* ]]; then
check_ppa ondrej/php || update=true
fi
export fail_fast
export runner
export update
export ts
}
# Function to download a file using cURL.
@ -151,6 +163,7 @@ self_hosted_setup() {
exit 1
else
self_hosted_helper >/dev/null 2>&1
add_env RUNNER_TOOL_CACHE /tmp
fi
fi
}
@ -159,10 +172,11 @@ self_hosted_setup() {
configure_php() {
add_php_config
ini_config_dir="${src:?}"/configs/ini
ini_files=("$ini_config_dir"/php.ini)
[[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
[[ "$version" =~ $xdebug3_versions ]] && ini_files+=("$ini_config_dir"/xdebug.ini)
cat "${ini_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
ini_config_files=("$ini_config_dir"/php.ini)
jit_config_files=("$ini_config_dir"/jit.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
[[ "$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.

View File

@ -3,7 +3,7 @@ param (
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$version = '8.1',
$version = '8.2',
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
@ -23,7 +23,7 @@ Function Add-Log($mark, $subject, $message) {
} else {
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $mark $subject $message
if($env:fail_fast -eq 'true') {
exit 1;
Write-Error $message -ErrorAction Stop
}
}
}
@ -43,7 +43,7 @@ Function Set-Output() {
$value
)
if ($env:GITHUB_ACTIONS -eq 'true') {
Write-Output "::set-output name=$output::$value"
Add-Content "$output=$value" -Path $env:GITHUB_OUTPUT -Encoding utf8
}
}
@ -88,6 +88,7 @@ Function Add-Path {
}
if ($env:GITHUB_PATH) {
Add-Content $PathItem -Path $env:GITHUB_PATH -Encoding utf8
$env:PATH += "$PathItem;"
} else {
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
$newPath = $PathItem + ';' + $newPath
@ -127,13 +128,51 @@ Function Add-EnvPATH {
$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 Add-Printf {
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe -Force > $null 2>&1
} 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
}
} else {
@ -165,7 +204,7 @@ Function Install-PSPackage() {
$module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) {
$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
}
Import-Module $module_path
@ -217,20 +256,55 @@ Function Add-PhpConfig {
# Function to get PHP from GitHub releases cache
Function Set-PhpCache {
try {
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
$asset = $release.assets | ForEach-Object {
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name
try {
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
$asset = $release.assets | ForEach-Object {
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.name
}
} | Select-Object -Last 1
if($null -eq $asset) {
throw "Asset not found"
}
} catch {
$release = Get-File -Url $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object {
if($_ -match "php-$version.[0-9]+$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
Set-PhpDownloadCache -Path $php_dir CurrentUser
} catch { }
}
# Function to add debug symbols to PHP.
Function Add-DebugSymbols {
$dev = if ($version -match $nightly_versions) { '-dev' } else { '' }
try {
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
$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
}
Get-File -Url $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Expand-Archive -Path $php_dir\$asset -DestinationPath $php_dir -Force
Get-ChildItem -Path $php_dir -Filter php_*.pdb | Move-Item -Destination $ext_dir
}
# Function to install nightly version of PHP
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
if(Test-Path $php_dir\COMMIT) {
return " ($( Get-Content $php_dir\COMMIT ))"
@ -276,7 +350,7 @@ if ( $env:GITHUB_ACTIONS -eq 'true') {
if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
if($env:RUNNER -eq 'github') {
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'
$php_dir = "$php_dir$version"
@ -287,7 +361,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
if($version -lt 5.6) {
Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner"
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)) {
Install-Module -Name VcRedist -Force
@ -295,6 +369,7 @@ if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
New-Item $php_dir -Type Directory -Force > $null 2>&1
Add-Path -PathItem $php_dir
setx PHPROOT $php_dir >$null 2>&1
Add-Env -EnvName RUNNER_TOOL_CACHE -EnvValue $env:TEMP
} else {
$current_profile = "$PSHOME\Profile.ps1"
if(-not(Test-Path -LiteralPath $current_profile)) {
@ -349,13 +424,17 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
Add-PhpConfig
}
if($env:DEBUG -eq 'true') {
Add-DebugSymbols
}
$installed = Get-Php -Path $php_dir
if($installed.MajorMinorVersion -ne $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") {
('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 {
$enable_extensions += ('opcache')
}

View File

@ -21,8 +21,12 @@ interface IRef {
export async function getSemverVersion(data: RS): Promise<string> {
const search: string = data['version_prefix'] + data['version'];
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
const token: string = await utils.readEnv('COMPOSER_TOKEN');
const response: RS = await fetch.fetch(url, token);
let github_token: string = await utils.readEnv('GITHUB_TOKEN');
const composer_token: string = await utils.readEnv('COMPOSER_TOKEN');
if (composer_token && !github_token) {
github_token = composer_token;
}
const response: RS = await fetch.fetch(url, github_token);
if (response.error || response.data === '[]') {
data['error'] = response.error ?? `No version found with prefix ${search}.`;
return data['version'];
@ -197,7 +201,7 @@ export async function addArchive(data: RS): Promise<string> {
* @param data
*/
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 args: string = await utils.joins(
parts[1],
@ -214,11 +218,12 @@ export async function addPackage(data: RS): Promise<string> {
* @param data
*/
export async function addBlackfirePlayer(data: RS): Promise<string> {
if (
/5\.[5-6]|7\.0/.test(data['php_version']) &&
data['version'] == 'latest'
) {
data['version'] = '1.9.3';
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);
@ -230,24 +235,34 @@ export async function addBlackfirePlayer(data: RS): Promise<string> {
* @param data
*/
export async function addComposer(data: RS): Promise<string> {
const channel = data['version'].replace('latest', 'stable');
const github = data['github'];
const getcomposer = data['domain'];
let cache_url = `${github}/shivammathur/composer-cache/releases/latest/download/composer-${
data['php_version']
}-${data['version'].replace('latest', 'stable')}.phar`;
const cds = 'https://dl.cloudsmith.io';
const filename = `composer-${data['php_version']}-${channel}.phar`;
const releases_url = `${github}/shivammathur/composer-cache/releases/latest/download/${filename}`;
const cds_url = `${cds}/public/shivammathur/composer-cache/raw/files/${filename}`;
const lts_url = `${getcomposer}/download/latest-2.2.x/composer.phar`;
const is_lts = /^5\.[3-6]$|^7\.[0-1]$/.test(data['php_version']);
const version_source_url = `${getcomposer}/composer-${channel}.phar`;
let cache_url = `${releases_url},${cds_url}`;
let source_url = `${getcomposer}/composer.phar`;
switch (true) {
case /^snapshot$/.test(data['version']):
case /^snapshot$/.test(channel):
source_url = is_lts ? lts_url : source_url;
break;
case /^preview$|^[1-2]$/.test(data['version']):
source_url = `${getcomposer}/composer-${data['version']}.phar`;
case /^preview$|^2$/.test(channel):
source_url = is_lts ? lts_url : version_source_url;
break;
case /^1$/.test(channel):
source_url = version_source_url;
break;
case /^\d+\.\d+\.\d+[\w-]*$/.test(data['version']):
cache_url = `${github}/${data['repository']}/releases/download/${data['version']}/composer.phar`;
source_url = `${getcomposer}/composer-${data['version']}.phar`;
source_url = version_source_url;
break;
default:
source_url = `${getcomposer}/composer-stable.phar`;
source_url = is_lts ? lts_url : version_source_url;
}
const use_cache: boolean = (await utils.readEnv('NO_TOOLS_CACHE')) !== 'true';
data['url'] = use_cache ? `${cache_url},${source_url}` : source_url;
@ -264,8 +279,25 @@ export async function addDeployer(data: RS): Promise<string> {
if (data['version'] === 'latest') {
data['url'] = data['domain'] + '/deployer.phar';
} else {
data['url'] =
data['domain'] + '/releases/v' + data['version'] + '/deployer.phar';
const manifest: RS = await fetch.fetch(
'https://deployer.org/manifest.json'
);
const version_data: RSRS = JSON.parse(manifest.data);
const version_key: string | undefined = Object.keys(version_data).find(
(key: string) => {
return version_data[key]['version'] === data['version'];
}
);
if (version_key) {
data['url'] = version_data[version_key]['url'];
} else {
return await utils.addLog(
'$cross',
'deployer',
'Version missing in deployer manifest',
data['os']
);
}
}
return await addArchive(data);
}

View File

@ -1,3 +1,4 @@
import fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
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> {
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
*/
export async function parseVersion(version: string): Promise<string> {
const manifest = await getManifestURL();
switch (true) {
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:
switch (true) {
case version.length > 1:
@ -246,7 +248,8 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
return value
.trim()
.replace(/^["']|["']$|(?<==)["']/g, '')
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'");
.replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'")
.replace(/=(.*?)(=.*)/, "='$1$2'");
})
.filter(Boolean);
}
@ -319,7 +322,14 @@ export async function getCommand(os: string, suffix: string): Promise<string> {
case 'darwin':
return 'add_' + suffix + ' ';
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:
return await log('Platform ' + os + ' is not supported', os, 'error');
}
@ -413,3 +423,44 @@ export async function parseExtensionSource(
prefix
);
}
/**
* 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.`);
}
return 'latest';
}
/**
* Log to console
*
* @param variable
* @param command
* @param os
*/
export async function setVariable(
variable: string,
command: string,
os: string
): Promise<string> {
switch (os) {
case 'win32':
return '\n$' + variable + ' = ' + command + '\n';
case 'linux':
case 'darwin':
default:
return '\n' + variable + '="$(' + command + ')"\n';
}
}

View File

@ -3,7 +3,7 @@
"declaration": true,
"esModuleInterop": true,
"lib": [
"ES2020"
"ES2021"
],
"module": "commonjs",
"moduleResolution": "node",
@ -13,7 +13,7 @@
"rootDir": "./src",
"sourceMap": true,
"strict": true,
"target": "ES2019"
"target": "ES2021"
},
"exclude": ["__tests__", "lib", "node_modules"]
}