mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add custom support for zephir parser
This commit is contained in:
parent
dd0115673c
commit
7abee8e28c
@ -208,7 +208,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
- These extensions have custom support:
|
- These extensions have custom support:
|
||||||
- `cubrid` and `pdo_cubrid` on `Ubuntu`.
|
- `cubrid` and `pdo_cubrid` on `Ubuntu`.
|
||||||
- `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`.
|
- `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`.
|
||||||
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4` and `phalcon5` on all supported OS.
|
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4`, `phalcon5`, and `zephir_parser` on all supported OS.
|
||||||
|
|
||||||
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ describe('Extension tests', () => {
|
|||||||
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
|
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
|
||||||
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
|
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
|
||||||
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
|
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
|
||||||
|
${'zephir_parser'} | ${'7.2'} | ${'Add-ZephirParser zephir_parser'}
|
||||||
`(
|
`(
|
||||||
'checking addExtensionOnWindows for extension $extension on version $version',
|
'checking addExtensionOnWindows for extension $extension on version $version',
|
||||||
async ({extension, version, output}) => {
|
async ({extension, version, output}) => {
|
||||||
@ -66,6 +67,7 @@ describe('Extension tests', () => {
|
|||||||
${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'}
|
${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'}
|
||||||
${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'}
|
${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'}
|
||||||
${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
|
${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
|
||||||
|
${'zephir_parser-1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-1.2.3'}
|
||||||
`(
|
`(
|
||||||
'checking addExtensionOnLinux for extension $extension on version $version',
|
'checking addExtensionOnLinux for extension $extension on version $version',
|
||||||
async ({extension, version, output}) => {
|
async ({extension, version, output}) => {
|
||||||
@ -96,6 +98,7 @@ describe('Extension tests', () => {
|
|||||||
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
||||||
${'relay-1.2.3'} | ${'7.4'} | ${'add_relay relay-1.2.3'}
|
${'relay-1.2.3'} | ${'7.4'} | ${'add_relay relay-1.2.3'}
|
||||||
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
|
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
|
||||||
|
${'zephir_parser-v1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-v1.2.3'}
|
||||||
`(
|
`(
|
||||||
'checking addExtensionOnDarwin for extension $extension on version $version',
|
'checking addExtensionOnDarwin for extension $extension on version $version',
|
||||||
async ({extension, version, output}) => {
|
async ({extension, version, output}) => {
|
||||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -254,6 +254,7 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension):
|
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(version_extension):
|
||||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
@ -303,6 +304,7 @@ async function addExtensionWindows(extension_csv, version) {
|
|||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
||||||
@ -371,6 +373,7 @@ async function addExtensionLinux(extension_csv, version) {
|
|||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(version_extension):
|
||||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
|
@ -37,6 +37,7 @@ export async function addExtensionDarwin(
|
|||||||
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
|
// match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
|
||||||
// match 5.3ioncube...7.4ioncube
|
// match 5.3ioncube...7.4ioncube
|
||||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
|
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
|
||||||
|
// match 7.0zephir_parser...8.2zephir_parser
|
||||||
case /^(7\.4|8\.[0-2])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
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(
|
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
@ -49,6 +50,9 @@ export async function addExtensionDarwin(
|
|||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
||||||
|
version_extension
|
||||||
|
):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'extensions',
|
'extensions',
|
||||||
@ -136,6 +140,7 @@ export async function addExtensionWindows(
|
|||||||
// match 5.3ioncube...7.4ioncube
|
// match 5.3ioncube...7.4ioncube
|
||||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
|
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
|
||||||
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
|
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
|
||||||
|
// match 7.0zephir_parser...8.2zephir_parser
|
||||||
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
@ -145,6 +150,9 @@ export async function addExtensionWindows(
|
|||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
||||||
|
version_extension
|
||||||
|
):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'extensions',
|
'extensions',
|
||||||
@ -261,6 +269,7 @@ export async function addExtensionLinux(
|
|||||||
// match couchbase, geos, pdo_oci, oci8, http, pecl_http
|
// match couchbase, geos, pdo_oci, oci8, http, pecl_http
|
||||||
// match 5.3ioncube...7.4ioncube
|
// match 5.3ioncube...7.4ioncube
|
||||||
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
|
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
|
||||||
|
// match 7.0zephir_parser...8.2zephir_parser
|
||||||
case /^(7\.4|8\.[0-2])relay(-v?\d+\.\d+\.\d+)?$/.test(version_extension):
|
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(
|
case /^(5\.[3-6]|7\.[0-4]|8\.[0-2])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
@ -277,6 +286,9 @@ export async function addExtensionLinux(
|
|||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
case /^(7\.[0-4]|8\.[0-2])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
|
||||||
|
version_extension
|
||||||
|
):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'extensions',
|
'extensions',
|
||||||
|
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"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user