Add coverage support, improve logs and fix bugs

This commit is contained in:
Shivam Mathur 2019-09-26 02:33:39 +05:30
parent 36104f0983
commit 9134867822
26 changed files with 762 additions and 284 deletions

View File

@ -46,6 +46,26 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
- Extensions which are installed along with PHP if specified are enabled. - Extensions which are installed along with PHP if specified are enabled.
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped. - Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped.
## :signal_strength: Coverage support
- Specify `coverage: xdebug` to use `Xdebug`.
- Runs on all [PHP versions supported](#tada-php-support)
```
uses: shivammathur/setup-php@master
with:
php-version: 7.3
coverage: xdebug
```
- Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`
- For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
- `PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
```
uses: shivammathur/setup-php@master
with:
php-version: 7.3
ini-values-csv: 'pcov.directory=api' #optional, see above for usage.
coverage: pcov
```
## :memo: Usage ## :memo: Usage
Inputs supported by this GitHub Action. Inputs supported by this GitHub Action.
@ -53,6 +73,7 @@ Inputs supported by this GitHub Action.
- php-version - php-version
- extension-csv (optional) - extension-csv (optional)
- ini-values-csv (optional) - ini-values-csv (optional)
- coverage (optional)
See [action.yml](action.yml) for more info See [action.yml](action.yml) for more info
@ -68,6 +89,7 @@ steps:
php-version: 7.3 php-version: 7.3
extension-csv: mbstring, xdebug #optional extension-csv: mbstring, xdebug #optional
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
coverage: xdebug #optional
- name: Check PHP Version - name: Check PHP Version
run: php -v run: php -v
- name: Check Composer Version - name: Check Composer Version
@ -97,6 +119,7 @@ jobs:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xdebug #optional extension-csv: mbstring, xdebug #optional
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
coverage: xdebug #optional
- name: Check PHP Version - name: Check PHP Version
run: php -v run: php -v
- name: Check Composer Version - name: Check Composer Version

View File

@ -28,11 +28,13 @@ describe('Features tests', () => {
'Install-PhpExtension pcov -MinimumStability alpha' 'Install-PhpExtension pcov -MinimumStability alpha'
); );
win32 = await features.addExtension('DoesNotExist', '7.2', 'win32'); win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
expect(win32).not.toContain( expect(win32).toContain('Could not find extension: does_not_exist');
'Install-PhpExtension DoesNotExist -MinimumStability stable'
); win32 = await features.addExtension('xdebug', '7.2', 'fedora');
expect(win32).toContain('Platform fedora is not supported');
}); });
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await features.addExtension( let linux: string = await features.addExtension(
'xdebug, pcov', 'xdebug, pcov',
@ -45,7 +47,11 @@ describe('Features tests', () => {
expect(linux).toContain( expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov' 'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
); );
linux = await features.addExtension('xdebug', '7.2', 'fedora');
expect(linux).toContain('Platform fedora is not supported');
}); });
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await features.addExtension( let darwin: string = await features.addExtension(
'xdebug, pcov', 'xdebug, pcov',
@ -55,8 +61,14 @@ describe('Features tests', () => {
expect(darwin).toContain('sudo pecl install xdebug'); expect(darwin).toContain('sudo pecl install xdebug');
expect(darwin).toContain('sudo pecl install pcov'); expect(darwin).toContain('sudo pecl install pcov');
darwin = await features.addExtension('DoesNotExist', '7.2', 'darwin'); darwin = await features.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).not.toContain('sudo pecl install DoesNotExist'); expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
expect(darwin).toContain('Could not find extension: does_not_exist');
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
expect(darwin).toContain('Platform fedora is not supported');
}); });
it('checking addINIValuesOnWindows', async () => { it('checking addINIValuesOnWindows', async () => {
@ -73,6 +85,12 @@ describe('Features tests', () => {
expect(win32).toContain( expect(win32).toContain(
'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"' 'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"'
); );
win32 = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(win32).toContain('Platform fedora is not supported');
}); });
it('checking addINIValuesOnLinux', async () => { it('checking addINIValuesOnLinux', async () => {
@ -83,6 +101,12 @@ describe('Features tests', () => {
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file'); expect(linux).toContain('echo "post_max_size=256M" >> $ini_file');
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file'); expect(linux).toContain('echo "short_open_tag=On" >> $ini_file');
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file'); expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
linux = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(linux).toContain('Platform fedora is not supported');
}); });
it('checking addINIValuesOnDarwin', async () => { it('checking addINIValuesOnDarwin', async () => {
@ -93,5 +117,85 @@ describe('Features tests', () => {
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file'); expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file');
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file'); expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file');
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file'); expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
darwin = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(darwin).toContain('Platform fedora is not supported');
});
it('checking addCoverage on windows', async () => {
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
expect(win32).toContain(
'Install-PhpExtension xdebug -MinimumStability alpha'
);
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
expect(win32).toContain(
'Install-PhpExtension xdebug -MinimumStability stable'
);
win32 = await features.addCoverage('pcov', '7.4', 'win32');
expect(win32).toContain(
'Install-PhpExtension pcov -MinimumStability alpha'
);
expect(win32).toContain(
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
);
win32 = await features.addCoverage('pcov', '7.3', 'win32');
expect(win32).toContain(
'Install-PhpExtension pcov -MinimumStability stable'
);
expect(win32).toContain(
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
);
win32 = await features.addCoverage('nocov', '7.3', 'win32');
expect(win32).toContain('');
win32 = await features.addCoverage('pcov', '7.0', 'win32');
expect(win32).toContain('pcov requires php 7.1 or newer');
win32 = await features.addCoverage('pcov', '5.6', 'win32');
expect(win32).toContain('pcov requires php 7.1 or newer');
win32 = await features.addCoverage('', '7.4', 'win32');
expect(win32).toEqual('');
});
it('checking addCoverage on linux', async () => {
let linux: string = await features.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-xdebug'
);
linux = await features.addCoverage('pcov', '7.4', 'linux');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-pcov'
);
expect(linux).toContain(
"sudo phpdismod xdebug || echo 'xdebug not installed'"
);
expect(linux).toContain("sudo phpenmod pcov || echo 'pcov not installed'");
linux = await features.addCoverage('', '7.4', 'linux');
expect(linux).toEqual('');
});
it('checking addCoverage on darwin', async () => {
let darwin: string = await features.addCoverage('xdebug', '7.4', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug');
darwin = await features.addCoverage('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
expect(darwin).toContain('sudo pecl install pcov');
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
darwin = await features.addCoverage('', '7.4', 'win32');
expect(darwin).toEqual('');
}); });
}); });

View File

@ -10,6 +10,12 @@ jest.mock('../src/pecl', () => ({
}) })
})); }));
jest.mock('@actions/core', () => ({
getInput: jest.fn().mockImplementation(key => {
return ['setup-php'].indexOf(key) !== -1 ? key : '';
})
}));
async function cleanup(path: string): Promise<void> { async function cleanup(path: string): Promise<void> {
fs.unlink(path, error => { fs.unlink(path, error => {
if (error) { if (error) {
@ -21,7 +27,10 @@ async function cleanup(path: string): Promise<void> {
describe('Utils tests', () => { describe('Utils tests', () => {
it('checking getInput', async () => { it('checking getInput', async () => {
process.env['test'] = 'setup-php'; process.env['test'] = 'setup-php';
process.env['undefined'] = '';
expect(await utils.getInput('test', false)).toBe('setup-php'); expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('undefined', false)).toBe('');
expect(await utils.getInput('setup-php', false)).toBe('setup-php');
expect(await utils.getInput('DoesNotExist', false)).toBe(''); expect(await utils.getInput('DoesNotExist', false)).toBe('');
}); });
@ -51,10 +60,13 @@ describe('Utils tests', () => {
path.join(__dirname, '../src/win32.ps1'), path.join(__dirname, '../src/win32.ps1'),
'utf8' 'utf8'
); );
expect(rc).toBe(await utils.readScript('darwin.sh', '7.4', 'darwin')); expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
expect(darwin).toBe(await utils.readScript('darwin.sh', '7.3', 'darwin')); expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
expect(linux).toBe(await utils.readScript('linux.sh', '7.3', 'linux')); expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
expect(win32).toBe(await utils.readScript('win32.ps1', '7.3', 'win32')); expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
'Platform fedora is not supported'
);
}); });
it('checking writeScripts', async () => { it('checking writeScripts', async () => {
@ -86,6 +98,37 @@ describe('Utils tests', () => {
]); ]);
}); });
it('checking log', async () => {
let message: string = 'Test message';
let warning_log: string = await utils.log(message, 'win32', 'warning');
// expect(warning_log).toEqual(
// "Write-Host '" + message + "' -ForegroundColor yellow"
// );
warning_log = await utils.log(message, 'linux', 'warning');
expect(warning_log).toEqual('echo -e "\\033[33;1m' + message + '\\033[0m"');
warning_log = await utils.log(message, 'darwin', 'warning');
expect(warning_log).toEqual('echo -e "\\033[33;1m' + message + '\\033[0m"');
let error_log: string = await utils.log(message, 'win32', 'error');
// expect(error_log).toEqual(
// "Write-Host '" + message + "' -ForegroundColor red"
// );
error_log = await utils.log(message, 'linux', 'error');
expect(error_log).toEqual('echo -e "\\033[31;1m' + message + '\\033[0m"');
error_log = await utils.log(message, 'darwin', 'error');
expect(error_log).toEqual('echo -e "\\033[31;1m' + message + '\\033[0m"');
let success_log: string = await utils.log(message, 'win32', 'success');
// expect(success_log).toEqual(
// "Write-Host '" + message + "' -ForegroundColor green"
// );
success_log = await utils.log(message, 'linux', 'success');
expect(success_log).toEqual('echo -e "\\033[32;1m' + message + '\\033[0m"');
success_log = await utils.log(message, 'darwin', 'success');
expect(success_log).toEqual('echo -e "\\033[32;1m' + message + '\\033[0m"');
});
it('checking checkPECLExtension', async () => { it('checking checkPECLExtension', async () => {
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false); expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
expect(await pecl.checkPECLExtension('xdebug')).toBe(true); expect(await pecl.checkPECLExtension('xdebug')).toBe(true);

View File

@ -14,6 +14,9 @@ inputs:
ini-values-csv: ini-values-csv:
description: '(Optional) Custom values you want to set in php.ini' description: '(Optional) Custom values you want to set in php.ini'
required: false required: false
coverage:
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug and pcov)'
required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/install.js' main: 'lib/install.js'

View File

@ -18,24 +18,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(require("./utils")); const utils = __importStar(require("./utils"));
const pecl = __importStar(require("./pecl")); const pecl = __importStar(require("./pecl"));
function addExtension(extensions, version, os_version) { function addExtension(extension_csv, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (os_version === 'win32') { switch (os_version) {
return yield addExtensionWindows(extensions, version); case 'win32':
return yield addExtensionWindows(extension_csv, version);
case 'darwin':
return yield addExtensionDarwin(extension_csv, version);
case 'linux':
return yield addExtensionLinux(extension_csv, version);
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }
else if (os_version === 'linux') {
return yield addExtensionLinux(extensions, version);
}
return yield addExtensionDarwin(extensions);
}); });
} }
exports.addExtension = addExtension; exports.addExtension = addExtension;
function addINIValues(ini_values_csv, os_version) { function addINIValues(ini_values_csv, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (os_version === 'win32') { switch (os_version) {
case 'win32':
return yield addINIValuesWindows(ini_values_csv); return yield addINIValuesWindows(ini_values_csv);
} case 'darwin':
case 'linux':
return yield addINIValuesUnix(ini_values_csv); return yield addINIValuesUnix(ini_values_csv);
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}); });
} }
exports.addINIValues = addINIValues; exports.addINIValues = addINIValues;
@ -46,14 +54,15 @@ exports.addINIValues = addINIValues;
*/ */
function enableExtensionWindows(extension) { function enableExtensionWindows(extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
return `try { return (`try {
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll $exist = Test-Path -Path $ext_dir\\php_${extension}.dll
if(!(php -m | findstr -i ${extension}) -and $exist) { if(!(php -m | findstr -i ${extension}) -and $exist) {
Enable-PhpExtension ${extension} C:\\tools\\php Enable-PhpExtension ${extension} C:\\tools\\php\n` +
} (yield utils.log(extension + ' enabled', 'win32', 'success')) +
} catch [Exception] { `}
echo $_ } catch [Exception] {\n` +
}\n`; (yield utils.log(extension + ' could not be installed', 'win32', 'error')) +
` }\n`);
}); });
} }
exports.enableExtensionWindows = enableExtensionWindows; exports.enableExtensionWindows = enableExtensionWindows;
@ -64,10 +73,10 @@ exports.enableExtensionWindows = enableExtensionWindows;
*/ */
function enableExtensionUnix(extension) { function enableExtensionUnix(extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
return `if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then return (`if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"' echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
echo "${extension} enabled" (yield utils.log(extension + ' enabled', 'unix', 'success')) +
fi\n`; `; fi\n`);
}); });
} }
exports.enableExtensionUnix = enableExtensionUnix; exports.enableExtensionUnix = enableExtensionUnix;
@ -75,24 +84,37 @@ exports.enableExtensionUnix = enableExtensionUnix;
* Install and enable extensions for darwin * Install and enable extensions for darwin
* *
* @param extension_csv * @param extension_csv
* @param version
*/ */
function addExtensionDarwin(extension_csv) { function addExtensionDarwin(extension_csv, version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let extensions = yield utils.extensionArray(extension_csv); let extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += yield enableExtensionUnix(extension); script += yield enableExtensionUnix(extension);
if (yield pecl.checkPECLExtension(extension)) { switch (yield pecl.checkPECLExtension(extension)) {
case true:
extension =
version === '5.6' && extension === 'xdebug'
? 'xdebug-2.5.5'
: extension;
script += script +=
'if [ ! "$(php -m | grep ' + 'if [ ! "$(php -m | grep ' +
extension + extension +
')" ]; then sudo pecl install ' + ')" ]; then sudo pecl install ' +
extension + extension +
' || echo "Couldn\'t find extension: ' + ' || ' +
extension + (yield utils.log("Couldn't install extension: " + extension, 'darwin', 'error')) +
'"; fi\n'; '; fi\n';
break;
case false:
default:
script +=
(yield utils.log('Could not find extension: ' + extension, 'darwin', 'error')) + '\n';
break;
} }
}); });
}); });
@ -112,13 +134,21 @@ function addExtensionWindows(extension_csv, version) {
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += yield enableExtensionWindows(extension); script += yield enableExtensionWindows(extension);
let extension_version = 'stable'; let extension_version = '';
if (version == '7.4') { switch (version) {
case '7.4':
extension_version = 'alpha'; extension_version = 'alpha';
break;
case '7.2':
default:
extension_version = 'stable';
break;
} }
if (yield pecl.checkPECLExtension(extension)) { switch (yield pecl.checkPECLExtension(extension)) {
case true:
script += script +=
'if(!(php -m | findstr -i ' + 'if(!(php -m | findstr -i ' +
extension + extension +
@ -127,9 +157,15 @@ function addExtensionWindows(extension_csv, version) {
extension + extension +
' -MinimumStability ' + ' -MinimumStability ' +
extension_version + extension_version +
' } catch [Exception] { echo $_; echo "Could not install extension: "' + ' } catch [Exception] { ' +
extension + (yield utils.log('Could not install extension: ' + extension, 'win32', 'error')) +
' } }\n'; ' } }\n';
break;
case false:
default:
script +=
(yield utils.log('Could not find extension: ' + extension, 'win32', 'error')) + '\n';
break;
} }
}); });
}); });
@ -149,6 +185,7 @@ function addExtensionLinux(extension_csv, version) {
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += yield enableExtensionUnix(extension); script += yield enableExtensionUnix(extension);
script += script +=
@ -158,11 +195,9 @@ function addExtensionLinux(extension_csv, version) {
version + version +
'-' + '-' +
extension + extension +
' || echo "Couldn\'t find extension php' + ' || ' +
version + (yield utils.log("Couldn't find extension php" + version + '-' + extension, 'linux', 'error')) +
'-' + '; fi\n';
extension +
'"; fi\n';
}); });
}); });
return script; return script;
@ -207,3 +242,54 @@ function addINIValuesWindows(ini_values_csv) {
}); });
} }
exports.addINIValuesWindows = addINIValuesWindows; exports.addINIValuesWindows = addINIValuesWindows;
function addCoverage(coverage, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '';
script += '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
case 'pcov':
// if version is 7.1 or newer
switch (version) {
default:
script += yield addExtension(coverage, version, os_version);
script += yield addINIValues('pcov.enabled=1', os_version);
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
script +=
"sudo phpdismod xdebug || echo 'xdebug not installed'\n";
script += "sudo phpenmod pcov || echo 'pcov not installed'\n";
break;
case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
break;
case 'win32':
script +=
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
break;
}
// success
script += yield utils.log('pcov enabled as coverage driver', os_version, 'success');
// version is not supported
break;
case '5.6':
case '7.0':
script += yield utils.log('pcov requires php 7.1 or newer', os_version, 'warning');
break;
}
break;
//xdebug
case 'xdebug':
script += yield addExtension(coverage, version, os_version);
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success');
break;
// unknown coverage driver
default:
script = '';
}
return script;
});
}
exports.addCoverage = addCoverage;

View File

@ -30,12 +30,14 @@ function run() {
let version = yield utils.getInput('php-version', true); let version = yield utils.getInput('php-version', true);
let extension_csv = yield utils.getInput('extension-csv', false); let extension_csv = yield utils.getInput('extension-csv', false);
let ini_values_csv = yield utils.getInput('ini-values-csv', false); let ini_values_csv = yield utils.getInput('ini-values-csv', false);
let coverage = yield utils.getInput('coverage', false);
let os_version = process.platform; let os_version = process.platform;
// check the os version and run the respective script // check the os version and run the respective script
if (os_version == 'darwin') { if (os_version == 'darwin') {
let darwin = yield utils.readScript('darwin.sh', version, os_version); let darwin = yield utils.readScript('darwin.sh', version, os_version);
darwin += yield features.addExtension(extension_csv, version, os_version); darwin += yield features.addExtension(extension_csv, version, os_version);
darwin += yield features.addINIValues(ini_values_csv, os_version); darwin += yield features.addINIValues(ini_values_csv, os_version);
darwin += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('darwin.sh', version, darwin); yield utils.writeScript('darwin.sh', version, darwin);
yield exec_1.exec('sh -x ./' + version + 'darwin.sh ' + version); yield exec_1.exec('sh -x ./' + version + 'darwin.sh ' + version);
} }
@ -43,6 +45,7 @@ function run() {
let windows = yield utils.readScript('win32.ps1', version, os_version); let windows = yield utils.readScript('win32.ps1', version, os_version);
windows += yield features.addExtension(extension_csv, version, os_version); windows += yield features.addExtension(extension_csv, version, os_version);
windows += yield features.addINIValues(ini_values_csv, os_version); windows += yield features.addINIValues(ini_values_csv, os_version);
windows += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('win32.ps1', version, windows); yield utils.writeScript('win32.ps1', version, windows);
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version); yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
} }
@ -50,6 +53,7 @@ function run() {
let linux = yield utils.readScript('linux.sh', version, os_version); let linux = yield utils.readScript('linux.sh', version, os_version);
linux += yield features.addExtension(extension_csv, version, os_version); linux += yield features.addExtension(extension_csv, version, os_version);
linux += yield features.addINIValues(ini_values_csv, os_version); linux += yield features.addINIValues(ini_values_csv, os_version);
linux += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('linux.sh', version, linux); yield utils.writeScript('linux.sh', version, linux);
yield exec_1.exec('./' + version + 'linux.sh ' + version); yield exec_1.exec('./' + version + 'linux.sh ' + version);
} }

View File

@ -22,10 +22,13 @@ const core = __importStar(require("@actions/core"));
function getInput(name, mandatory) { function getInput(name, mandatory) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let input = process.env[name]; let input = process.env[name];
if (!input) { switch (input) {
input = core.getInput(name, { required: mandatory }); case '':
} case undefined:
return core.getInput(name, { required: mandatory });
default:
return input; return input;
}
}); });
} }
exports.getInput = getInput; exports.getInput = getInput;
@ -53,10 +56,21 @@ exports.asyncForEach = asyncForEach;
*/ */
function readScript(filename, version, os_version) { function readScript(filename, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (version === '7.4' && os_version === 'darwin') { switch (os_version) {
case 'darwin':
switch (version) {
case '7.4':
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8'); return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
} case '7.3':
default:
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8'); return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
}
case 'win32':
case 'linux':
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}); });
} }
exports.readScript = readScript; exports.readScript = readScript;
@ -102,3 +116,26 @@ function INIArray(ini_values_csv) {
}); });
} }
exports.INIArray = INIArray; exports.INIArray = INIArray;
function log(message, os_version, log_type) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'win32':
const color = {
error: 'red',
success: 'green',
warning: 'yellow'
};
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
case 'linux':
case 'darwin':
default:
const unix_color = {
error: '31',
success: '32',
warning: '33'
};
return ('echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
}
});
}
exports.log = log;

View File

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -20,7 +20,7 @@ function issue(name, message = '') {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;
const CMD_PREFIX = '##['; const CMD_STRING = '::';
class Command { class Command {
constructor(command, properties, message) { constructor(command, properties, message) {
if (!command) { if (!command) {
@ -31,7 +31,7 @@ class Command {
this.message = message; this.message = message;
} }
toString() { toString() {
let cmdStr = CMD_PREFIX + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
for (const key in this.properties) { for (const key in this.properties) {
@ -40,12 +40,12 @@ class Command {
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)};`; cmdStr += `${key}=${escape(`${val || ''}`)},`;
} }
} }
} }
} }
cmdStr += ']'; cmdStr += CMD_STRING;
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
const message = `${this.message || ''}`; const message = `${this.message || ''}`;

View File

@ -1 +1 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QA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AAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View File

@ -71,6 +71,11 @@ export declare function error(message: string): void;
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;
/**
* Writes info to log with console.log.
* @param message info message
*/
export declare function info(message: string): void;
/** /**
* Begin an output group. * Begin an output group.
* *

View File

@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("./command"); const command_1 = require("./command");
const os = require("os");
const path = require("path"); const path = require("path");
/** /**
* The code to exit an action * The code to exit an action
@ -68,7 +69,7 @@ exports.addPath = addPath;
* @returns string * @returns string
*/ */
function getInput(name, options) { function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
@ -125,6 +126,14 @@ function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message);
} }
exports.warning = warning; exports.warning = warning;
/**
* Writes info to log with console.log.
* @param message info message
*/
function info(message) {
process.stdout.write(message + os.EOL);
}
exports.info = info;
/** /**
* Begin an output group. * Begin an output group.
* *

View File

@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SA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GG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View File

@ -1,33 +1,33 @@
{ {
"_args": [ "_args": [
[ [
"@actions/core@1.1.0", "@actions/core@1.1.1",
"E:\\python\\setup-php" "E:\\python\\setup-php"
] ]
], ],
"_from": "@actions/core@1.1.0", "_from": "@actions/core@1.1.1",
"_id": "@actions/core@1.1.0", "_id": "@actions/core@1.1.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==", "_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
"_location": "/@actions/core", "_location": "/@actions/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/core@1.1.0", "raw": "@actions/core@1.1.1",
"name": "@actions/core", "name": "@actions/core",
"escapedName": "@actions%2fcore", "escapedName": "@actions%2fcore",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.1.0", "rawSpec": "1.1.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.1.0" "fetchSpec": "1.1.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"_spec": "1.1.0", "_spec": "1.1.1",
"_where": "E:\\python\\setup-php", "_where": "E:\\python\\setup-php",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
@ -43,7 +43,6 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core", "homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"keywords": [ "keywords": [
"github", "github",
@ -64,5 +63,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.1.0" "version": "1.1.1"
} }

View File

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -11,7 +11,7 @@ You can use this to download tools (or other files) from a download URL:
```js ```js
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
``` ```
#### Extract #### Extract
@ -22,15 +22,15 @@ These can then be extracted in platform specific ways:
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
if (process.platform === 'win32') { if (process.platform === 'win32') {
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip'); const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
// Or alternately // Or alternately
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z'); const node12Path = tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
} }
else { else {
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
} }
``` ```
@ -45,7 +45,7 @@ You'll often want to add it to the path as part of this step:
const tc = require('@actions/tool-cache'); const tc = require('@actions/tool-cache');
const core = require('@actions/core'); const core = require('@actions/core');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz'); const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to'); const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0'); const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');

View File

@ -217,14 +217,9 @@ function extractZip(file, dest) {
if (IS_WINDOWS) { if (IS_WINDOWS) {
yield extractZipWin(file, dest); yield extractZipWin(file, dest);
} }
else {
if (process.platform === 'darwin') {
yield extractZipDarwin(file, dest);
}
else { else {
yield extractZipNix(file, dest); yield extractZipNix(file, dest);
} }
}
return dest; return dest;
}); });
} }
@ -252,13 +247,7 @@ function extractZipWin(file, dest) {
} }
function extractZipNix(file, dest) { function extractZipNix(file, dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip'); const unzipPath = yield io.which('unzip');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
function extractZipDarwin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -1,32 +1,32 @@
{ {
"_args": [ "_args": [
[ [
"@actions/tool-cache@1.1.1", "@actions/tool-cache@1.1.2",
"E:\\python\\setup-php" "E:\\python\\setup-php"
] ]
], ],
"_from": "@actions/tool-cache@1.1.1", "_from": "@actions/tool-cache@1.1.2",
"_id": "@actions/tool-cache@1.1.1", "_id": "@actions/tool-cache@1.1.2",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-AILekrrj/L4N/5z5TGtUKVie4nKjxDioCgOEymyYxzPhGfjIxfE71tN2VTTpiICEWJ883rPRj2+WinTr1b6yVA==", "_integrity": "sha512-IJczPaZr02ECa3Lgws/TJEVco9tjOujiQSZbO3dHuXXjhd5vrUtfOgGwhmz3/f97L910OraPZ8SknofUk6RvOQ==",
"_location": "/@actions/tool-cache", "_location": "/@actions/tool-cache",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/tool-cache@1.1.1", "raw": "@actions/tool-cache@1.1.2",
"name": "@actions/tool-cache", "name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache", "escapedName": "@actions%2ftool-cache",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.1.1", "rawSpec": "1.1.2",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.1.1" "fetchSpec": "1.1.2"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.1.tgz", "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.2.tgz",
"_spec": "1.1.1", "_spec": "1.1.2",
"_where": "E:\\python\\setup-php", "_where": "E:\\python\\setup-php",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
@ -54,7 +54,6 @@
"lib", "lib",
"scripts" "scripts"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec", "homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [ "keywords": [
"github", "github",
@ -75,5 +74,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.1.1" "version": "1.1.2"
} }

Binary file not shown.

Binary file not shown.

188
package-lock.json generated
View File

@ -1,13 +1,13 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.3.4", "version": "1.3.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.1.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==" "integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg=="
}, },
"@actions/exec": { "@actions/exec": {
"version": "1.0.1", "version": "1.0.1",
@ -20,9 +20,9 @@
"integrity": "sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==" "integrity": "sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA=="
}, },
"@actions/tool-cache": { "@actions/tool-cache": {
"version": "1.1.1", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.1.tgz", "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.2.tgz",
"integrity": "sha512-AILekrrj/L4N/5z5TGtUKVie4nKjxDioCgOEymyYxzPhGfjIxfE71tN2VTTpiICEWJ883rPRj2+WinTr1b6yVA==", "integrity": "sha512-IJczPaZr02ECa3Lgws/TJEVco9tjOujiQSZbO3dHuXXjhd5vrUtfOgGwhmz3/f97L910OraPZ8SknofUk6RvOQ==",
"requires": { "requires": {
"@actions/core": "^1.1.0", "@actions/core": "^1.1.0",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
@ -42,18 +42,18 @@
} }
}, },
"@babel/core": { "@babel/core": {
"version": "7.5.5", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.2.tgz",
"integrity": "sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==", "integrity": "sha512-l8zto/fuoZIbncm+01p8zPSDZu/VuuJhAfA7d/AbzM09WR7iVhavvfNDYCNpo1VvLk6E6xgAoP9P+/EMJHuRkQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.5.5", "@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.5.5", "@babel/generator": "^7.6.2",
"@babel/helpers": "^7.5.5", "@babel/helpers": "^7.6.2",
"@babel/parser": "^7.5.5", "@babel/parser": "^7.6.2",
"@babel/template": "^7.4.4", "@babel/template": "^7.6.0",
"@babel/traverse": "^7.5.5", "@babel/traverse": "^7.6.2",
"@babel/types": "^7.5.5", "@babel/types": "^7.6.0",
"convert-source-map": "^1.1.0", "convert-source-map": "^1.1.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"json5": "^2.1.0", "json5": "^2.1.0",
@ -93,16 +93,15 @@
} }
}, },
"@babel/generator": { "@babel/generator": {
"version": "7.5.5", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.2.tgz",
"integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==", "integrity": "sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/types": "^7.5.5", "@babel/types": "^7.6.0",
"jsesc": "^2.5.1", "jsesc": "^2.5.1",
"lodash": "^4.17.13", "lodash": "^4.17.13",
"source-map": "^0.5.0", "source-map": "^0.5.0"
"trim-right": "^1.0.1"
}, },
"dependencies": { "dependencies": {
"source-map": { "source-map": {
@ -149,14 +148,14 @@
} }
}, },
"@babel/helpers": { "@babel/helpers": {
"version": "7.5.5", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.6.2.tgz",
"integrity": "sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==", "integrity": "sha512-3/bAUL8zZxYs1cdX2ilEE0WobqbCmKWr/889lf2SS0PpDcpEIY8pb1CCyz0pEcX3pEb+MCbks1jIokz2xLtGTA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/template": "^7.4.4", "@babel/template": "^7.6.0",
"@babel/traverse": "^7.5.5", "@babel/traverse": "^7.6.2",
"@babel/types": "^7.5.5" "@babel/types": "^7.6.0"
} }
}, },
"@babel/highlight": { "@babel/highlight": {
@ -171,9 +170,9 @@
} }
}, },
"@babel/parser": { "@babel/parser": {
"version": "7.5.5", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.2.tgz",
"integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g==", "integrity": "sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==",
"dev": true "dev": true
}, },
"@babel/plugin-syntax-object-rest-spread": { "@babel/plugin-syntax-object-rest-spread": {
@ -186,28 +185,28 @@
} }
}, },
"@babel/template": { "@babel/template": {
"version": "7.4.4", "version": "7.6.0",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.6.0.tgz",
"integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", "integrity": "sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"@babel/parser": "^7.4.4", "@babel/parser": "^7.6.0",
"@babel/types": "^7.4.4" "@babel/types": "^7.6.0"
} }
}, },
"@babel/traverse": { "@babel/traverse": {
"version": "7.5.5", "version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.2.tgz",
"integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==", "integrity": "sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.5.5", "@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.5.5", "@babel/generator": "^7.6.2",
"@babel/helper-function-name": "^7.1.0", "@babel/helper-function-name": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.4.4", "@babel/helper-split-export-declaration": "^7.4.4",
"@babel/parser": "^7.5.5", "@babel/parser": "^7.6.2",
"@babel/types": "^7.5.5", "@babel/types": "^7.6.0",
"debug": "^4.1.0", "debug": "^4.1.0",
"globals": "^11.1.0", "globals": "^11.1.0",
"lodash": "^4.17.13" "lodash": "^4.17.13"
@ -231,9 +230,9 @@
} }
}, },
"@babel/types": { "@babel/types": {
"version": "7.5.5", "version": "7.6.1",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz",
"integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==", "integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==",
"dev": true, "dev": true,
"requires": { "requires": {
"esutils": "^2.0.2", "esutils": "^2.0.2",
@ -473,9 +472,9 @@
} }
}, },
"@types/babel__generator": { "@types/babel__generator": {
"version": "7.0.2", "version": "7.6.0",
"resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.0.tgz",
"integrity": "sha512-NHcOfab3Zw4q5sEE2COkpfXjoE7o+PmqD9DQW4koUT3roNxwziUdXGnRndMat/LJNUtePwn1TlP4do3uoe3KZQ==", "integrity": "sha512-c1mZUu4up5cp9KROs/QAw0gTeHrw/x7m52LcnvMxxOZ03DmLwPV0MlGmlgzV3cnSdjhJOZsj7E7FHeioai+egw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/types": "^7.0.0" "@babel/types": "^7.0.0"
@ -541,9 +540,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.7.4", "version": "12.7.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.4.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.7.tgz",
"integrity": "sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ==", "integrity": "sha512-4jUncNe2tj1nmrO/34PsRpZqYVnRV1svbU78cKhuQKkMntKB/AmdLyGgswcZKjFHEHGpiY8pVD8CuVI55nP54w==",
"dev": true "dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
@ -568,15 +567,15 @@
} }
}, },
"@types/yargs-parser": { "@types/yargs-parser": {
"version": "13.0.0", "version": "13.1.0",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-13.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-13.1.0.tgz",
"integrity": "sha512-wBlsw+8n21e6eTd4yVv8YD/E3xq0O6nNnJIquutAsFGE7EyMKz7W6RNT6BRu1SmdgmlCZ9tb0X+j+D6HGr8pZw==", "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==",
"dev": true "dev": true
}, },
"abab": { "abab": {
"version": "2.0.1", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.1.tgz", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.2.tgz",
"integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw==", "integrity": "sha512-2scffjvioEmNz0OyDSLGWDfKCVwaKc6l9Pm9kOIREU13ClXZvHpg/nRL5xyjSSSLhOnXqft2HpsAzNEEA8cFFg==",
"dev": true "dev": true
}, },
"acorn": { "acorn": {
@ -586,9 +585,9 @@
"dev": true "dev": true
}, },
"acorn-globals": { "acorn-globals": {
"version": "4.3.3", "version": "4.3.4",
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.3.tgz", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.4.tgz",
"integrity": "sha512-vkR40VwS2SYO98AIeFvzWWh+xyc2qi9s7OoXSFEGIP/rOJKzjnhykaZJNnHdoq4BL2gGxI5EZOU16z896EYnOQ==", "integrity": "sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A==",
"dev": true, "dev": true,
"requires": { "requires": {
"acorn": "^6.0.1", "acorn": "^6.0.1",
@ -1353,9 +1352,9 @@
"dev": true "dev": true
}, },
"end-of-stream": { "end-of-stream": {
"version": "1.4.1", "version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"once": "^1.4.0" "once": "^1.4.0"
@ -1371,9 +1370,9 @@
} }
}, },
"es-abstract": { "es-abstract": {
"version": "1.14.1", "version": "1.14.2",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.1.tgz", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz",
"integrity": "sha512-cp/Tb1oA/rh2X7vqeSOvM+TSo3UkJLX70eNihgVEvnzwAgikjkTFr/QVgRCaxjm0knCNQzNoxxxcw2zO2LJdZA==", "integrity": "sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg==",
"dev": true, "dev": true,
"requires": { "requires": {
"es-to-primitive": "^1.2.0", "es-to-primitive": "^1.2.0",
@ -2343,9 +2342,9 @@
"dev": true "dev": true
}, },
"handlebars": { "handlebars": {
"version": "4.2.0", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.1.tgz",
"integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==", "integrity": "sha512-c0HoNHzDiHpBt4Kqe99N8tdLPKAnGCQ73gYMPWtAYM4PwGnf7xl8PBUHJqh9ijlzt2uQKaSRxbXRt+rZ7M2/kA==",
"dev": true, "dev": true,
"requires": { "requires": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
@ -3478,6 +3477,12 @@
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
"dev": true "dev": true
}, },
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
"integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=",
"dev": true
},
"lodash.sortby": { "lodash.sortby": {
"version": "4.7.0", "version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
@ -4117,9 +4122,9 @@
} }
}, },
"psl": { "psl": {
"version": "1.3.1", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.3.1.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-2KLd5fKOdAfShtY2d/8XDWVRnmp3zp40Qt6ge2zBPFARLXOGUf2fHD5eg+TV/5oxBtQKVhjUaKFsAaE4HnwfSA==", "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==",
"dev": true "dev": true
}, },
"pump": { "pump": {
@ -4778,23 +4783,23 @@
} }
}, },
"string.prototype.trimleft": { "string.prototype.trimleft": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.0.0.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz",
"integrity": "sha1-aLaqjhYsaoDnbjqKDC50cYbicf8=", "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-properties": "^1.1.2", "define-properties": "^1.1.3",
"function-bind": "^1.0.2" "function-bind": "^1.1.1"
} }
}, },
"string.prototype.trimright": { "string.prototype.trimright": {
"version": "2.0.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.0.0.tgz", "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz",
"integrity": "sha1-q0pW2AKgH75yk+EehPJNyBZGYd0=", "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-properties": "^1.1.2", "define-properties": "^1.1.3",
"function-bind": "^1.0.2" "function-bind": "^1.1.1"
} }
}, },
"strip-ansi": { "strip-ansi": {
@ -4924,22 +4929,17 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"trim-right": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz",
"integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
"dev": true
},
"ts-jest": { "ts-jest": {
"version": "24.0.2", "version": "24.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.2.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.1.0.tgz",
"integrity": "sha512-h6ZCZiA1EQgjczxq+uGLXQlNgeg02WWJBbeT8j6nyIBRQdglqbvzDoHahTEIiS6Eor6x8mK6PfZ7brQ9Q6tzHw==", "integrity": "sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bs-logger": "0.x", "bs-logger": "0.x",
"buffer-from": "1.x", "buffer-from": "1.x",
"fast-json-stable-stringify": "2.x", "fast-json-stable-stringify": "2.x",
"json5": "2.x", "json5": "2.x",
"lodash.memoize": "4.x",
"make-error": "1.x", "make-error": "1.x",
"mkdirp": "0.x", "mkdirp": "0.x",
"resolve": "1.x", "resolve": "1.x",
@ -5015,9 +5015,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "3.6.2", "version": "3.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
"integrity": "sha512-lmQ4L+J6mnu3xweP8+rOrUwzmN+MRAj7TgtJtDaXE5PMyX2kCrklhg3rvOsOIfNeAWMQWO2F1GPc1kMD2vLAfw==", "integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.3.4", "version": "1.3.5",
"private": false, "private": false,
"description": "Setup php action", "description": "Setup php action",
"main": "lib/setup-php.js", "main": "lib/setup-php.js",
@ -28,13 +28,13 @@
"typed-rest-client": "^1.5.0" "typed-rest-client": "^1.5.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^24.0.13", "@types/jest": "^24.0.18",
"@types/node": "^12.0.4", "@types/node": "^12.0.4",
"husky": "^2.3.0", "husky": "^2.3.0",
"jest": "^24.8.0", "jest": "^24.9.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.9.0",
"prettier": "^1.17.1", "prettier": "^1.17.1",
"ts-jest": "^24.0.2", "ts-jest": "^24.1.0",
"typescript": "^3.5.1" "typescript": "^3.5.1"
}, },
"husky": { "husky": {

View File

@ -2,24 +2,40 @@ import * as utils from './utils';
import * as pecl from './pecl'; import * as pecl from './pecl';
export async function addExtension( export async function addExtension(
extensions: string, extension_csv: string,
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
if (os_version === 'win32') { switch (os_version) {
return await addExtensionWindows(extensions, version); case 'win32':
} else if (os_version === 'linux') { return await addExtensionWindows(extension_csv, version);
return await addExtensionLinux(extensions, version); case 'darwin':
return await addExtensionDarwin(extension_csv, version);
case 'linux':
return await addExtensionLinux(extension_csv, version);
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
} }
return await addExtensionDarwin(extensions);
} }
export async function addINIValues(ini_values_csv: string, os_version: string) { export async function addINIValues(ini_values_csv: string, os_version: string) {
if (os_version === 'win32') { switch (os_version) {
case 'win32':
return await addINIValuesWindows(ini_values_csv); return await addINIValuesWindows(ini_values_csv);
} case 'darwin':
case 'linux':
return await addINIValuesUnix(ini_values_csv); return await addINIValuesUnix(ini_values_csv);
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
} }
/** /**
@ -28,14 +44,17 @@ export async function addINIValues(ini_values_csv: string, os_version: string) {
* @param extension * @param extension
*/ */
export async function enableExtensionWindows(extension: string) { export async function enableExtensionWindows(extension: string) {
return `try { return (
`try {
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll $exist = Test-Path -Path $ext_dir\\php_${extension}.dll
if(!(php -m | findstr -i ${extension}) -and $exist) { if(!(php -m | findstr -i ${extension}) -and $exist) {
Enable-PhpExtension ${extension} C:\\tools\\php Enable-PhpExtension ${extension} C:\\tools\\php\n` +
} (await utils.log(extension + ' enabled', 'win32', 'success')) +
} catch [Exception] { `}
echo $_ } catch [Exception] {\n` +
}\n`; (await utils.log(extension + ' could not be installed', 'win32', 'error')) +
` }\n`
);
} }
/** /**
@ -44,34 +63,58 @@ export async function enableExtensionWindows(extension: string) {
* @param extension * @param extension
*/ */
export async function enableExtensionUnix(extension: string) { export async function enableExtensionUnix(extension: string) {
return `if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then return (
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"' `if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
echo "${extension} enabled" echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
fi\n`; (await utils.log(extension + ' enabled', 'unix', 'success')) +
`; fi\n`
);
} }
/** /**
* Install and enable extensions for darwin * Install and enable extensions for darwin
* *
* @param extension_csv * @param extension_csv
* @param version
*/ */
export async function addExtensionDarwin( export async function addExtensionDarwin(
extension_csv: string extension_csv: string,
version: string
): Promise<string> { ): Promise<string> {
let extensions: Array<string> = await utils.extensionArray(extension_csv); let extensions: Array<string> = await utils.extensionArray(extension_csv);
let script: string = '\n'; let script: string = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += await enableExtensionUnix(extension); script += await enableExtensionUnix(extension);
if (await pecl.checkPECLExtension(extension)) { switch (await pecl.checkPECLExtension(extension)) {
case true:
extension =
version === '5.6' && extension === 'xdebug'
? 'xdebug-2.5.5'
: extension;
script += script +=
'if [ ! "$(php -m | grep ' + 'if [ ! "$(php -m | grep ' +
extension + extension +
')" ]; then sudo pecl install ' + ')" ]; then sudo pecl install ' +
extension + extension +
' || echo "Couldn\'t find extension: ' + ' || ' +
extension + (await utils.log(
'"; fi\n'; "Couldn't install extension: " + extension,
'darwin',
'error'
)) +
'; fi\n';
break;
case false:
default:
script +=
(await utils.log(
'Could not find extension: ' + extension,
'darwin',
'error'
)) + '\n';
break;
} }
}); });
return script; return script;
@ -90,13 +133,22 @@ export async function addExtensionWindows(
let extensions: Array<string> = await utils.extensionArray(extension_csv); let extensions: Array<string> = await utils.extensionArray(extension_csv);
let script: string = '\n'; let script: string = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += await enableExtensionWindows(extension); script += await enableExtensionWindows(extension);
let extension_version = 'stable'; let extension_version: string = '';
if (version == '7.4') { switch (version) {
case '7.4':
extension_version = 'alpha'; extension_version = 'alpha';
break;
case '7.2':
default:
extension_version = 'stable';
break;
} }
if (await pecl.checkPECLExtension(extension)) {
switch (await pecl.checkPECLExtension(extension)) {
case true:
script += script +=
'if(!(php -m | findstr -i ' + 'if(!(php -m | findstr -i ' +
extension + extension +
@ -105,9 +157,23 @@ export async function addExtensionWindows(
extension + extension +
' -MinimumStability ' + ' -MinimumStability ' +
extension_version + extension_version +
' } catch [Exception] { echo $_; echo "Could not install extension: "' + ' } catch [Exception] { ' +
extension + (await utils.log(
'Could not install extension: ' + extension,
'win32',
'error'
)) +
' } }\n'; ' } }\n';
break;
case false:
default:
script +=
(await utils.log(
'Could not find extension: ' + extension,
'win32',
'error'
)) + '\n';
break;
} }
}); });
return script; return script;
@ -126,6 +192,7 @@ export async function addExtensionLinux(
let extensions: Array<string> = await utils.extensionArray(extension_csv); let extensions: Array<string> = await utils.extensionArray(extension_csv);
let script: string = '\n'; let script: string = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
script += await enableExtensionUnix(extension); script += await enableExtensionUnix(extension);
script += script +=
@ -135,11 +202,13 @@ export async function addExtensionLinux(
version + version +
'-' + '-' +
extension + extension +
' || echo "Couldn\'t find extension php' + ' || ' +
version + (await utils.log(
'-' + "Couldn't find extension php" + version + '-' + extension,
extension + 'linux',
'"; fi\n'; 'error'
)) +
'; fi\n';
}); });
return script; return script;
} }
@ -177,3 +246,70 @@ export async function addINIValuesWindows(
}); });
return script; return script;
} }
export async function addCoverage(
coverage: string,
version: string,
os_version: string
): Promise<string> {
let script: string = '';
script += '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
case 'pcov':
// if version is 7.1 or newer
switch (version) {
default:
script += await addExtension(coverage, version, os_version);
script += await addINIValues('pcov.enabled=1', os_version);
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
script +=
"sudo phpdismod xdebug || echo 'xdebug not installed'\n";
script += "sudo phpenmod pcov || echo 'pcov not installed'\n";
break;
case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
break;
case 'win32':
script +=
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
break;
}
// success
script += await utils.log(
'pcov enabled as coverage driver',
os_version,
'success'
);
// version is not supported
break;
case '5.6':
case '7.0':
script += await utils.log(
'pcov requires php 7.1 or newer',
os_version,
'warning'
);
break;
}
break;
//xdebug
case 'xdebug':
script += await addExtension(coverage, version, os_version);
script += await utils.log(
'Xdebug enabled as coverage driver',
os_version,
'success'
);
break;
// unknown coverage driver
default:
script = '';
}
return script;
}

View File

@ -12,6 +12,7 @@ async function run() {
let version: string = await utils.getInput('php-version', true); let version: string = await utils.getInput('php-version', true);
let extension_csv: string = await utils.getInput('extension-csv', false); let extension_csv: string = await utils.getInput('extension-csv', false);
let ini_values_csv: string = await utils.getInput('ini-values-csv', false); let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
let coverage: string = await utils.getInput('coverage', false);
let os_version: string = process.platform; let os_version: string = process.platform;
// check the os version and run the respective script // check the os version and run the respective script
@ -23,6 +24,7 @@ async function run() {
); );
darwin += await features.addExtension(extension_csv, version, os_version); darwin += await features.addExtension(extension_csv, version, os_version);
darwin += await features.addINIValues(ini_values_csv, os_version); darwin += await features.addINIValues(ini_values_csv, os_version);
darwin += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('darwin.sh', version, darwin); await utils.writeScript('darwin.sh', version, darwin);
await exec('sh -x ./' + version + 'darwin.sh ' + version); await exec('sh -x ./' + version + 'darwin.sh ' + version);
} else if (os_version == 'win32') { } else if (os_version == 'win32') {
@ -37,6 +39,7 @@ async function run() {
os_version os_version
); );
windows += await features.addINIValues(ini_values_csv, os_version); windows += await features.addINIValues(ini_values_csv, os_version);
windows += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('win32.ps1', version, windows); await utils.writeScript('win32.ps1', version, windows);
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version); await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
} else if (os_version == 'linux') { } else if (os_version == 'linux') {
@ -47,6 +50,7 @@ async function run() {
); );
linux += await features.addExtension(extension_csv, version, os_version); linux += await features.addExtension(extension_csv, version, os_version);
linux += await features.addINIValues(ini_values_csv, os_version); linux += await features.addINIValues(ini_values_csv, os_version);
linux += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('linux.sh', version, linux); await utils.writeScript('linux.sh', version, linux);
await exec('./' + version + 'linux.sh ' + version); await exec('./' + version + 'linux.sh ' + version);
} }

View File

@ -7,12 +7,14 @@ export async function getInput(
mandatory: boolean mandatory: boolean
): Promise<string> { ): Promise<string> {
let input = process.env[name]; let input = process.env[name];
if (!input) { switch (input) {
input = core.getInput(name, {required: mandatory}); case '':
} case undefined:
return core.getInput(name, {required: mandatory});
default:
return input; return input;
} }
}
/** /**
* Async foreach loop * Async foreach loop
@ -42,10 +44,31 @@ export async function readScript(
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
if (version === '7.4' && os_version === 'darwin') { switch (os_version) {
case 'darwin':
switch (version) {
case '7.4':
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8'); return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
case '7.3':
default:
return fs.readFileSync(
path.join(__dirname, '../src/' + filename),
'utf8'
);
}
case 'win32':
case 'linux':
return fs.readFileSync(
path.join(__dirname, '../src/' + filename),
'utf8'
);
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
} }
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
} }
/** /**
@ -89,3 +112,31 @@ export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
return ini_value.trim(); return ini_value.trim();
}); });
} }
export async function log(
message: string,
os_version: string,
log_type: string
): Promise<string> {
switch (os_version) {
case 'win32':
const color: any = {
error: 'red',
success: 'green',
warning: 'yellow'
};
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
case 'linux':
case 'darwin':
default:
const unix_color: any = {
error: '31',
success: '32',
warning: '33'
};
return (
'echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
);
}
}