mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-12-06 09:50:56 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ca1ee6aee | ||
|
|
7ad1a97ee1 | ||
|
|
91a169a846 | ||
|
|
9ebeb73afd |
@@ -7,7 +7,6 @@ describe('Extension tests', () => {
|
|||||||
${'none'} | ${'7.4'} | ${'Disable-AllShared'}
|
${'none'} | ${'7.4'} | ${'Disable-AllShared'}
|
||||||
${':intl'} | ${'7.4'} | ${'Disable-Extension intl'}
|
${':intl'} | ${'7.4'} | ${'Disable-Extension intl'}
|
||||||
${'ast-beta'} | ${'7.4'} | ${'Add-Extension ast beta'}
|
${'ast-beta'} | ${'7.4'} | ${'Add-Extension ast beta'}
|
||||||
${'ast-stable'} | ${'7.4'} | ${'Add-Extension ast stable'}
|
|
||||||
${'blackfire'} | ${'7.3'} | ${'Add-Blackfire blackfire'}
|
${'blackfire'} | ${'7.3'} | ${'Add-Blackfire blackfire'}
|
||||||
${'blackfire-1.31.0'} | ${'7.3'} | ${'Add-Blackfire blackfire-1.31.0'}
|
${'blackfire-1.31.0'} | ${'7.3'} | ${'Add-Blackfire blackfire-1.31.0'}
|
||||||
${'grpc-1.2.3'} | ${'7.4'} | ${'Add-Extension grpc stable 1.2.3'}
|
${'grpc-1.2.3'} | ${'7.4'} | ${'Add-Extension grpc stable 1.2.3'}
|
||||||
@@ -42,6 +41,14 @@ describe('Extension tests', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('omits the stable argument from the generated Windows command', async () => {
|
||||||
|
const script = await extensions.addExtensionWindows(
|
||||||
|
'mbstring-stable',
|
||||||
|
'8.4'
|
||||||
|
);
|
||||||
|
expect(script.trim()).toBe('Add-Extension mbstring');
|
||||||
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
extension | version | output
|
extension | version | output
|
||||||
${'none'} | ${'7.4'} | ${'disable_all_shared'}
|
${'none'} | ${'7.4'} | ${'disable_all_shared'}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -180,7 +180,7 @@ export async function addExtensionWindows(
|
|||||||
add_script += await utils.joins(
|
add_script += await utils.joins(
|
||||||
'\nAdd-Extension',
|
'\nAdd-Extension',
|
||||||
ext_name,
|
ext_name,
|
||||||
ext_version
|
ext_version.replace('stable', '')
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
// match extensions for compiling from source
|
// match extensions for compiling from source
|
||||||
|
|||||||
@@ -167,8 +167,9 @@ get_pecl_version() {
|
|||||||
local extension=$1
|
local extension=$1
|
||||||
local requested=${2:-stable}
|
local requested=${2:-stable}
|
||||||
local states=("stable" "rc" "preview" "beta" "alpha" "devel" "snapshot")
|
local states=("stable" "rc" "preview" "beta" "alpha" "devel" "snapshot")
|
||||||
|
local curl_opts=("${curl_opts[@]}" --fail)
|
||||||
local stability major_version response pecl_version pattern
|
local stability major_version response pecl_version pattern
|
||||||
response=$(get -s -n "" "https://pecl.php.net/rest/r/$extension/allreleases.xml")
|
response=$(get -s -n "" "https://pecl.php.net/rest/r/$extension/allreleases.xml") || response=
|
||||||
if [[ "$requested" =~ ^[0-9] ]]; then
|
if [[ "$requested" =~ ^[0-9] ]]; then
|
||||||
# Preserve exact pins and PECL's case-sensitive archive directory names.
|
# Preserve exact pins and PECL's case-sensitive archive directory names.
|
||||||
pecl_version=$(echo "$response" | grep -Fio "<v>$requested</v>" | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
pecl_version=$(echo "$response" | grep -Fio "<v>$requested</v>" | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||||
@@ -176,6 +177,10 @@ get_pecl_version() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
requested="$(echo "$requested" | tr '[:upper:]' '[:lower:]')"
|
requested="$(echo "$requested" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
# Only relax stable when the complete PECL release list contains no stable release.
|
||||||
|
if [[ "$requested" = stable && "$response" = *'<r>'*'</r>'*'</a>'* ]] && ! grep -Fqi '<s>stable</s>' <<< "$response"; then
|
||||||
|
requested=snapshot
|
||||||
|
fi
|
||||||
[[ " ${states[*]} " = *" $requested "* ]] || return 0
|
[[ " ${states[*]} " = *" $requested "* ]] || return 0
|
||||||
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo ".*$requested")"
|
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo ".*$requested")"
|
||||||
stability="$(IFS='|' ; echo "${states[*]}")"
|
stability="$(IFS='|' ; echo "${states[*]}")"
|
||||||
|
|||||||
@@ -403,27 +403,30 @@ Function Add-ComposerToolHelper() {
|
|||||||
}
|
}
|
||||||
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
||||||
} else {
|
} else {
|
||||||
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
$scoped_dir = "$composer_bin\_tools\$tool"
|
||||||
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
|
||||||
$scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix"
|
|
||||||
$unix_scoped_dir = $scoped_dir.replace('\', '/')
|
$unix_scoped_dir = $scoped_dir.replace('\', '/')
|
||||||
if(-not(Test-Path $scoped_dir\vendor\autoload.php)) {
|
$log = if((Test-Path $scoped_dir\vendor\autoload.php) -and $tool_version -match '^v?\d+\.\d+\.\d+([-+][a-zA-Z0-9.+-]+)?$') {
|
||||||
New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1
|
composer show $prefix$tool $tool_version -d $unix_scoped_dir 2>$null | findstr '^versions'
|
||||||
Set-Content -Path $scoped_dir\composer.json -Value "{}"
|
}
|
||||||
|
if(-not $log) {
|
||||||
|
if($tool_version -eq 'latest') { $tool_version = '*' }
|
||||||
|
if(-not(Test-Path $scoped_dir\composer.json)) {
|
||||||
|
New-Item -ItemType File -Path $scoped_dir\composer.json -Value '{}' -Force >$null
|
||||||
|
}
|
||||||
if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
|
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 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
|
composer require "$prefix${tool}:$tool_version" -d $unix_scoped_dir --update-with-dependencies $composer_args >$null 2>&1
|
||||||
if($LASTEXITCODE -ne 0) {
|
if($LASTEXITCODE -ne 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$log = composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
$log = composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
||||||
|
}
|
||||||
if(-not $log) {
|
if(-not $log) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
||||||
Add-Path $scoped_dir\vendor\bin
|
Add-Path $scoped_dir\vendor\bin -Force:(Test-Path -LiteralPath "$scoped_dir\phar\$tool.bat")
|
||||||
return $log
|
return $log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +481,14 @@ Function Add-ComposerTool() {
|
|||||||
Add-Log $tick $tool "Added $tool $tool_version"
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
} elseif($fallback_url) {
|
} elseif($fallback_url) {
|
||||||
Add-Log "!" $tool "Could not setup $tool using Composer. Falling back to PHAR."
|
Add-Log "!" $tool "Could not setup $tool using Composer. Falling back to PHAR."
|
||||||
|
if($scope -eq 'scoped') {
|
||||||
|
$bin_dir = "$composer_bin\_tools\$tool\phar"
|
||||||
|
New-Item -ItemType Directory -Path $bin_dir -Force >$null
|
||||||
|
Add-Path $bin_dir -Force
|
||||||
|
$env:PATH = "$bin_dir;$env:PATH"
|
||||||
|
$alias_command = "Set-Alias $tool $tool.bat"
|
||||||
|
Add-ToProfile $current_profile "/C:$alias_command" $alias_command
|
||||||
|
}
|
||||||
Add-Tool $fallback_url $tool $fallback_version_parameter
|
Add-Tool $fallback_url $tool $fallback_version_parameter
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $tool "Could not setup $tool"
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
|
|||||||
@@ -333,18 +333,24 @@ add_composer_tool_helper() {
|
|||||||
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 || return 1
|
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 || return 1
|
||||||
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
scoped_dir="$composer_bin/_tools/$tool"
|
||||||
if ! [ -f "$scoped_dir/vendor/autoload.php" ]; then
|
if [[ ! -f "$scoped_dir/vendor/autoload.php" || ! "$tool_version" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+([-+][a-zA-Z0-9.+-]+)?$ ]] ||
|
||||||
|
! composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" 2>/dev/null | grep '^versions' > /tmp/composer.log; then
|
||||||
|
[ "$tool_version" != latest ] || tool_version='*'
|
||||||
mkdir -p "$scoped_dir"
|
mkdir -p "$scoped_dir"
|
||||||
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
|
[ -f "$scoped_dir/composer.json" ] || echo '{}' > "$scoped_dir/composer.json"
|
||||||
if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
|
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
|
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1 || return 1
|
composer require "$prefix$tool:$tool_version" -d "$scoped_dir" --update-with-dependencies ${composer_args:+"$composer_args"} >/dev/null 2>&1 || return 1
|
||||||
|
composer show "$prefix$tool" -d "$scoped_dir" 2>/dev/null | grep '^versions' > /tmp/composer.log
|
||||||
fi
|
fi
|
||||||
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
|
||||||
[ -s /tmp/composer.log ] || return 1
|
[ -s /tmp/composer.log ] || return 1
|
||||||
add_path "$scoped_dir"/vendor/bin
|
add_path "$scoped_dir"/vendor/bin
|
||||||
|
# Switch the fallback's tool-cache link back to the Composer launcher.
|
||||||
|
if [[ -L "$tool_cache_path_dir/$tool" && "$(readlink "$tool_cache_path_dir/$tool")" = "$scoped_dir/phar/$tool" ]]; then
|
||||||
|
sudo ln -sfn "$scoped_dir/vendor/bin/$tool" "$tool_cache_path_dir/$tool"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +378,12 @@ add_composer_tool() {
|
|||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
elif [ -n "$fallback_url" ]; then
|
elif [ -n "$fallback_url" ]; then
|
||||||
add_log "!" "$tool" "Could not setup $tool using Composer. Falling back to PHAR."
|
add_log "!" "$tool" "Could not setup $tool using Composer. Falling back to PHAR."
|
||||||
|
if [ "$scope" = scoped ]; then
|
||||||
|
# Keep the PHAR private. Only its tool-cache link belongs on the runner PATH.
|
||||||
|
PATH="$scoped_dir/phar:$PATH" tool_path_dir="$scoped_dir/phar" add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
||||||
|
else
|
||||||
add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ read_env() {
|
|||||||
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
||||||
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
||||||
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
||||||
[[ "${asan:-${ASAN:-false}}" = "true" ]] && asan=asan && configure_asan || asan=
|
[[ "$OSTYPE" = linux* && "${asan:-${ASAN:-false}}" = "true" ]] && asan=asan && configure_asan || asan=
|
||||||
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||||
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
||||||
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user