Skip to content

Commit

Permalink
Merge pull request #152 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.7.3
  • Loading branch information
shivammathur authored Jan 17, 2020
2 parents 2ee4653 + f23ae2e commit 8489dbf
Show file tree
Hide file tree
Showing 14 changed files with 1,143 additions and 320 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/experimental-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup Node.js 12.x
uses: actions/setup-node@v1
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup Node.js 12.x
uses: actions/setup-node@v1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ describe('Extension tests', () => {
'7.4',
'linux'
);
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-xdebug'
);
expect(linux).toContain('pecl install xdebug');
expect(linux).toContain('update_extension xdebug 2.9.0');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
);
Expand Down Expand Up @@ -94,6 +91,9 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');

darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.9.0');

darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug');

Expand Down
43 changes: 40 additions & 3 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'
);
Expand All @@ -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'
);
Expand All @@ -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'
);
Expand All @@ -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 () => {
Expand Down
57 changes: 52 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1297,13 +1297,20 @@ class Command {
let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' ';
let first = true;
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key];
if (val) {
if (first) {
first = false;
}
else {
cmdStr += ',';
}
// safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)},`;
cmdStr += `${key}=${escape(`${val || ''}`)}`;
}
}
}
Expand Down Expand Up @@ -1813,6 +1820,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
*
Expand Down Expand Up @@ -1902,6 +1932,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;
Expand Down Expand Up @@ -2537,6 +2571,9 @@ function addExtensionDarwin(extension_csv, version, pipe) {
case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break;
case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.9.0' + pipe;
break;
case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8' + pipe;
break;
Expand Down Expand Up @@ -2631,17 +2668,27 @@ function addExtensionLinux(extension_csv, version, pipe) {
version +
pipe;
break;
// match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
script +=
'\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version +
pipe;
break;
pipe +
'\n' +
(yield utils.addLog('$tick', extension, 'Installed and enabled', 'linux'));
return;
default:
install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
Expand Down
Loading

0 comments on commit 8489dbf

Please sign in to comment.