mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Add blackfire to linux install
Add logging about install process Fix formating of semversion blackfire Only add version when needed Pass phpversion
This commit is contained in:
parent
03fd0b8719
commit
dc9461a053
@ -63,6 +63,12 @@ describe('Extension tests', () => {
|
|||||||
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
||||||
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||||
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('blackfire', '7.3', 'linux');
|
||||||
|
expect(linux).toContain('blackfire.sh 7.3 73');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
|
||||||
|
expect(linux).toContain('blackfire.sh 7.3 73 1.31.0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addExtensionOnDarwin', async () => {
|
it('checking addExtensionOnDarwin', async () => {
|
||||||
|
@ -161,4 +161,11 @@ describe('Utils tests', () => {
|
|||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking getMinorVersion', async () => {
|
||||||
|
expect(await utils.getMinorVersion('7.14.0')).toEqual('7.14');
|
||||||
|
expect(await utils.getMinorVersion('7.4')).toEqual('7.4');
|
||||||
|
expect(await utils.getMinorVersion('7.4.1')).toEqual('7.4');
|
||||||
|
expect(await utils.getMinorVersion('7.aa')).toEqual('7.aa');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@ -1247,6 +1247,17 @@ function suppressOutput(os_version) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.suppressOutput = suppressOutput;
|
exports.suppressOutput = suppressOutput;
|
||||||
|
function getMinorVersion(version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const regex = /^\d+\.\d+/;
|
||||||
|
const match = version.match(regex);
|
||||||
|
if (match === null) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
return match[0];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getMinorVersion = getMinorVersion;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -2810,6 +2821,19 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
const prefix = yield utils.getExtensionPrefix(ext_name);
|
const prefix = yield utils.getExtensionPrefix(ext_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
// match blackfire... blackfire-1.31.0
|
||||||
|
case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension):
|
||||||
|
script +=
|
||||||
|
'\nsh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
|
||||||
|
' ' +
|
||||||
|
version +
|
||||||
|
' ' +
|
||||||
|
(yield utils.getMinorVersion(version)).replace('.', '');
|
||||||
|
if (ext_version) {
|
||||||
|
script += ' ' + ext_version;
|
||||||
|
}
|
||||||
|
return;
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
script +=
|
script +=
|
||||||
|
@ -155,6 +155,20 @@ export async function addExtensionLinux(
|
|||||||
const prefix = await utils.getExtensionPrefix(ext_name);
|
const prefix = await utils.getExtensionPrefix(ext_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
// match blackfire... blackfire-1.31.0
|
||||||
|
case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension):
|
||||||
|
script +=
|
||||||
|
'\nsh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
|
||||||
|
' ' +
|
||||||
|
version +
|
||||||
|
' ' +
|
||||||
|
(await utils.getMinorVersion(version)).replace('.', '');
|
||||||
|
|
||||||
|
if (ext_version) {
|
||||||
|
script += ' ' + ext_version;
|
||||||
|
}
|
||||||
|
return;
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
script +=
|
script +=
|
||||||
|
23
src/scripts/ext/blackfire.sh
Normal file
23
src/scripts/ext/blackfire.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
phpversion=$2
|
||||||
|
blackfireVersion=${3:-1.31.0}
|
||||||
|
ini_file="/etc/php/$1/cli/conf.d/50-blackfire.ini"
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
(curl -A "Github action" -o /tmp/blackfire.so -L -s https://packages.blackfire.io/binaries/blackfire-php/$blackfireVersion/blackfire-php-linux_amd64-php-$phpversion.so >/dev/null 2>&1 && \
|
||||||
|
sudo mv /tmp/blackfire.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so >/dev/null 2>&1 && \
|
||||||
|
echo "extension=blackfire.so" | sudo tee -a "$ini_file" >/dev/null 2>&1 && \
|
||||||
|
add_log "$tick" "blackfire" "Installed and enabled") || \
|
||||||
|
add_log "$cross" "blackfire" "Could not install blackfire"
|
||||||
|
|
11
src/utils.ts
11
src/utils.ts
@ -261,3 +261,14 @@ export async function suppressOutput(os_version: string): Promise<string> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getMinorVersion(version: string): Promise<string> {
|
||||||
|
const regex = /^\d+\.\d+/;
|
||||||
|
const match = version.match(regex);
|
||||||
|
|
||||||
|
if (match === null) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match[0];
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user