Add support for blackfire client, agent and player

This commit is contained in:
Shivam Mathur 2020-02-28 13:19:12 +05:30
parent 84e88e382f
commit acee5b203f
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
10 changed files with 177 additions and 174 deletions

View File

@ -2,28 +2,10 @@ import * as tools from '../src/tools';
describe('Tools tests', () => { describe('Tools tests', () => {
it('checking getCommand', async () => { it('checking getCommand', async () => {
expect(await tools.getArchiveCommand('linux')).toBe('add_tool '); expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await tools.getArchiveCommand('darwin')).toBe('add_tool '); expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await tools.getArchiveCommand('win32')).toBe('Add-Tool '); expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await tools.getArchiveCommand('fedora')).toContain( expect(await tools.getCommand('fedora', 'tool')).toContain(
'Platform fedora is not supported'
);
});
it('checking getCommand', async () => {
expect(await tools.getPackageCommand('linux')).toBe('add_composer_tool ');
expect(await tools.getPackageCommand('darwin')).toBe('add_composer_tool ');
expect(await tools.getPackageCommand('win32')).toBe('Add-Composer-Tool ');
expect(await tools.getPackageCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking getPECLCommand', async () => {
expect(await tools.getPECLCommand('linux')).toBe('add_pecl ');
expect(await tools.getPECLCommand('darwin')).toBe('add_pecl ');
expect(await tools.getPECLCommand('win32')).toBe('Add-PECL ');
expect(await tools.getPECLCommand('fedora')).toContain(
'Platform fedora is not supported' 'Platform fedora is not supported'
); );
}); });
@ -205,12 +187,12 @@ describe('Tools tests', () => {
); );
}); });
it('checking getPhpunitUri', async () => { it('checking getPharUri', async () => {
expect(await tools.getPhpunitUrl('tool', 'latest')).toBe( expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe(
'https://phar.phpunit.de/tool.phar' 'domain/tool.phar'
); );
expect(await tools.getPhpunitUrl('tool', '1.2.3')).toBe( expect(await tools.getPharUrl('domain', 'tool', 'v', '1.2.3')).toBe(
'https://phar.phpunit.de/tool-1.2.3.phar' 'domain/tool-v1.2.3.phar'
); );
}); });
@ -353,13 +335,13 @@ describe('Tools tests', () => {
'user/', 'user/',
'linux' 'linux'
); );
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/'); expect(script).toContain('add_composertool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin');
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/'); expect(script).toContain('add_composertool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
expect(script).toContain('Add-Composer-Tool tool tool:1.2.3 user/'); expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora'); script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
expect(script).toContain('Platform fedora is not supported'); expect(script).toContain('Platform fedora is not supported');
@ -367,10 +349,14 @@ describe('Tools tests', () => {
it('checking addTools on linux', async () => { it('checking addTools on linux', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'cs2pr, flex, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony, wp-cli', 'blackfire, blackfire-player, cs2pr, flex, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony, wp-cli',
'7.4', '7.4',
'linux' 'linux'
); );
expect(script).toContain('add_blackfire');
expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://getcomposer.org/composer-stable.phar composer' 'add_tool https://getcomposer.org/composer-stable.phar composer'
); );
@ -396,19 +382,23 @@ describe('Tools tests', () => {
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli' 'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
); );
expect(script).toContain('add_pecl'); expect(script).toContain('add_pecl');
expect(script).toContain('add_composer_tool flex flex symfony/'); expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/'); expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/');
expect(script).toContain('add_devtools'); expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_log "$tick" "php-config" "Added"');
expect(script).toContain('add_log "$tick" "phpize" "Added"'); expect(script).toContain('add_log "$tick" "phpize" "Added"');
}); });
it('checking addTools on darwin', async () => { it('checking addTools on darwin', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'flex, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli', 'blackfire, blackfire-player, flex, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli',
'7.4', '7.4',
'darwin' 'darwin'
); );
expect(script).toContain('add_blackfire');
expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://getcomposer.org/composer-stable.phar composer' 'add_tool https://getcomposer.org/composer-stable.phar composer'
); );
@ -430,13 +420,13 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm' 'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
); );
expect(script).toContain('add_composer_tool flex flex symfony/'); expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
); );
expect(script).toContain( expect(script).toContain(
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-' 'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony'
@ -452,27 +442,29 @@ describe('Tools tests', () => {
}); });
it('checking addTools on windows', async () => { it('checking addTools on windows', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'codeception, cs2pr, deployer, flex, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, wp-cli, does_not_exit', 'blackfire, blackfire-player:1.8.1, codeception, cs2pr, deployer, flex, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, wp-cli, does_not_exit',
'7.4', '7.4',
'win32' 'win32'
); );
expect(script).toContain('Add-Blackfire 1.32.0');
expect(script).toContain(
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'Add-Tool https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
); );
expect(script).toContain('Add-Composer-Tool flex flex symfony/'); expect(script).toContain('Add-Composertool flex flex symfony/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer' 'Add-Tool https://deployer.org/deployer.phar deployer'
); );
expect(script).toContain( expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
'Add-Composer-Tool prestissimo prestissimo hirak/'
);
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd' 'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
); );
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/'); expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive' 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
); );
@ -496,12 +488,10 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'Add-Tool https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
expect(script).toContain( expect(script).toContain(
'Add-Composer-Tool prestissimo prestissimo hirak/' 'Add-Composertool composer-prefetcher composer-prefetcher narrowspark/automatic-'
);
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
expect(script).toContain(
'Add-Composer-Tool composer-prefetcher composer-prefetcher narrowspark/automatic-'
); );
}); });
}); });

View File

@ -168,4 +168,7 @@ describe('Utils tests', () => {
expect(await utils.getBlackfireVersion(null)).toEqual('1.31.0'); expect(await utils.getBlackfireVersion(null)).toEqual('1.31.0');
expect(await utils.getBlackfireVersion('1.32.0')).toEqual('1.32.0'); expect(await utils.getBlackfireVersion('1.32.0')).toEqual('1.32.0');
}); });
it('checking getBlackfireAgentVersion', async () => {
expect(await utils.getBlackfireAgentVersion()).toEqual('1.32.0');
});
}); });

View File

@ -3,6 +3,7 @@ author: shivammathur
description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer' description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer'
branding: branding:
color: 'purple' color: 'purple'
icon: 'play-circle'
inputs: inputs:
php-version: php-version:
description: 'Setup PHP version.' description: 'Setup PHP version.'

97
dist/index.js vendored
View File

@ -1265,6 +1265,15 @@ function getBlackfireVersion(blackfire_version) {
}); });
} }
exports.getBlackfireVersion = getBlackfireVersion; exports.getBlackfireVersion = getBlackfireVersion;
/**
* Function to get Blackfire Agent version
*/
function getBlackfireAgentVersion() {
return __awaiter(this, void 0, void 0, function* () {
return '1.32.0';
});
}
exports.getBlackfireAgentVersion = getBlackfireAgentVersion;
/***/ }), /***/ }),
@ -1594,63 +1603,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/** /**
* Function to get command to setup tool * Function to get command to setup tools
* *
* @param os_version * @param os_version
*/ */
function getArchiveCommand(os_version) { function getCommand(os_version, suffix) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
case 'darwin': case 'darwin':
return 'add_tool '; return 'add_' + suffix + ' ';
case 'win32': case 'win32':
return 'Add-Tool '; return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default: default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }
}); });
} }
exports.getArchiveCommand = getArchiveCommand; exports.getCommand = getCommand;
/**
* Function to get command to setup tools using composer
*
* @param os_version
*/
function getPackageCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_composer_tool ';
case 'win32':
return 'Add-Composer-Tool ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getPackageCommand = getPackageCommand;
/**
*
* Function to get command to setup PECL
*
* @param os_version
*/
function getPECLCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getPECLCommand = getPECLCommand;
/** /**
* Function to get tool version * Function to get tool version
* *
@ -1805,10 +1775,10 @@ function addPhive(version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (version) { switch (version) {
case 'latest': case 'latest':
return ((yield getArchiveCommand(os_version)) + return ((yield getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive'); 'https://phar.io/releases/phive.phar phive');
default: default:
return ((yield getArchiveCommand(os_version)) + return ((yield getCommand(os_version, 'tool')) +
'https://github.com/phar-io/phive/releases/download/' + 'https://github.com/phar-io/phive/releases/download/' +
version + version +
'/phive-' + '/phive-' +
@ -1819,22 +1789,21 @@ function addPhive(version, os_version) {
} }
exports.addPhive = addPhive; exports.addPhive = addPhive;
/** /**
* Function to get the PHPUnit url * Function to get the phar url in domain/tool-version.phar format
* *
* @param version * @param version
*/ */
function getPhpunitUrl(tool, version) { function getPharUrl(domain, tool, prefix, version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const phpunit = 'https://phar.phpunit.de';
switch (version) { switch (version) {
case 'latest': case 'latest':
return phpunit + '/' + tool + '.phar'; return domain + '/' + tool + '.phar';
default: default:
return phpunit + '/' + tool + '-' + version + '.phar'; return domain + '/' + tool + '-' + prefix + version + '.phar';
} }
}); });
} }
exports.getPhpunitUrl = getPhpunitUrl; exports.getPharUrl = getPharUrl;
/** /**
* Function to get the Deployer url * Function to get the Deployer url
* *
@ -1948,7 +1917,7 @@ exports.getCleanedToolsList = getCleanedToolsList;
*/ */
function addArchive(tool, version, url, os_version) { function addArchive(tool, version, url, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
return (yield getArchiveCommand(os_version)) + url + ' ' + tool; return (yield getCommand(os_version, 'tool')) + url + ' ' + tool;
}); });
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
@ -1985,7 +1954,7 @@ exports.addDevTools = addDevTools;
*/ */
function addPackage(tool, release, prefix, os_version) { function addPackage(tool, release, prefix, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const tool_command = yield getPackageCommand(os_version); const tool_command = yield getCommand(os_version, 'composertool');
return tool_command + tool + ' ' + release + ' ' + prefix; return tool_command + tool + ' ' + release + ' ' + prefix;
}); });
} }
@ -2010,6 +1979,14 @@ function addTools(tools_csv, php_version, os_version) {
script += '\n'; script += '\n';
let url = ''; let url = '';
switch (tool) { switch (tool) {
case 'blackfire':
case 'blackfire-agent':
script += yield getCommand(os_version, 'blackfire ' + (yield utils.getBlackfireAgentVersion()));
break;
case 'blackfire-player':
url = yield getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += yield addArchive(tool, version, url, os_version);
break;
case 'cs2pr': case 'cs2pr':
uri = yield getUri(tool, '', version, 'releases', '', 'download'); uri = yield getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
@ -2055,7 +2032,7 @@ function addTools(tools_csv, php_version, os_version) {
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = yield getPhpunitUrl(tool, version); url = yield getPharUrl('https://phar.phpunit.de', tool, '', version);
script += yield addArchive(tool, version, url, os_version); script += yield addArchive(tool, version, url, os_version);
break; break;
case 'deployer': case 'deployer':
@ -2075,7 +2052,7 @@ function addTools(tools_csv, php_version, os_version) {
script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version); script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version);
break; break;
case 'pecl': case 'pecl':
script += yield getPECLCommand(os_version); script += yield getCommand(os_version, 'pecl');
break; break;
case 'php-config': case 'php-config':
case 'phpize': case 'phpize':
@ -2724,6 +2701,8 @@ function addExtensionDarwin(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 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
install_command = install_command =
'bash ' + 'bash ' +
@ -2814,7 +2793,8 @@ function addExtensionWindows(extension_csv, version, pipe) {
const version_extension = version + extension; const version_extension = version + extension;
let matches; let matches;
switch (true) { switch (true) {
// match blackfire...blackfire-1.31.0 // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
script += script +=
'\n& ' + '\n& ' +
@ -2877,7 +2857,8 @@ 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 // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
install_command = install_command =
'bash ' + 'bash ' +

View File

@ -22,6 +22,8 @@ export async function addExtensionDarwin(
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 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -114,7 +116,8 @@ export async function addExtensionWindows(
const version_extension: string = version + extension; const version_extension: string = version + extension;
let matches: RegExpExecArray; let matches: RegExpExecArray;
switch (true) { switch (true) {
// match blackfire...blackfire-1.31.0 // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -183,7 +186,8 @@ 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 // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):

View File

@ -123,7 +123,7 @@ add_tool() {
} }
# Function to add a tool using composer # Function to add a tool using composer
add_composer_tool() { add_composertool() {
tool=$1 tool=$1
release=$2 release=$2
prefix=$3 prefix=$3
@ -134,6 +134,16 @@ add_composer_tool() {
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
} }
add_blackfire() {
sudo mkdir -p usr/local/var/run
brew tap blackfireio/homebrew-blackfire >/dev/null 2>&1
brew install blackfire-agent >/dev/null 2>&1
sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" >/dev/null 2>&1
brew services start blackfire-agent >/dev/null 2>&1
sudo blackfire --config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN" >/dev/null 2>&1
}
# Function to configure PECL # Function to configure PECL
configure_pecl() { configure_pecl() {
for tool in pear pecl; do for tool in pear pecl; do

View File

@ -173,7 +173,7 @@ add_tool() {
} }
# Function to setup a tool using composer # Function to setup a tool using composer
add_composer_tool() { add_composertool() {
tool=$1 tool=$1
release=$2 release=$2
prefix=$3 prefix=$3
@ -194,6 +194,18 @@ add_devtools() {
configure_pecl configure_pecl
} }
add_blackfire() {
sudo mkdir -p /var/run/blackfire
sudo curl -o /tmp/blackfire-gpg.key -sSL https://packages.blackfire.io/gpg.key >/dev/null 2>&1
sudo apt-key add /tmp/blackfire-gpg.key >/dev/null 2>&1
echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list >/dev/null 2>&1
find /etc/apt/sources.list.d -type f -name blackfire.list -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
$apt_install blackfire-agent >/dev/null 2>&1
sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" >/dev/null 2>&1
sudo /etc/init.d/blackfire-agent restart >/dev/null 2>&1
sudo blackfire --config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN" >/dev/null 2>&1
}
# Function to setup the nightly build from master branch # Function to setup the nightly build from master branch
setup_master() { setup_master() {
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz

View File

@ -134,7 +134,7 @@ Function Add-Tool() {
} }
} }
Function Add-Composer-Tool() { Function Add-Composertool() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()] [ValidateNotNull()]
@ -162,10 +162,31 @@ Function Add-Composer-Tool() {
} }
} }
Function Add-PECL() { Function Add-Pecl() {
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows" Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
} }
Function Add-Blackfire() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$agent_version
)
$url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\blackfire.zip >$null 2>&1
7z e $php_dir\blackfire.zip -o"$php_dir" -y >$null 2>&1
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias blackfire $php_dir\blackfire.exe"
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias blackfire-agent $php_dir\blackfire-agent.exe"
if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {
blackfire-agent --register --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1
}
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
blackfire --config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
}
}
# Variables # Variables
$tick = ([char]8730) $tick = ([char]8730)
$cross = ([char]10007) $cross = ([char]10007)
@ -174,6 +195,7 @@ $ext_dir = $php_dir + '\ext'
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$master_version = '8.0' $master_version = '8.0'
$arch = 'x64' $arch = 'x64'
$arch_name='amd64'
$ts = $false $ts = $false
if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') { if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') {
$ts = $true $ts = $true
@ -197,6 +219,7 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
if ($version -lt '7.0') { if ($version -lt '7.0') {
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
$arch='x86' $arch='x86'
$arch_name='386'
} }
if ($version -eq $master_version) { if ($version -eq $master_version) {
$version = 'master' $version = 'master'

View File

@ -1,60 +1,20 @@
import * as utils from './utils'; import * as utils from './utils';
/** /**
* Function to get command to setup tool * Function to get command to setup tools
* *
* @param os_version * @param os_version
*/ */
export async function getArchiveCommand(os_version: string): Promise<string> { export async function getCommand(
os_version: string,
suffix: string
): Promise<string> {
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
case 'darwin': case 'darwin':
return 'add_tool '; return 'add_' + suffix + ' ';
case 'win32': case 'win32':
return 'Add-Tool '; return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to get command to setup tools using composer
*
* @param os_version
*/
export async function getPackageCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_composer_tool ';
case 'win32':
return 'Add-Composer-Tool ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
*
* Function to get command to setup PECL
*
* @param os_version
*/
export async function getPECLCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default: default:
return await utils.log( return await utils.log(
'Platform ' + os_version + ' is not supported', 'Platform ' + os_version + ' is not supported',
@ -226,12 +186,12 @@ export async function addPhive(
switch (version) { switch (version) {
case 'latest': case 'latest':
return ( return (
(await getArchiveCommand(os_version)) + (await getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive' 'https://phar.io/releases/phive.phar phive'
); );
default: default:
return ( return (
(await getArchiveCommand(os_version)) + (await getCommand(os_version, 'tool')) +
'https://github.com/phar-io/phive/releases/download/' + 'https://github.com/phar-io/phive/releases/download/' +
version + version +
'/phive-' + '/phive-' +
@ -242,20 +202,21 @@ export async function addPhive(
} }
/** /**
* Function to get the PHPUnit url * Function to get the phar url in domain/tool-version.phar format
* *
* @param version * @param version
*/ */
export async function getPhpunitUrl( export async function getPharUrl(
domain: string,
tool: string, tool: string,
prefix: string,
version: string version: string
): Promise<string> { ): Promise<string> {
const phpunit = 'https://phar.phpunit.de';
switch (version) { switch (version) {
case 'latest': case 'latest':
return phpunit + '/' + tool + '.phar'; return domain + '/' + tool + '.phar';
default: default:
return phpunit + '/' + tool + '-' + version + '.phar'; return domain + '/' + tool + '-' + prefix + version + '.phar';
} }
} }
@ -382,7 +343,7 @@ export async function addArchive(
url: string, url: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
return (await getArchiveCommand(os_version)) + url + ' ' + tool; return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
} }
/** /**
@ -434,7 +395,7 @@ export async function addPackage(
prefix: string, prefix: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
const tool_command = await getPackageCommand(os_version); const tool_command = await getCommand(os_version, 'composertool');
return tool_command + tool + ' ' + release + ' ' + prefix; return tool_command + tool + ' ' + release + ' ' + prefix;
} }
@ -467,6 +428,17 @@ export async function addTools(
script += '\n'; script += '\n';
let url = ''; let url = '';
switch (tool) { switch (tool) {
case 'blackfire':
case 'blackfire-agent':
script += await getCommand(
os_version,
'blackfire ' + (await utils.getBlackfireAgentVersion())
);
break;
case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += await addArchive(tool, version, url, os_version);
break;
case 'cs2pr': case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download'); uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
@ -512,7 +484,7 @@ export async function addTools(
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = await getPhpunitUrl(tool, version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, version, url, os_version);
break; break;
case 'deployer': case 'deployer':
@ -537,7 +509,7 @@ export async function addTools(
); );
break; break;
case 'pecl': case 'pecl':
script += await getPECLCommand(os_version); script += await getCommand(os_version, 'pecl');
break; break;
case 'php-config': case 'php-config':
case 'phpize': case 'phpize':

View File

@ -279,3 +279,10 @@ export async function getBlackfireVersion(
return blackfire_version; return blackfire_version;
} }
} }
/**
* Function to get Blackfire Agent version
*/
export async function getBlackfireAgentVersion(): Promise<string> {
return '1.32.0';
}