diff --git a/__tests__/config.test.ts b/__tests__/config.test.ts index 15a510f8..97c23572 100644 --- a/__tests__/config.test.ts +++ b/__tests__/config.test.ts @@ -24,7 +24,7 @@ describe('Config tests', () => { true ); expect(linux).toContain( - 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" >> $ini_file' + 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"' ); linux = await config.addINIValues( @@ -40,7 +40,7 @@ describe('Config tests', () => { 'darwin' ); expect(darwin).toContain( - 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" >> $ini_file' + 'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"' ); darwin = await config.addINIValues( diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 6c77f56b..3850e779 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -47,16 +47,16 @@ describe('Extension tests', () => { ); linux = await extensions.addExtension('xdebug, pcov', '7.4', 'linux'); - expect(linux).toContain('./xdebug.sh'); - expect(linux).toContain('./pcov.sh'); + expect(linux).toContain('xdebug.sh'); + expect(linux).toContain('pcov.sh'); linux = await extensions.addExtension('phalcon3, phalcon4', '7.2', 'linux'); - expect(linux).toContain('./phalcon.sh master 7.2'); - expect(linux).toContain('./phalcon.sh 4.0.x 7.2'); + expect(linux).toContain('phalcon.sh master 7.2'); + expect(linux).toContain('phalcon.sh 4.0.x 7.2'); linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux'); - expect(linux).toContain('./phalcon.sh master 7.3'); - expect(linux).toContain('./phalcon.sh 4.0.x 7.3'); + expect(linux).toContain('phalcon.sh master 7.3'); + expect(linux).toContain('phalcon.sh 4.0.x 7.3'); linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); expect(linux).toContain('Platform fedora is not supported'); @@ -81,10 +81,10 @@ describe('Extension tests', () => { expect(darwin).toContain('sudo pecl install xdebug-2.5.5'); darwin = await extensions.addExtension('xdebug', '7.4', 'darwin'); - expect(darwin).toContain('sh ./xdebug_darwin.sh'); + expect(darwin).toContain('xdebug_darwin.sh'); darwin = await extensions.addExtension('pcov', '7.4', 'darwin'); - expect(darwin).toContain('sh ./pcov.sh'); + expect(darwin).toContain('pcov.sh'); darwin = await extensions.addExtension('xdebug', '7.2', 'darwin'); expect(darwin).toContain('sudo pecl install xdebug'); diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 9209d38e..4778f639 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -61,23 +61,17 @@ describe('Utils tests', () => { expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain( 'Platform fedora is not supported' ); - await cleanup('./config.yaml'); - await cleanup('./pcov.sh'); - await cleanup('./phalcon.sh'); - await cleanup('./php_pcov.dll'); - await cleanup('./xdebug_darwin.sh'); }); it('checking writeScripts', async () => { let testString: string = 'sudo apt-get install php'; - await utils.writeScript('test.sh', '10', testString); - await fs.readFile(path.join(__dirname, '../10test.sh'), function( - error: any, - data: Buffer - ) { + let runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; + let script_path: string = path.join(runner_dir, 'test.sh'); + await utils.writeScript('test.sh', testString); + await fs.readFile(script_path, function(error: any, data: Buffer) { expect(testString).toBe(data.toString()); }); - await cleanup('./10test.sh'); + await cleanup(script_path); }); it('checking extensionArray', async () => { diff --git a/lib/extensions.js b/lib/extensions.js index d56f0a47..d4516d1a 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -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 = diff --git a/lib/install.js b/lib/install.js index 8004fdad..cf850a5f 100644 --- a/lib/install.js +++ b/lib/install.js @@ -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) { diff --git a/lib/utils.js b/lib/utils.js index 4ba6f6a2..57a7e55f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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; diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json index 3522669e..a1fa7f22 100644 --- a/node_modules/@actions/core/package.json +++ b/node_modules/@actions/core/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/core@1.2.0", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "@actions/core@1.2.0", @@ -28,7 +28,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", "_spec": "1.2.0", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/node_modules/@actions/exec/package.json b/node_modules/@actions/exec/package.json index 88b076af..0ca3f17f 100644 --- a/node_modules/@actions/exec/package.json +++ b/node_modules/@actions/exec/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/exec@1.0.1", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "@actions/exec@1.0.1", @@ -27,7 +27,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz", "_spec": "1.0.1", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/node_modules/@actions/io/package.json b/node_modules/@actions/io/package.json index 503301d4..54b43c57 100644 --- a/node_modules/@actions/io/package.json +++ b/node_modules/@actions/io/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/io@1.0.1", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "@actions/io@1.0.1", @@ -27,7 +27,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz", "_spec": "1.0.1", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/node_modules/@actions/tool-cache/package.json b/node_modules/@actions/tool-cache/package.json index 44a99467..a784381d 100644 --- a/node_modules/@actions/tool-cache/package.json +++ b/node_modules/@actions/tool-cache/package.json @@ -2,7 +2,7 @@ "_args": [ [ "@actions/tool-cache@1.1.2", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "@actions/tool-cache@1.1.2", @@ -27,7 +27,7 @@ ], "_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.2.tgz", "_spec": "1.1.2", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bugs": { "url": "https://github.com/actions/toolkit/issues" }, diff --git a/node_modules/fs/package.json b/node_modules/fs/package.json index 35cb69ca..277e58e3 100644 --- a/node_modules/fs/package.json +++ b/node_modules/fs/package.json @@ -2,7 +2,7 @@ "_args": [ [ "fs@0.0.1-security", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "fs@0.0.1-security", @@ -26,7 +26,7 @@ ], "_resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", "_spec": "0.0.1-security", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "author": "", "bugs": { "url": "https://github.com/npm/security-holder/issues" diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index ad71e9c5..b68881d3 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -2,7 +2,7 @@ "_args": [ [ "semver@6.3.0", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "semver@6.3.0", @@ -28,7 +28,7 @@ ], "_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "_spec": "6.3.0", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bin": { "semver": "./bin/semver.js" }, diff --git a/node_modules/tunnel/package.json b/node_modules/tunnel/package.json index 67873a46..457e8df2 100644 --- a/node_modules/tunnel/package.json +++ b/node_modules/tunnel/package.json @@ -2,7 +2,7 @@ "_args": [ [ "tunnel@0.0.4", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "tunnel@0.0.4", @@ -26,7 +26,7 @@ ], "_resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", "_spec": "0.0.4", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "author": { "name": "Koichi Kobayashi", "email": "koichik@improvement.jp" diff --git a/node_modules/typed-rest-client/package.json b/node_modules/typed-rest-client/package.json index c502180e..87b6ddf5 100644 --- a/node_modules/typed-rest-client/package.json +++ b/node_modules/typed-rest-client/package.json @@ -2,7 +2,7 @@ "_args": [ [ "typed-rest-client@1.5.0", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "typed-rest-client@1.5.0", @@ -26,7 +26,7 @@ ], "_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.5.0.tgz", "_spec": "1.5.0", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "author": { "name": "Microsoft Corporation" }, diff --git a/node_modules/underscore/package.json b/node_modules/underscore/package.json index 2a597c34..5f2fc353 100644 --- a/node_modules/underscore/package.json +++ b/node_modules/underscore/package.json @@ -2,7 +2,7 @@ "_args": [ [ "underscore@1.8.3", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "underscore@1.8.3", @@ -26,7 +26,7 @@ ], "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", "_spec": "1.8.3", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "author": { "name": "Jeremy Ashkenas", "email": "jeremy@documentcloud.org" diff --git a/node_modules/uuid/package.json b/node_modules/uuid/package.json index 9f00d4b1..e041bfe6 100644 --- a/node_modules/uuid/package.json +++ b/node_modules/uuid/package.json @@ -2,7 +2,7 @@ "_args": [ [ "uuid@3.3.3", - "E:\\python\\setup-php" + "C:\\wamp64\\www\\setup-php" ] ], "_from": "uuid@3.3.3", @@ -27,7 +27,7 @@ ], "_resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", "_spec": "3.3.3", - "_where": "E:\\python\\setup-php", + "_where": "C:\\wamp64\\www\\setup-php", "bin": { "uuid": "./bin/uuid" }, diff --git a/src/extensions.ts b/src/extensions.ts index 032c3fbf..adfcab95 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -1,3 +1,4 @@ +import * as path from 'path'; import * as utils from './utils'; /** @@ -62,11 +63,15 @@ export async function addExtensionDarwin( 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'; @@ -149,19 +154,34 @@ export async function addExtensionLinux( 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 = diff --git a/src/install.ts b/src/install.ts index 4d90ca6e..9f50ca43 100644 --- a/src/install.ts +++ b/src/install.ts @@ -1,9 +1,10 @@ import {exec} from '@actions/exec/lib/exec'; import * as core from '@actions/core'; -import * as utils from './utils'; -import * as extensions from './extensions'; +import * as path from 'path'; import * as config from './config'; import * as coverage from './coverage'; +import * as extensions from './extensions'; +import * as utils from './utils'; /** * Build the script @@ -12,7 +13,11 @@ import * as coverage from './coverage'; * @param version * @param os_version */ -async function build(filename: string, version: string, os_version: string) { +async function build( + filename: string, + version: string, + os_version: string +): Promise { // taking inputs let extension_csv: string = await utils.getInput('extension-csv', false); let ini_values_csv: string = await utils.getInput('ini-values-csv', false); @@ -28,7 +33,8 @@ async function build(filename: string, version: string, os_version: string) { if (coverage_driver) { script += await coverage.addCoverage(coverage_driver, version, os_version); } - await utils.writeScript(filename, version, script); + + return await utils.writeScript(filename, script); } /** @@ -40,14 +46,16 @@ async function run() { let version: string = await utils.getInput('php-version', true); // check the os version and run the respective script if (os_version == 'darwin') { - await build('darwin.sh', version, os_version); - await exec('sh ./' + version + 'darwin.sh ' + version); + let script_path: string = await build('darwin.sh', version, os_version); + await exec('sh ' + script_path + ' ' + version + ' ' + __dirname); } else if (os_version == 'win32') { - await build('win32.ps1', version, os_version); - await exec('pwsh .\\' + version + 'win32.ps1 -version ' + version); + let script_path: string = await build('win32.ps1', version, os_version); + await exec( + 'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname + ); } else if (os_version == 'linux') { - await build('linux.sh', version, os_version); - await exec('./' + version + 'linux.sh ' + version); + let script_path: string = await build('linux.sh', version, os_version); + await exec('sh ' + script_path + ' ' + version + ' ' + __dirname); } } catch (error) { core.setFailed(error.message); diff --git a/src/scripts/7.4.sh b/src/scripts/7.4.sh index 77e2cb1d..3497f1e7 100644 --- a/src/scripts/7.4.sh +++ b/src/scripts/7.4.sh @@ -58,7 +58,7 @@ echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib /usr/local/opt/icu4c/lib/libicutu.dylib /usr/local/opt/icu4c/lib/libicuuc.dylib"' } >> ~/.bash_profile -config_file=$(pwd)/config.yaml +config_file=$2/../src/configs/config.yaml step_log "Setup PHPBrew" curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1 diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 7bd046fa..55b3e4a3 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -34,7 +34,7 @@ if [ "$existing_version" != "$1" ]; then for tool in php phar phar.phar php-cgi php-config phpize; do if [ -e "/usr/bin/$tool$1" ]; then - sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 & + sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 fi done fi diff --git a/src/scripts/pcov.sh b/src/scripts/pcov.sh index 5e021199..0837f5b3 100644 --- a/src/scripts/pcov.sh +++ b/src/scripts/pcov.sh @@ -1,7 +1,5 @@ -git clone --depth=1 https://github.com/krakjoe/pcov.git -( +cd ~ && git clone --depth=1 https://github.com/krakjoe/pcov.git cd pcov && phpize ./configure --enable-pcov make -sudo make install -) +sudo make install \ No newline at end of file diff --git a/src/scripts/phalcon.sh b/src/scripts/phalcon.sh index b1ef2c4b..073a8fa6 100644 --- a/src/scripts/phalcon.sh +++ b/src/scripts/phalcon.sh @@ -1,19 +1,21 @@ ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") -sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-dev php-pear -y +sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-dev -y for tool in php-config phpize; do if [ -e "/usr/bin/$tool$2" ]; then - sudo update-alternatives --set $tool /usr/bin/"$tool$2" & + sudo update-alternatives --set $tool /usr/bin/"$tool$2" fi done -sudo pecl config-set php_ini "$ini_file" -sudo pear config-set php_ini "$ini_file" -sudo pecl install psr + +cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git +cd php-psr && sudo /usr/bin/phpize"$2" +./configure --with-php-config=/usr/bin/php-config"$2" +make -j2 && sudo make -j2 install +echo "extension=psr.so" >> "$ini_file" + if [ "$1" = "master" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-phalcon -y else - git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1" - ( - cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2" - echo "extension=phalcon.so" >> "$ini_file" - ) + cd ~ && git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1" + cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2" + echo "extension=phalcon.so" >> "$ini_file" fi \ No newline at end of file diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 2e6535ff..cc6a1755 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -1,5 +1,6 @@ param ( - [Parameter(Mandatory=$true)][string]$version = "7.3" + [Parameter(Mandatory=$true)][string]$version = "7.3", + [Parameter(Mandatory=$true)][string]$dir ) $tick = ([char]8730) @@ -41,7 +42,7 @@ if($version -lt '7.4') { Enable-PhpExtension curl } else { Add-Content C:\tools\php\php.ini "extension=php_openssl.dll`nextension=php_curl.dll" - Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" + Copy-Item $dir"\..\src\ext\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" } Add-Log $tick "PHP" $status diff --git a/src/scripts/xdebug.sh b/src/scripts/xdebug.sh index 957db81d..4f040002 100644 --- a/src/scripts/xdebug.sh +++ b/src/scripts/xdebug.sh @@ -1,5 +1,3 @@ -git clone --depth=1 https://github.com/xdebug/xdebug.git -( - cd xdebug || echo "cd failed" - sudo ./rebuild.sh -) +cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git +cd xdebug || echo "Failed to clone Xdebug" +sudo ./rebuild.sh \ No newline at end of file diff --git a/src/scripts/xdebug_darwin.sh b/src/scripts/xdebug_darwin.sh index 730f5464..7e660af6 100644 --- a/src/scripts/xdebug_darwin.sh +++ b/src/scripts/xdebug_darwin.sh @@ -1,8 +1,6 @@ -git clone --depth=1 https://github.com/xdebug/xdebug.git -( - cd xdebug || echo "cd failed" - sudo phpize - sudo ./configure - sudo make - sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")" -) +cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git +cd xdebug || echo "Failed to clone Xdebug" +sudo phpize +sudo ./configure +sudo make +sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")" \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 05c0856c..e73d8111 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -38,19 +38,6 @@ export async function asyncForEach( } } -/** - * Copy config - * - * @param files - */ -export async function moveFiles(files: Array) { - await asyncForEach(files, function(filename: string) { - fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe( - fs.createWriteStream(filename.split('/')[1], {mode: 0o755}) - ); - }); -} - /** * Read the scripts * @@ -67,33 +54,21 @@ export async function readScript( case 'darwin': switch (version) { case '7.4': - await 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: Array = ['scripts/phalcon.sh']; - switch (version) { - case '7.4': - files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']); - break; - } - await moveFiles(files); - break; case 'win32': - switch (version) { - case '7.4': - await moveFiles(['ext/php_pcov.dll']); - break; - } - break; + return fs.readFileSync( + path.join(__dirname, '../src/scripts/' + filename), + 'utf8' + ); default: return await log( 'Platform ' + os_version + ' is not supported', @@ -101,11 +76,6 @@ export async function readScript( 'error' ); } - - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); } /** @@ -117,10 +87,12 @@ export async function readScript( */ export async function writeScript( filename: string, - version: string, script: string -): Promise { - fs.writeFileSync(version + filename, script, {mode: 0o755}); +): Promise { + let runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false); + let script_path: string = path.join(runner_dir, filename); + fs.writeFileSync(script_path, script, {mode: 0o755}); + return script_path; } /**