Skip to content

Commit 8489dbf

Browse files
authored
Merge pull request #152 from shivammathur/develop
1.7.3
2 parents 2ee4653 + f23ae2e commit 8489dbf

14 files changed

+1143
-320
lines changed

.github/workflows/experimental-workflow.yml

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@v2
33-
with:
34-
fetch-depth: 1
3533

3634
- name: Setup Node.js 12.x
3735
uses: actions/setup-node@v1

.github/workflows/workflow.yml

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
steps:
2929
- name: Checkout
3030
uses: actions/checkout@v2
31-
with:
32-
fetch-depth: 1
3331

3432
- name: Setup Node.js 12.x
3533
uses: actions/setup-node@v1

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<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>
1414
</p>
1515

16-
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.
16+
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.
1717

1818
## Contents
1919

@@ -72,7 +72,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
7272

7373
These tools can be setup globally using the `tools` input.
7474

75-
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
75+
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
7676

7777
```yaml
7878
uses: shivammathur/setup-php@v1

__tests__/extensions.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ describe('Extension tests', () => {
3030
'7.4',
3131
'linux'
3232
);
33-
expect(linux).toContain(
34-
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-xdebug'
35-
);
36-
expect(linux).toContain('pecl install xdebug');
33+
expect(linux).toContain('update_extension xdebug 2.9.0');
3734
expect(linux).toContain(
3835
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
3936
);
@@ -94,6 +91,9 @@ describe('Extension tests', () => {
9491
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
9592
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
9693

94+
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
95+
expect(darwin).toContain('sudo pecl install xdebug-2.9.0');
96+
9797
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
9898
expect(darwin).toContain('sudo pecl install xdebug');
9999

__tests__/tools.test.ts

+40-3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,35 @@ describe('Tools tests', () => {
239239
expect(script).toContain('Platform fedora is not supported');
240240
});
241241

242+
it('checking addDevTools', async () => {
243+
let script: string = await tools.addDevTools('phpize', 'linux');
244+
expect(script).toContain('add_devtools');
245+
expect(script).toContain('add_log "$tick" "phpize" "Added"');
246+
247+
script = await tools.addDevTools('php-config', 'linux');
248+
expect(script).toContain('add_devtools');
249+
expect(script).toContain('add_log "$tick" "php-config" "Added"');
250+
251+
script = await tools.addDevTools('phpize', 'darwin');
252+
expect(script).toContain('add_log "$tick" "phpize" "Added"');
253+
254+
script = await tools.addDevTools('php-config', 'darwin');
255+
expect(script).toContain('add_log "$tick" "php-config" "Added"');
256+
257+
script = await tools.addDevTools('phpize', 'win32');
258+
expect(script).toContain(
259+
'Add-Log "$cross" "phpize" "phpize is not a windows tool"'
260+
);
261+
262+
script = await tools.addDevTools('php-config', 'win32');
263+
expect(script).toContain(
264+
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
265+
);
266+
267+
script = await tools.addDevTools('tool', 'fedora');
268+
expect(script).toContain('Platform fedora is not supported');
269+
});
270+
242271
it('checking addPackage', async () => {
243272
let script: string = await tools.addPackage(
244273
'tool',
@@ -260,7 +289,7 @@ describe('Tools tests', () => {
260289

261290
it('checking addTools on linux', async () => {
262291
const script: string = await tools.addTools(
263-
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3',
292+
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, php-config, phpize',
264293
'7.4',
265294
'linux'
266295
);
@@ -279,10 +308,13 @@ describe('Tools tests', () => {
279308
expect(script).toContain('add_pecl');
280309
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
281310
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
311+
expect(script).toContain('add_devtools');
312+
expect(script).toContain('add_log "$tick" "php-config" "Added"');
313+
expect(script).toContain('add_log "$tick" "phpize" "Added"');
282314
});
283315
it('checking addTools on darwin', async () => {
284316
const script: string = await tools.addTools(
285-
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3',
317+
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3, phpize, php-config',
286318
'7.4',
287319
'darwin'
288320
);
@@ -308,10 +340,12 @@ describe('Tools tests', () => {
308340
expect(script).toContain(
309341
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
310342
);
343+
expect(script).toContain('add_log "$tick" "phpize" "Added"');
344+
expect(script).toContain('add_log "$tick" "php-config" "Added"');
311345
});
312346
it('checking addTools on windows', async () => {
313347
const script: string = await tools.addTools(
314-
'codeception, deployer, prestissimo, phpmd, phinx, does_not_exit',
348+
'codeception, deployer, prestissimo, phpmd, phinx, php-config, phpize, does_not_exit',
315349
'7.4',
316350
'win32'
317351
);
@@ -325,6 +359,9 @@ describe('Tools tests', () => {
325359
'Add-Composer-Tool prestissimo prestissimo hirak/'
326360
);
327361
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
362+
expect(script).toContain('phpize is not a windows tool');
363+
expect(script).toContain('php-config is not a windows tool');
364+
expect(script).toContain('Tool does_not_exit is not supported');
328365
expect(script).toContain('Tool does_not_exit is not supported');
329366
});
330367
it('checking addTools with composer tool using user/tool as input', async () => {

dist/index.js

+52-5
Original file line numberDiff line numberDiff line change
@@ -1297,13 +1297,20 @@ class Command {
12971297
let cmdStr = CMD_STRING + this.command;
12981298
if (this.properties && Object.keys(this.properties).length > 0) {
12991299
cmdStr += ' ';
1300+
let first = true;
13001301
for (const key in this.properties) {
13011302
if (this.properties.hasOwnProperty(key)) {
13021303
const val = this.properties[key];
13031304
if (val) {
1305+
if (first) {
1306+
first = false;
1307+
}
1308+
else {
1309+
cmdStr += ',';
1310+
}
13041311
// safely append the val - avoid blowing up when attempting to
13051312
// call .replace() if message is not a string for some reason
1306-
cmdStr += `${key}=${escape(`${val || ''}`)},`;
1313+
cmdStr += `${key}=${escape(`${val || ''}`)}`;
13071314
}
13081315
}
13091316
}
@@ -1813,6 +1820,29 @@ function addArchive(tool, version, url, os_version) {
18131820
});
18141821
}
18151822
exports.addArchive = addArchive;
1823+
/**
1824+
* Function to get the script to setup php-config and phpize
1825+
*
1826+
* @param tool
1827+
* @param os_version
1828+
*/
1829+
function addDevTools(tool, os_version) {
1830+
return __awaiter(this, void 0, void 0, function* () {
1831+
switch (os_version) {
1832+
case 'linux':
1833+
return ('add_devtools' +
1834+
'\n' +
1835+
(yield utils.addLog('$tick', tool, 'Added', 'linux')));
1836+
case 'darwin':
1837+
return yield utils.addLog('$tick', tool, 'Added', 'darwin');
1838+
case 'win32':
1839+
return yield utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
1840+
default:
1841+
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
1842+
}
1843+
});
1844+
}
1845+
exports.addDevTools = addDevTools;
18161846
/**
18171847
* Helper function to get script to setup a tool using composer
18181848
*
@@ -1902,6 +1932,10 @@ function addTools(tools_csv, php_version, os_version) {
19021932
case 'pecl':
19031933
script += yield getPECLCommand(os_version);
19041934
break;
1935+
case 'php-config':
1936+
case 'phpize':
1937+
script += yield addDevTools(tool, os_version);
1938+
break;
19051939
default:
19061940
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
19071941
break;
@@ -2537,6 +2571,9 @@ function addExtensionDarwin(extension_csv, version, pipe) {
25372571
case /5\.6xdebug/.test(version_extension):
25382572
install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
25392573
break;
2574+
case /7\.0xdebug/.test(version_extension):
2575+
install_command = 'sudo pecl install xdebug-2.9.0' + pipe;
2576+
break;
25402577
case /5\.6redis/.test(version_extension):
25412578
install_command = 'sudo pecl install redis-2.2.8' + pipe;
25422579
break;
@@ -2631,17 +2668,27 @@ function addExtensionLinux(extension_csv, version, pipe) {
26312668
version +
26322669
pipe;
26332670
break;
2671+
// match 7.0xdebug..7.4xdebug
2672+
case /^7\.[0-4]xdebug$/.test(version_extension):
2673+
script +=
2674+
'\nupdate_extension xdebug 2.9.0' +
2675+
pipe +
2676+
'\n' +
2677+
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
2678+
return;
26342679
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
26352680
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
2636-
install_command =
2637-
'sh ' +
2681+
script +=
2682+
'\nsh ' +
26382683
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
26392684
' ' +
26402685
extension +
26412686
' ' +
26422687
version +
2643-
pipe;
2644-
break;
2688+
pipe +
2689+
'\n' +
2690+
(yield utils.addLog('$tick', extension, 'Installed and enabled', 'linux'));
2691+
return;
26452692
default:
26462693
install_command =
26472694
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +

0 commit comments

Comments
 (0)