From 4704ad638a0825b6c7c369678683ef6282b62c4a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 14 Nov 2022 15:17:12 +0530 Subject: [PATCH] Improve extension support on macOS --- README.md | 4 ++-- __tests__/extensions.test.ts | 6 +++--- dist/index.js | 7 ++++--- src/configs/brew_extensions | 6 ++++++ src/extensions.ts | 12 +++++------- src/scripts/extensions/gearman.sh | 8 ++++++-- src/scripts/extensions/sqlsrv.sh | 16 ++++++---------- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 26a78dec..a03a052a 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,8 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string` - 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` and `event` on `Ubuntu` and `macOS`. + - `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. - 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`. diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 735eb07c..f2c3beb3 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -93,7 +93,6 @@ describe('Extension tests', () => { ${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'} ${'pecl_http'} | ${'7.3'} | ${'add_http'} ${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'} - ${'sqlsrv'} | ${'7.3'} | ${'add_sqlsrv sqlsrv'} `( 'checking addExtensionOnDarwin for extension $extension on version $version', async ({extension, version, output}) => { @@ -112,10 +111,11 @@ 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, formula === 'phalcon3' ? '7.3' : '7.4', output]; }); diff --git a/dist/index.js b/dist/index.js index 1efa3a2e..0a8b50d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -245,7 +245,7 @@ async function addExtensionDarwin(extension_csv, version) { add_script += await utils.parseExtensionSource(extension, ext_prefix); return; case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): - case /^couchbase|^event|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension): + case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension): case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension): case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension): case /(?/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 } diff --git a/src/scripts/extensions/sqlsrv.sh b/src/scripts/extensions/sqlsrv.sh index 8230623e..ed811c06 100644 --- a/src/scripts/extensions/sqlsrv.sh +++ b/src/scripts/extensions/sqlsrv.sh @@ -7,18 +7,14 @@ get_sqlsrv_version() { fi } -add_unixodbc() { - if [ "$(uname -s)" = 'Linux' ]; then - install_packages unixodbc-dev - else - brew install unixodbc - fi -} - # Function to install sqlsrv and pdo_sqlsrv. add_sqlsrv() { ext=$1 ext_version=$(get_sqlsrv_version) - add_unixodbc >/dev/null 2>&1 - 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 }