Remove unnecessary dist parameter

This commit is contained in:
Shivam Mathur 2022-01-29 12:14:42 +05:30
parent 71d07ee7f4
commit 0022878947
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
11 changed files with 34 additions and 41 deletions

View File

@ -32,8 +32,7 @@ jest.mock('../src/install', () => ({
tool,
filename,
version,
ini_file,
__dirname
ini_file
].join(' ');
})
}));
@ -69,18 +68,18 @@ function setEnv(
describe('Install', () => {
it.each`
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.3 production ' + __dirname}
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini bash darwin.sh 7.3 development ' + __dirname}
${'7.4.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.4 none ' + __dirname}
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 production ' + __dirname}
${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 development ' + __dirname}
${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.1 none ' + __dirname}
${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 7.3 production ' + __dirname}
${'7.3'} | ${'linux'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${'phpunit'} | ${'initial script install extensions add_tool set coverage driver edit php.ini bash linux.sh 7.3 development ' + __dirname}
${'latest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 8.1 none ' + __dirname}
${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.0 production ' + __dirname}
${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.3 development ' + __dirname}
${'7.3'} | ${'win32'} | ${'a, b'} | ${'none'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini pwsh win32.ps1 7.3 none ' + __dirname}
${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.3 production'}
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini bash darwin.sh 7.3 development'}
${'7.4.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.4 none'}
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 production'}
${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 development'}
${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.1 none'}
${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 7.3 production'}
${'7.3'} | ${'linux'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${'phpunit'} | ${'initial script install extensions add_tool set coverage driver edit php.ini bash linux.sh 7.3 development'}
${'latest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 8.1 none'}
${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.0 production'}
${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.3 development'}
${'7.3'} | ${'win32'} | ${'a, b'} | ${'none'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini pwsh win32.ps1 7.3 none'}
`(
'Test install on $os for $version with extensions=$extension_csv, ini_values=$ini_values_csv, coverage_driver=$coverage_driver, tools=$tools',
async ({

2
dist/index.js vendored
View File

@ -481,7 +481,7 @@ async function run() {
const tool = await utils.scriptTool(os);
const script = os + (await utils.scriptExtension(os));
const location = await getScript(script, version, os);
await (0, exec_1.exec)(await utils.joins(tool, location, version, ini_file, __dirname));
await (0, exec_1.exec)(await utils.joins(tool, location, version, ini_file));
}
else {
core.setFailed('Unable to get the PHP version');

View File

@ -69,9 +69,7 @@ export async function run(): Promise<void> {
const tool = await utils.scriptTool(os);
const script = os + (await utils.scriptExtension(os));
const location = await getScript(script, version, os);
await exec(
await utils.joins(tool, location, version, ini_file, __dirname)
);
await exec(await utils.joins(tool, location, version, ini_file));
} else {
core.setFailed('Unable to get the PHP version');
}

View File

@ -64,7 +64,7 @@ add_brew_tap() {
add_brew_extension() {
formula=$1
prefix=$2
extension=$(grep "$formula=" "$dist"/../src/configs/brew_extensions | cut -d '=' -f 2)
extension=$(grep "$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2)
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
enable_extension "$extension" "$prefix"
if check_extension "$extension"; then
@ -240,7 +240,7 @@ setup_php() {
exit 1
fi
sudo cp "$dist"/../src/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
echo "::set-output name=php-version::$semver"
add_log "$tick" "PHP" "$status PHP $semver$extra_version"
}
@ -248,7 +248,7 @@ setup_php() {
# Variables
version=${1:-'8.1'}
ini=${2:-'production'}
dist=$3
src=${0%/*}/..
php_formula=shivammathur/php/php@"$version"
brew_path="$(command -v brew)"
brew_path_dir="$(dirname "$brew_path")"
@ -256,7 +256,7 @@ 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="${dist}"/../src/scripts
scripts="$src"/scripts
ext_tap=shivammathur/homebrew-extensions
php_tap=shivammathur/homebrew-php
export HOMEBREW_CHANGE_ARCH_TO_ARM=1

View File

@ -82,7 +82,7 @@ Function Add-Extension {
# Function to get a map of extensions and their dependent shared extensions.
Function Get-ExtensionMap {
php -d'error_reporting=0' $dist\..\src\scripts\extensions\extension_map.php $env:TEMP\map$version.orig
php -d'error_reporting=0' $src\scripts\extensions\extension_map.php $env:TEMP\map$version.orig
}
# Function to enable extension dependencies which are also extensions.

View File

@ -49,7 +49,7 @@ enable_extension() {
# Function to get a map of extensions and their dependent shared extensions.
get_extension_map() {
php -d'error_reporting=0' "${dist:?}"/../src/scripts/extensions/extension_map.php /tmp/map"$version".orig
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig
}
# Function to enable extension dependencies which are also extensions.

View File

@ -130,7 +130,7 @@ switch_version() {
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" "$dist"/../src/configs/php_packages | tr '\n' ' ')"
IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')"
install_packages "${packages[@]}"
else
run_script "php-ubuntu" "$version"
@ -241,7 +241,7 @@ setup_php() {
configure_php
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
sudo cp "$dist"/../src/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
echo "::set-output name=php-version::$semver"
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
}
@ -249,10 +249,10 @@ setup_php() {
# Variables
version=${1:-'8.1'}
ini=${2:-'production'}
dist=$3
src=${0%/*}/..
debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
scripts="${dist}"/../src/scripts
scripts="$src"/scripts
add_sudo

View File

@ -22,7 +22,7 @@ Function Edit-ComposerConfig() {
if (-not(Test-Path $composer_json)) {
Set-Content -Path $composer_json -Value "{}"
}
Add-EnvPATH $dist\..\src\configs\composer.env
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 + '"}}')

View File

@ -42,7 +42,7 @@ configure_composer() {
echo '{}' | tee "$composer_json" >/dev/null
chmod 644 "$composer_json"
fi
add_env_path "${dist:?}"/../src/configs/composer.env
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"'"}}'

View File

@ -136,7 +136,7 @@ self_hosted_setup() {
# Function to configure PHP
configure_php() {
add_php_config
ini_config_dir="${dist:?}"/../src/configs/ini
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)

View File

@ -8,12 +8,7 @@ param (
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$ini = 'production',
[Parameter(Position = 2, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$dist
$ini = 'production'
)
# Function to log start of a operation.
@ -178,7 +173,7 @@ Function Add-PhpConfig {
Set-Content -Path $php_dir\php.ini -Value ''
}
Set-Content -Path $php_dir\php.ini-current -Value $ini
$ini_config_dir = "$dist\..\src\configs\ini"
$ini_config_dir = "$src\configs\ini"
$ini_files = @("$ini_config_dir\php.ini")
$version -match $jit_versions -and ($ini_files += ("$ini_config_dir\jit.ini")) > $null 2>&1
$version -match $xdebug3_versions -and ($ini_files += ("$ini_config_dir\xdebug.ini")) > $null 2>&1
@ -261,8 +256,9 @@ if($env:RUNNER -eq 'self-hosted' -or (-not($env:ImageOS) -and -not($env:ImageVer
}
}
. $dist\..\src\scripts\tools\add_tools.ps1
. $dist\..\src\scripts\extensions\add_extensions.ps1
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
. $src\scripts\tools\add_tools.ps1
. $src\scripts\extensions\add_extensions.ps1
Add-Printf >$null 2>&1
Step-Log "Setup PhpManager"
@ -319,6 +315,6 @@ if($version -lt "5.5") {
}
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
Add-PhpCAInfo
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"