mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add support for phpize and php-config
This commit is contained in:
parent
65ccfb36dc
commit
320474a245
@ -13,7 +13,7 @@
|
||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||
</p>
|
||||
|
||||
Setup PHP with required extensions, php.ini configuration, code-coverage support and tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
||||
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -72,7 +72,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
||||
|
||||
These tools can be setup globally using the `tools` input.
|
||||
|
||||
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
|
||||
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
|
||||
|
||||
```yaml
|
||||
uses: shivammathur/setup-php@v1
|
||||
|
@ -239,6 +239,35 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addDevTools', async () => {
|
||||
let script: string = await tools.addDevTools('phpize', 'linux');
|
||||
expect(script).toContain('add_devtools');
|
||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||
|
||||
script = await tools.addDevTools('php-config', 'linux');
|
||||
expect(script).toContain('add_devtools');
|
||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||
|
||||
script = await tools.addDevTools('phpize', 'darwin');
|
||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||
|
||||
script = await tools.addDevTools('php-config', 'darwin');
|
||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||
|
||||
script = await tools.addDevTools('phpize', 'win32');
|
||||
expect(script).toContain(
|
||||
'Add-Log "$cross" "phpize" "phpize is not a windows tool"'
|
||||
);
|
||||
|
||||
script = await tools.addDevTools('php-config', 'win32');
|
||||
expect(script).toContain(
|
||||
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
|
||||
);
|
||||
|
||||
script = await tools.addDevTools('tool', 'fedora');
|
||||
expect(script).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addPackage', async () => {
|
||||
let script: string = await tools.addPackage(
|
||||
'tool',
|
||||
@ -260,7 +289,7 @@ describe('Tools tests', () => {
|
||||
|
||||
it('checking addTools on linux', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3',
|
||||
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, php-config, phpize',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
@ -279,10 +308,13 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain('add_pecl');
|
||||
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
|
||||
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
|
||||
expect(script).toContain('add_devtools');
|
||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||
});
|
||||
it('checking addTools on darwin', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3',
|
||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3, phpize, php-config',
|
||||
'7.4',
|
||||
'darwin'
|
||||
);
|
||||
@ -308,10 +340,12 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain(
|
||||
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
|
||||
);
|
||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||
});
|
||||
it('checking addTools on windows', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'codeception, deployer, prestissimo, phpmd, phinx, does_not_exit',
|
||||
'codeception, deployer, prestissimo, phpmd, phinx, php-config, phpize, does_not_exit',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
@ -325,6 +359,9 @@ describe('Tools tests', () => {
|
||||
'Add-Composer-Tool prestissimo prestissimo hirak/'
|
||||
);
|
||||
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
|
||||
expect(script).toContain('phpize is not a windows tool');
|
||||
expect(script).toContain('php-config is not a windows tool');
|
||||
expect(script).toContain('Tool does_not_exit is not supported');
|
||||
expect(script).toContain('Tool does_not_exit is not supported');
|
||||
});
|
||||
it('checking addTools with composer tool using user/tool as input', async () => {
|
||||
|
27
dist/index.js
vendored
27
dist/index.js
vendored
@ -1813,6 +1813,29 @@ function addArchive(tool, version, url, os_version) {
|
||||
});
|
||||
}
|
||||
exports.addArchive = addArchive;
|
||||
/**
|
||||
* Function to get the script to setup php-config and phpize
|
||||
*
|
||||
* @param tool
|
||||
* @param os_version
|
||||
*/
|
||||
function addDevTools(tool, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
return ('add_devtools' +
|
||||
'\n' +
|
||||
(yield utils.addLog('$tick', tool, 'Added', 'linux')));
|
||||
case 'darwin':
|
||||
return yield utils.addLog('$tick', tool, 'Added', 'darwin');
|
||||
case 'win32':
|
||||
return yield utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
|
||||
default:
|
||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.addDevTools = addDevTools;
|
||||
/**
|
||||
* Helper function to get script to setup a tool using composer
|
||||
*
|
||||
@ -1902,6 +1925,10 @@ function addTools(tools_csv, php_version, os_version) {
|
||||
case 'pecl':
|
||||
script += yield getPECLCommand(os_version);
|
||||
break;
|
||||
case 'php-config':
|
||||
case 'phpize':
|
||||
script += yield addDevTools(tool, os_version);
|
||||
break;
|
||||
default:
|
||||
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
|
||||
break;
|
||||
|
@ -96,6 +96,15 @@ add_composer_tool() {
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
}
|
||||
|
||||
# Function to setup phpize and php-config
|
||||
add_devtools() {
|
||||
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
||||
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||
fi
|
||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to setup the nightly build from master branch
|
||||
setup_master() {
|
||||
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||
@ -112,9 +121,7 @@ setup_master() {
|
||||
# Function to setup PECL
|
||||
add_pecl() {
|
||||
update_ppa
|
||||
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||
add_devtools
|
||||
wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1
|
||||
sudo php install-pear-nozlib.phar >/dev/null 2>&1
|
||||
sudo rm -rf install-pear-nozlib.phar >/dev/null 2>&1
|
||||
|
39
src/tools.ts
39
src/tools.ts
@ -269,6 +269,41 @@ export async function addArchive(
|
||||
return (await getArchiveCommand(os_version)) + url + ' ' + tool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the script to setup php-config and phpize
|
||||
*
|
||||
* @param tool
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addDevTools(
|
||||
tool: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
return (
|
||||
'add_devtools' +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', tool, 'Added', 'linux'))
|
||||
);
|
||||
case 'darwin':
|
||||
return await utils.addLog('$tick', tool, 'Added', 'darwin');
|
||||
case 'win32':
|
||||
return await utils.addLog(
|
||||
'$cross',
|
||||
tool,
|
||||
tool + ' is not a windows tool',
|
||||
'win32'
|
||||
);
|
||||
default:
|
||||
return await utils.log(
|
||||
'Platform ' + os_version + ' is not supported',
|
||||
os_version,
|
||||
'error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get script to setup a tool using composer
|
||||
*
|
||||
@ -368,6 +403,10 @@ export async function addTools(
|
||||
case 'pecl':
|
||||
script += await getPECLCommand(os_version);
|
||||
break;
|
||||
case 'php-config':
|
||||
case 'phpize':
|
||||
script += await addDevTools(tool, os_version);
|
||||
break;
|
||||
default:
|
||||
script += await utils.addLog(
|
||||
'$cross',
|
||||
|
Loading…
Reference in New Issue
Block a user