Fix side effects of this action

This commit is contained in:
Shivam Mathur
2019-10-27 05:42:49 +05:30
parent 16267e1982
commit 0d8d5d2f2c
26 changed files with 162 additions and 180 deletions

View File

@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const utils = __importStar(require("./utils"));
/**
* Install and enable extensions
@ -70,11 +71,15 @@ function addExtensionDarwin(extension_csv, version) {
switch (version + extension) {
case '7.4xdebug':
install_command =
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
'sh ' +
path.join(__dirname, '../src/scripts/xdebug_darwin.sh') +
' >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
break;
case '7.4pcov':
install_command =
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
'sh ' +
path.join(__dirname, '../src/scripts/pcov.sh') +
' >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
break;
case '5.6xdebug':
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
@ -156,19 +161,34 @@ function addExtensionLinux(extension_csv, version) {
switch (version + extension) {
case '7.4xdebug':
install_command =
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
'sh ' +
path.join(__dirname, '../src/scripts/xdebug.sh') +
' >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
break;
case '7.4pcov':
install_command =
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
'sh ' +
path.join(__dirname, '../src/scripts/pcov.sh') +
' >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
break;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = './phalcon.sh master ' + version + ' >/dev/null 2>&1';
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') +
' master ' +
version +
' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
install_command = './phalcon.sh 4.0.x ' + version + ' >/dev/null 2>&1';
case '7.4phalcon4':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') +
' 4.0.x ' +
version +
' >/dev/null 2>&1';
break;
default:
install_command =

View File

@ -18,10 +18,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const exec_1 = require("@actions/exec/lib/exec");
const core = __importStar(require("@actions/core"));
const utils = __importStar(require("./utils"));
const extensions = __importStar(require("./extensions"));
const config = __importStar(require("./config"));
const coverage = __importStar(require("./coverage"));
const extensions = __importStar(require("./extensions"));
const utils = __importStar(require("./utils"));
/**
* Build the script
*
@ -45,7 +45,7 @@ function build(filename, version, os_version) {
if (coverage_driver) {
script += yield coverage.addCoverage(coverage_driver, version, os_version);
}
yield utils.writeScript(filename, version, script);
return yield utils.writeScript(filename, script);
});
}
/**
@ -58,16 +58,16 @@ function run() {
let version = yield utils.getInput('php-version', true);
// check the os version and run the respective script
if (os_version == 'darwin') {
yield build('darwin.sh', version, os_version);
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
let script_path = yield build('darwin.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
}
else if (os_version == 'win32') {
yield build('win32.ps1', version, os_version);
yield exec_1.exec('pwsh .\\' + version + 'win32.ps1 -version ' + version);
let script_path = yield build('win32.ps1', version, os_version);
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname);
}
else if (os_version == 'linux') {
yield build('linux.sh', version, os_version);
yield exec_1.exec('./' + version + 'linux.sh ' + version);
let script_path = yield build('linux.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
}
}
catch (error) {

View File

@ -53,19 +53,6 @@ function asyncForEach(array, callback) {
});
}
exports.asyncForEach = asyncForEach;
/**
* Copy config
*
* @param files
*/
function moveFiles(files) {
return __awaiter(this, void 0, void 0, function* () {
yield asyncForEach(files, function (filename) {
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
});
});
}
exports.moveFiles = moveFiles;
/**
* Read the scripts
*
@ -79,34 +66,15 @@ function readScript(filename, version, os_version) {
case 'darwin':
switch (version) {
case '7.4':
yield moveFiles([
'configs/config.yaml',
'scripts/xdebug_darwin.sh',
'scripts/pcov.sh'
]);
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
}
break;
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
case 'linux':
let files = ['scripts/phalcon.sh'];
switch (version) {
case '7.4':
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
break;
}
yield moveFiles(files);
break;
case 'win32':
switch (version) {
case '7.4':
yield moveFiles(['ext/php_pcov.dll']);
break;
}
break;
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
});
}
exports.readScript = readScript;
@ -117,9 +85,12 @@ exports.readScript = readScript;
* @param version
* @param script
*/
function writeScript(filename, version, script) {
function writeScript(filename, script) {
return __awaiter(this, void 0, void 0, function* () {
fs.writeFileSync(version + filename, script, { mode: 0o755 });
let runner_dir = yield getInput('RUNNER_TOOL_CACHE', false);
let script_path = path.join(runner_dir, filename);
fs.writeFileSync(script_path, script, { mode: 0o755 });
return script_path;
});
}
exports.writeScript = writeScript;