mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-01 12:43:17 +07:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
d30ad8b184 | |||
0f765070fa | |||
313d0cfdbf | |||
cf767706fe | |||
1267cf80a1 | |||
7abee8e28c | |||
dd0115673c | |||
bbc65d999a | |||
6db1a06425 | |||
52eb86c60c | |||
2b77dd6b79 | |||
224f9ddef5 | |||
7f5c8b51ba | |||
bd5c747191 | |||
40846b27d0 |
@ -207,8 +207,8 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
||||
|
||||
- These extensions have custom support:
|
||||
- `cubrid` and `pdo_cubrid` on `Ubuntu`.
|
||||
- `gearman`, `geos` and `event` on `Ubuntu` and `macOS`.
|
||||
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4` and `phalcon5` on all supported OS.
|
||||
- `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`.
|
||||
|
||||
@ -736,7 +736,7 @@ If your project uses composer, you can persist the composer's internal cache dir
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- 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') }}
|
||||
|
@ -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}) => {
|
||||
@ -59,11 +60,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,7 +96,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'}
|
||||
${'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}) => {
|
||||
|
@ -222,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',
|
||||
@ -265,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'}
|
||||
`(
|
||||
@ -376,30 +377,30 @@ describe('Tools tests', () => {
|
||||
[
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||
'add_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"'
|
||||
]
|
||||
]
|
||||
@ -415,21 +416,21 @@ describe('Tools tests', () => {
|
||||
'behat, blackfire, blackfire-player, churn, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, flex, grpc_php_plugin:1.2.3, infection, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, rector, symfony-cli, vapor-cli, wp-cli',
|
||||
[
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||
'add_composertool behat behat behat/ scoped',
|
||||
'add_composer_tool behat behat behat/ scoped',
|
||||
'add_blackfire',
|
||||
'add_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_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"',
|
||||
@ -439,13 +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_composertool rector rector rector/ scoped',
|
||||
'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"'
|
||||
]
|
||||
]
|
||||
@ -467,13 +468,13 @@ describe('Tools tests', () => {
|
||||
'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"'
|
||||
]
|
||||
@ -490,13 +491,13 @@ describe('Tools tests', () => {
|
||||
'composer:v1, codeception/codeception, prestissimo, hirak/prestissimo, composer-prefetcher, narrowspark/automatic-composer-prefetcher, phinx: 1.2, robmorgan/phinx: ^1.2, user/tool:1.2.3, user/tool:~1.2',
|
||||
[
|
||||
'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'
|
||||
'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'
|
||||
]
|
||||
]
|
||||
])(
|
||||
|
@ -193,6 +193,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'
|
||||
);
|
||||
|
42
dist/index.js
vendored
42
dist/index.js
vendored
@ -127,19 +127,21 @@ async function checkXdebugError(extension, version) {
|
||||
exports.checkXdebugError = checkXdebugError;
|
||||
async function addCoverageXdebug(extension, version, os, pipe) {
|
||||
let script = '\n';
|
||||
let message = await checkXdebugError(extension, version);
|
||||
let status = '$cross';
|
||||
if (!message) {
|
||||
const error = 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;
|
||||
script += await utils.setVariable('xdebug_version', 'php -r "echo phpversion(\'xdebug\');"', os);
|
||||
message = 'Xdebug $xdebug_version enabled as coverage driver';
|
||||
status = '$tick';
|
||||
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;
|
||||
}
|
||||
exports.addCoverageXdebug = addCoverageXdebug;
|
||||
@ -154,7 +156,9 @@ async function addCoveragePCOV(version, os, pipe) {
|
||||
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||
script += await utils.setVariable('pcov_version', 'php -r "echo phpversion(\'pcov\');"', os);
|
||||
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV $pcov_version enabled as coverage driver', os);
|
||||
script +=
|
||||
(await utils.getCommand(os, 'extension_log')) +
|
||||
'pcov "PCOV $pcov_version enabled as coverage driver"';
|
||||
break;
|
||||
case /5\.[3-6]|7\.0/.test(version):
|
||||
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os);
|
||||
@ -244,11 +248,13 @@ async function addExtensionDarwin(extension_csv, version) {
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
case /^(7\.4|8\.[0-2])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|^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|(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', extension, 'darwin');
|
||||
return;
|
||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||
@ -298,6 +304,7 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||
case /^(7\.[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', extension, 'win32');
|
||||
return;
|
||||
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
||||
@ -358,6 +365,7 @@ async function addExtensionLinux(extension_csv, version) {
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
case /^(7\.4|8\.[0-2])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|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
|
||||
@ -365,6 +373,7 @@ async function addExtensionLinux(extension_csv, version) {
|
||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
|
||||
return;
|
||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||
@ -750,16 +759,20 @@ async function addArchive(data) {
|
||||
}
|
||||
exports.addArchive = addArchive;
|
||||
async function addPackage(data) {
|
||||
const command = await utils.getCommand(data['os'], 'composertool');
|
||||
const command = await utils.getCommand(data['os'], 'composer_tool');
|
||||
const parts = data['repository'].split('/');
|
||||
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
|
||||
return command + args;
|
||||
}
|
||||
exports.addPackage = addPackage;
|
||||
async function addBlackfirePlayer(data) {
|
||||
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);
|
||||
@ -1212,7 +1225,12 @@ async function getCommand(os, suffix) {
|
||||
case 'darwin':
|
||||
return 'add_' + suffix + ' ';
|
||||
case 'win32':
|
||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||
return ('Add-' +
|
||||
suffix
|
||||
.split('_')
|
||||
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
||||
.join('') +
|
||||
' ');
|
||||
default:
|
||||
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||
}
|
||||
|
2779
package-lock.json
generated
2779
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "2.23.0",
|
||||
"version": "2.24.0",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"main": "lib/install.js",
|
||||
@ -39,22 +39,22 @@
|
||||
"@actions/io": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.2.4",
|
||||
"@types/node": "^18.11.17",
|
||||
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
||||
"@typescript-eslint/parser": "^5.47.0",
|
||||
"@vercel/ncc": "^0.36.0",
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jest": "^27.1.7",
|
||||
"@types/jest": "^29.4.0",
|
||||
"@types/node": "^18.11.18",
|
||||
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
||||
"@typescript-eslint/parser": "^5.49.0",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.32.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^29.3.1",
|
||||
"jest-circus": "^29.3.1",
|
||||
"nock": "^13.2.9",
|
||||
"prettier": "^2.8.1",
|
||||
"jest": "^29.4.1",
|
||||
"jest-circus": "^29.4.1",
|
||||
"nock": "^13.3.0",
|
||||
"prettier": "^2.8.3",
|
||||
"simple-git-hooks": "^2.8.1",
|
||||
"ts-jest": "^29.0.3",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"bugs": {
|
||||
|
@ -16,7 +16,7 @@ export async function checkXdebugError(
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
* Function to set up Xdebug
|
||||
*
|
||||
* @param extension
|
||||
* @param version
|
||||
@ -30,9 +30,8 @@ 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;
|
||||
@ -43,15 +42,17 @@ export async function addCoverageXdebug(
|
||||
'php -r "echo phpversion(\'xdebug\');"',
|
||||
os
|
||||
);
|
||||
message = 'Xdebug $xdebug_version enabled as coverage driver';
|
||||
status = '$tick';
|
||||
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
|
||||
@ -76,14 +77,9 @@ export async function addCoveragePCOV(
|
||||
'php -r "echo phpversion(\'pcov\');"',
|
||||
os
|
||||
);
|
||||
// success
|
||||
script += await utils.addLog(
|
||||
'$tick',
|
||||
'coverage: pcov',
|
||||
'PCOV $pcov_version enabled as coverage driver',
|
||||
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):
|
||||
|
@ -31,11 +31,14 @@ export async function addExtensionDarwin(
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
// match 7.4relay...8.2relay
|
||||
// match 5.3blackfire...8.2blackfire
|
||||
// match 5.3blackfire-(semver)...8.1blackfire-(semver)
|
||||
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
|
||||
// match 5.3ioncube...7.4ioncube
|
||||
// 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-2])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
|
||||
):
|
||||
@ -47,6 +50,9 @@ export async function addExtensionDarwin(
|
||||
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',
|
||||
@ -134,6 +140,7 @@ export async function addExtensionWindows(
|
||||
// match 5.3ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
|
||||
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
|
||||
// match 7.0zephir_parser...8.2zephir_parser
|
||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
@ -143,6 +150,9 @@ export async function addExtensionWindows(
|
||||
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',
|
||||
@ -252,12 +262,15 @@ export async function addExtensionLinux(
|
||||
case /.+-.+\/.+@.+/.test(extension):
|
||||
add_script += await utils.parseExtensionSource(extension, ext_prefix);
|
||||
return;
|
||||
// match 7.4relay...8.2relay
|
||||
// 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, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
|
||||
// match 7.0zephir_parser...8.2zephir_parser
|
||||
case /^(7\.4|8\.[0-2])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
|
||||
):
|
||||
@ -273,6 +286,9 @@ export async function addExtensionLinux(
|
||||
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',
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 { }
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
143
src/scripts/extensions/relay.sh
Normal file
143
src/scripts/extensions/relay.sh
Normal file
@ -0,0 +1,143 @@
|
||||
# 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_releases"/download/"$relay_version"/"$artifact_file_name"
|
||||
fallback_url="$relay_trunk"/"$artifact_file_name"
|
||||
get -q -n /tmp/relay.tar.gz "$url" "$fallback_url"
|
||||
if [ "$openssl_suffix" = '.libssl3' ] && (! [ -e /tmp/relay.tar.gz ] || ! file /tmp/relay.tar.gz | grep -q 'gzip'); then
|
||||
get -q -n /tmp/relay.tar.gz "${url/.libssl3/}" "${fallback_url/.libssl3/}"
|
||||
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"
|
||||
}
|
@ -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
|
||||
|
79
src/scripts/extensions/zephir_parser.ps1
Normal file
79
src/scripts/extensions/zephir_parser.ps1
Normal file
@ -0,0 +1,79 @@
|
||||
# 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"
|
||||
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}.*windows.*.zip)"
|
||||
} catch {
|
||||
$match = (Invoke-WebRequest -Uri "$zp_releases/expanded_assets/$extension_version").Links.href | Select-String -Pattern "(zephir_parser-php-${version}.*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 (Invoke-WebRequest -UseBasicParsing -Uri $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) {
|
||||
Invoke-WebRequest -Uri $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)"
|
||||
}
|
||||
}
|
37
src/scripts/extensions/zephir_parser.sh
Normal file
37
src/scripts/extensions/zephir_parser.sh
Normal file
@ -0,0 +1,37 @@
|
||||
# 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
|
||||
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:?}.*$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:?}.*$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"
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ Function Add-Tool() {
|
||||
}
|
||||
}
|
||||
|
||||
Function Add-ComposertoolHelper() {
|
||||
Function Add-ComposerToolHelper() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[string]
|
||||
@ -234,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()]
|
||||
@ -267,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
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ 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
|
||||
@ -184,7 +184,7 @@ add_composertool_helper() {
|
||||
}
|
||||
|
||||
# Function to setup a tool using composer.
|
||||
add_composertool() {
|
||||
add_composer_tool() {
|
||||
tool=$1
|
||||
release=$2
|
||||
prefix=$3
|
||||
@ -199,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"
|
||||
|
@ -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"
|
||||
|
13
src/tools.ts
13
src/tools.ts
@ -201,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],
|
||||
@ -218,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);
|
||||
|
@ -320,7 +320,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');
|
||||
}
|
||||
|
Reference in New Issue
Block a user