diff --git a/__tests__/config.test.ts b/__tests__/config.test.ts index 2ef92613..f17067e9 100644 --- a/__tests__/config.test.ts +++ b/__tests__/config.test.ts @@ -24,7 +24,7 @@ describe('Config tests', () => { true ); expect(linux).toContain( - 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${ini_file[@]}"' + 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${pecl_file:-${ini_file[@]}}"' ); linux = await config.addINIValues( @@ -40,7 +40,7 @@ describe('Config tests', () => { 'darwin' ); expect(darwin).toContain( - 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${ini_file[@]}"' + 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" | sudo tee -a "${pecl_file:-${ini_file[@]}}"' ); darwin = await config.addINIValues( diff --git a/__tests__/coverage.test.ts b/__tests__/coverage.test.ts index af25eb8c..b159209a 100644 --- a/__tests__/coverage.test.ts +++ b/__tests__/coverage.test.ts @@ -28,43 +28,36 @@ describe('Config tests', () => { it('checking addCoverage with Xdebug on windows', async () => { const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); expect(win32).toContain('Add-Extension xdebug'); - expect(win32).toContain('xdebug.mode=coverage'); }); it('checking addCoverage with Xdebug on linux', async () => { const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); expect(linux).toContain('add_extension xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug3 on linux', async () => { const linux: string = await coverage.addCoverage('xdebug3', '7.4', 'linux'); expect(linux).toContain('add_extension_from_source xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug3 on linux', async () => { const linux: string = await coverage.addCoverage('xdebug3', '8.0', 'linux'); expect(linux).toContain('add_extension xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug on linux', async () => { const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); expect(linux).toContain('add_extension xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug3 on linux', async () => { const linux: string = await coverage.addCoverage('xdebug3', '8.1', 'linux'); expect(linux).toContain('add_extension xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug on linux', async () => { const linux: string = await coverage.addCoverage('xdebug', '8.1', 'linux'); expect(linux).toContain('add_extension xdebug'); - expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug on darwin', async () => { diff --git a/dist/index.js b/dist/index.js index 1cd2476c..75c37c1e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2337,9 +2337,8 @@ const config = __importStar(__webpack_require__(641)); async function addCoverageXdebug(extension, version, os_version, pipe) { const xdebug = (await extensions.addExtension(extension, version, os_version, true)) + pipe; - const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true); const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version); - return [xdebug, ini, log].join('\n'); + return xdebug + '\n' + log; } exports.addCoverageXdebug = addCoverageXdebug; /** @@ -2474,7 +2473,7 @@ async function addINIValuesUnix(ini_values_csv) { }); return ('echo "' + ini_values.join('\n') + - '" | sudo tee -a "${ini_file[@]}" >/dev/null 2>&1' + + '" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' + script); } exports.addINIValuesUnix = addINIValuesUnix; diff --git a/src/config.ts b/src/config.ts index c1a97128..07b601ad 100644 --- a/src/config.ts +++ b/src/config.ts @@ -17,7 +17,7 @@ export async function addINIValuesUnix( return ( 'echo "' + ini_values.join('\n') + - '" | sudo tee -a "${ini_file[@]}" >/dev/null 2>&1' + + '" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1' + script ); } diff --git a/src/coverage.ts b/src/coverage.ts index 4cbfed09..01216d91 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -19,18 +19,13 @@ export async function addCoverageXdebug( const xdebug = (await extensions.addExtension(extension, version, os_version, true)) + pipe; - const ini = await config.addINIValues( - 'xdebug.mode=coverage', - os_version, - true - ); const log = await utils.addLog( '$tick', extension, 'Xdebug enabled as coverage driver', os_version ); - return [xdebug, ini, log].join('\n'); + return xdebug + '\n' + log; } /** diff --git a/src/scripts/common.sh b/src/scripts/common.sh index a866c874..0f27a744 100644 --- a/src/scripts/common.sh +++ b/src/scripts/common.sh @@ -3,7 +3,8 @@ export tick="✓" export cross="✗" export curl_opts=(-sL) export old_versions="5.[3-5]" -export jit_versions="8.[0-1]" +export jit_versions="8.[0-9]" +export xdebug3_versions="7.[2-4]|8.[0-9]" export tool_path_dir="/usr/local/bin" export composer_bin="$HOME/.composer/vendor/bin" export composer_json="$HOME/.composer/composer.json" @@ -107,10 +108,19 @@ enable_extension() { sudo phpenmod -v "$version" "$1" >/dev/null 2>&1 fi if ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then - echo "$2=${ext_dir:?}/$1.so" >>"${pecl_file:-${ini_file[@]}}" + echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null fi } +# Function to configure PHP +configure_php() { + ( + echo -e "date.timezone=UTC\nmemory_limit=-1" + [[ "$version" =~ $jit_versions ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235" + [[ "$version" =~ $xdebug3_versions ]] && echo -e "xdebug.mode=coverage" + ) | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null +} + # Function to configure PECL. configure_pecl() { if ! [ -e /tmp/pecl_config ]; then diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 09f119b0..413ea428 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -139,8 +139,7 @@ setup_php() { fi ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") sudo chmod 777 "$ini_file" "${tool_path_dir:?}" - echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file" - [[ "$version" =~ ${jit_versions:?} ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235" >>"$ini_file" + configure_php ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer" diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 8cf4f5a5..d2bb7f3a 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -278,10 +278,10 @@ setup_php() { pecl_file="$scan_dir"/99-pecl.ini mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +) link_pecl_file + 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/*.json "$RUNNER_TOOL_CACHE/" - [[ "$version" =~ ${jit_versions:?} ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235" | sudo tee -a "${ini_file[@]}" >/dev/null 2>&1 add_log "${tick:?}" "PHP" "$status PHP $semver" } diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 630dd1ab..d3ff1dcd 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -419,7 +419,7 @@ if($installed.MajorMinorVersion -ne $version) { Add-Log $cross "PHP" "Could not setup PHP $version" exit 1 } -('date.timezone=UTC', 'memory_limit=-1') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir } +('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir } if($version -lt "5.5") { ('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri $bintray/$_ -OutFile $php_dir\$_ >$null 2>&1 } } else {