mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-25 21:13:04 +07:00
Add support for Xdebug3 on stable PHP
This commit is contained in:
parent
b9404683e1
commit
52691651dc
@ -1,15 +1,9 @@
|
|||||||
import * as coverage from '../src/coverage';
|
import * as coverage from '../src/coverage';
|
||||||
|
|
||||||
jest.mock('../src/extensions', () => ({
|
|
||||||
addExtension: jest.fn().mockImplementation(extension => {
|
|
||||||
return 'add_extension ' + extension + '\n';
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Config tests', () => {
|
describe('Config tests', () => {
|
||||||
it('checking addCoverage with PCOV on windows', async () => {
|
it('checking addCoverage with PCOV on windows', async () => {
|
||||||
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
|
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
|
||||||
expect(win32).toContain('add_extension pcov');
|
expect(win32).toContain('Add-Extension pcov');
|
||||||
expect(win32).toContain('Remove-Extension xdebug');
|
expect(win32).toContain('Remove-Extension xdebug');
|
||||||
|
|
||||||
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||||
@ -33,14 +27,26 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
it('checking addCoverage with Xdebug on windows', async () => {
|
it('checking addCoverage with Xdebug on windows', async () => {
|
||||||
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
|
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
|
||||||
expect(win32).toContain('add_extension xdebug');
|
expect(win32).toContain('Add-Extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with Xdebug on linux', async () => {
|
it('checking addCoverage with Xdebug on linux', async () => {
|
||||||
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
|
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
|
||||||
expect(linux).toContain('add_extension xdebug');
|
expect(linux).toContain('add_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 darwin', async () => {
|
it('checking addCoverage with Xdebug on darwin', async () => {
|
||||||
const darwin: string = await coverage.addCoverage(
|
const darwin: string = await coverage.addCoverage(
|
||||||
'xdebug',
|
'xdebug',
|
||||||
|
@ -56,11 +56,14 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'Xdebug, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('update_extension xdebug 2.9.3');
|
expect(linux).toContain('update_extension xdebug 2.9.6');
|
||||||
|
expect(linux).toContain(
|
||||||
|
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
|
||||||
|
);
|
||||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||||
@ -76,6 +79,11 @@ describe('Extension tests', () => {
|
|||||||
'add_unstable_extension xdebug alpha zend_extension'
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
|
||||||
|
expect(linux).toContain(
|
||||||
|
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
|
||||||
|
);
|
||||||
|
|
||||||
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
||||||
expect(linux).toContain('gearman.sh 7.0');
|
expect(linux).toContain('gearman.sh 7.0');
|
||||||
linux = await extensions.addExtension('gearman', '7.1', 'linux');
|
linux = await extensions.addExtension('gearman', '7.1', 'linux');
|
||||||
|
@ -155,6 +155,7 @@ describe('Utils tests', () => {
|
|||||||
);
|
);
|
||||||
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
||||||
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||||
|
expect(await utils.getExtensionPrefix('xdebug3')).toEqual('zend_extension');
|
||||||
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
52
dist/index.js
vendored
52
dist/index.js
vendored
@ -1218,13 +1218,17 @@ exports.CSVArray = CSVArray;
|
|||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
async function getExtensionPrefix(extension) {
|
async function getExtensionPrefix(extension) {
|
||||||
const zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
const zend = [
|
||||||
|
'xdebug',
|
||||||
|
'xdebug3',
|
||||||
|
'opcache',
|
||||||
|
'ioncube',
|
||||||
|
'eaccelerator'
|
||||||
|
];
|
||||||
switch (zend.indexOf(extension)) {
|
switch (zend.indexOf(extension)) {
|
||||||
case 0:
|
default:
|
||||||
case 1:
|
|
||||||
return 'zend_extension';
|
return 'zend_extension';
|
||||||
case -1:
|
case -1:
|
||||||
default:
|
|
||||||
return 'extension';
|
return 'extension';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2142,18 +2146,24 @@ const config = __importStar(__webpack_require__(641));
|
|||||||
/**
|
/**
|
||||||
* Function to setup Xdebug
|
* Function to setup Xdebug
|
||||||
*
|
*
|
||||||
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
async function addCoverageXdebug(version, os_version, pipe) {
|
async function addCoverageXdebug(extension, version, os_version, pipe) {
|
||||||
switch (version) {
|
const xdebug = (await extensions.addExtension(extension, version, os_version, true)) +
|
||||||
case '7.4':
|
pipe;
|
||||||
|
const ini = (await config.addINIValues('xdebug.mode=coverage', os_version, true)) +
|
||||||
|
pipe;
|
||||||
|
const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version);
|
||||||
|
switch (true) {
|
||||||
|
case /^xdebug3$/.test(extension):
|
||||||
|
case /^8\.0$/.test(version):
|
||||||
|
return '\n' + xdebug + '\n' + ini + '\n' + log;
|
||||||
|
case /^xdebug$/.test(extension):
|
||||||
default:
|
default:
|
||||||
return ((await extensions.addExtension('xdebug', version, os_version, true)) +
|
return '\n' + xdebug + '\n' + log;
|
||||||
pipe +
|
|
||||||
'\n' +
|
|
||||||
(await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addCoverageXdebug = addCoverageXdebug;
|
exports.addCoverageXdebug = addCoverageXdebug;
|
||||||
@ -2234,7 +2244,9 @@ async function addCoverage(coverage_driver, version, os_version) {
|
|||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
return script + (await addCoverageXdebug(version, os_version, pipe));
|
case 'xdebug3':
|
||||||
|
return (script +
|
||||||
|
(await addCoverageXdebug(coverage_driver, version, os_version, pipe)));
|
||||||
case 'none':
|
case 'none':
|
||||||
return script + (await disableCoverage(version, os_version, pipe));
|
return script + (await disableCoverage(version, os_version, pipe));
|
||||||
default:
|
default:
|
||||||
@ -2280,10 +2292,10 @@ const utils = __importStar(__webpack_require__(163));
|
|||||||
*/
|
*/
|
||||||
async function addINIValuesUnix(ini_values_csv) {
|
async function addINIValuesUnix(ini_values_csv) {
|
||||||
const ini_values = await utils.CSVArray(ini_values_csv);
|
const ini_values = await utils.CSVArray(ini_values_csv);
|
||||||
let script = '\n';
|
let script = '';
|
||||||
await utils.asyncForEach(ini_values, async function (line) {
|
await utils.asyncForEach(ini_values, async function (line) {
|
||||||
script +=
|
script +=
|
||||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||||
});
|
});
|
||||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||||
}
|
}
|
||||||
@ -2961,10 +2973,20 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 7.2xdebug3..7.4xdebug3
|
||||||
|
case /^7\.[2-4]xdebug3$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
|
||||||
|
return;
|
||||||
|
// match 8.0xdebug3
|
||||||
|
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||||
|
extension = 'xdebug';
|
||||||
|
command = command_prefix + version + '-' + extension + pipe;
|
||||||
|
break;
|
||||||
// match 7.1xdebug..7.4xdebug
|
// match 7.1xdebug..7.4xdebug
|
||||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
'\nupdate_extension xdebug 2.9.3' +
|
'\nupdate_extension xdebug 2.9.6' +
|
||||||
pipe +
|
pipe +
|
||||||
'\n' +
|
'\n' +
|
||||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||||
|
@ -9,10 +9,10 @@ export async function addINIValuesUnix(
|
|||||||
ini_values_csv: string
|
ini_values_csv: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||||
let script = '\n';
|
let script = '';
|
||||||
await utils.asyncForEach(ini_values, async function (line: string) {
|
await utils.asyncForEach(ini_values, async function (line: string) {
|
||||||
script +=
|
script +=
|
||||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||||
});
|
});
|
||||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||||
}
|
}
|
||||||
|
@ -5,29 +5,36 @@ import * as config from './config';
|
|||||||
/**
|
/**
|
||||||
* Function to setup Xdebug
|
* Function to setup Xdebug
|
||||||
*
|
*
|
||||||
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoverageXdebug(
|
export async function addCoverageXdebug(
|
||||||
|
extension: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os_version: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (version) {
|
const xdebug =
|
||||||
case '7.4':
|
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||||
|
pipe;
|
||||||
|
const ini =
|
||||||
|
(await config.addINIValues('xdebug.mode=coverage', os_version, true)) +
|
||||||
|
pipe;
|
||||||
|
const log = await utils.addLog(
|
||||||
|
'$tick',
|
||||||
|
extension,
|
||||||
|
'Xdebug enabled as coverage driver',
|
||||||
|
os_version
|
||||||
|
);
|
||||||
|
switch (true) {
|
||||||
|
case /^xdebug3$/.test(extension):
|
||||||
|
case /^8\.0$/.test(version):
|
||||||
|
return '\n' + xdebug + '\n' + ini + '\n' + log;
|
||||||
|
case /^xdebug$/.test(extension):
|
||||||
default:
|
default:
|
||||||
return (
|
return '\n' + xdebug + '\n' + log;
|
||||||
(await extensions.addExtension('xdebug', version, os_version, true)) +
|
|
||||||
pipe +
|
|
||||||
'\n' +
|
|
||||||
(await utils.addLog(
|
|
||||||
'$tick',
|
|
||||||
'xdebug',
|
|
||||||
'Xdebug enabled as coverage driver',
|
|
||||||
os_version
|
|
||||||
))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +148,11 @@ export async function addCoverage(
|
|||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
return script + (await addCoverageXdebug(version, os_version, pipe));
|
case 'xdebug3':
|
||||||
|
return (
|
||||||
|
script +
|
||||||
|
(await addCoverageXdebug(coverage_driver, version, os_version, pipe))
|
||||||
|
);
|
||||||
case 'none':
|
case 'none':
|
||||||
return script + (await disableCoverage(version, os_version, pipe));
|
return script + (await disableCoverage(version, os_version, pipe));
|
||||||
default:
|
default:
|
||||||
|
@ -298,10 +298,20 @@ export async function addExtensionLinux(
|
|||||||
' ' +
|
' ' +
|
||||||
version;
|
version;
|
||||||
return;
|
return;
|
||||||
|
// match 7.2xdebug3..7.4xdebug3
|
||||||
|
case /^7\.[2-4]xdebug3$/.test(version_extension):
|
||||||
|
add_script +=
|
||||||
|
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
|
||||||
|
return;
|
||||||
|
// match 8.0xdebug3
|
||||||
|
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||||
|
extension = 'xdebug';
|
||||||
|
command = command_prefix + version + '-' + extension + pipe;
|
||||||
|
break;
|
||||||
// match 7.1xdebug..7.4xdebug
|
// match 7.1xdebug..7.4xdebug
|
||||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||||
add_script +=
|
add_script +=
|
||||||
'\nupdate_extension xdebug 2.9.3' +
|
'\nupdate_extension xdebug 2.9.6' +
|
||||||
pipe +
|
pipe +
|
||||||
'\n' +
|
'\n' +
|
||||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||||
|
@ -201,6 +201,27 @@ update_extension() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to install extension from source
|
||||||
|
add_extension_from_source() {
|
||||||
|
extension=$1
|
||||||
|
repo=$2
|
||||||
|
release=$3
|
||||||
|
args=$4
|
||||||
|
prefix=$5
|
||||||
|
(
|
||||||
|
add_devtools
|
||||||
|
delete_extension "$extension"
|
||||||
|
curl -o /tmp/"$extension".tar.gz -sSL https://github.com/"$repo"/archive/"$release".tar.gz
|
||||||
|
tar xf /tmp/"$extension".tar.gz -C /tmp
|
||||||
|
cd /tmp/"$extension-$release" || exit 1
|
||||||
|
phpize && ./configure "$args" && make && sudo make install
|
||||||
|
enable_extension "$extension" "$prefix"
|
||||||
|
) >/dev/null 2>&1
|
||||||
|
(
|
||||||
|
check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$release on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
# Function to setup a remote tool.
|
||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
|
12
src/utils.ts
12
src/utils.ts
@ -224,13 +224,17 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
|||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
export async function getExtensionPrefix(extension: string): Promise<string> {
|
export async function getExtensionPrefix(extension: string): Promise<string> {
|
||||||
const zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
const zend: Array<string> = [
|
||||||
|
'xdebug',
|
||||||
|
'xdebug3',
|
||||||
|
'opcache',
|
||||||
|
'ioncube',
|
||||||
|
'eaccelerator'
|
||||||
|
];
|
||||||
switch (zend.indexOf(extension)) {
|
switch (zend.indexOf(extension)) {
|
||||||
case 0:
|
default:
|
||||||
case 1:
|
|
||||||
return 'zend_extension';
|
return 'zend_extension';
|
||||||
case -1:
|
case -1:
|
||||||
default:
|
|
||||||
return 'extension';
|
return 'extension';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user