From 91bd6b26c271cc30f882588631e6af5a391c384a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 4 Aug 2020 20:47:30 +0530 Subject: [PATCH 1/8] Use cached composer builds --- __tests__/tools.test.ts | 14 +++++++------- dist/index.js | 9 ++++++--- src/scripts/darwin.sh | 8 +++++++- src/scripts/linux.sh | 8 +++++++- src/scripts/win32.ps1 | 3 +-- src/tools.ts | 10 +++++++--- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index a81e6bc8..abbdb424 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -424,7 +424,7 @@ describe('Tools tests', () => { 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player' ); expect(script).toContain( - 'add_tool https://getcomposer.org/composer-stable.phar composer' + 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' @@ -499,7 +499,7 @@ describe('Tools tests', () => { 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player' ); expect(script).toContain( - 'add_tool https://getcomposer.org/composer-stable.phar composer' + 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize' @@ -590,7 +590,7 @@ describe('Tools tests', () => { 'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player' ); expect(script).toContain( - 'Add-Tool https://getcomposer.org/composer-stable.phar composer' + 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain( 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' @@ -631,7 +631,7 @@ describe('Tools tests', () => { ); expect(script).toContain( - 'Add-Tool https://getcomposer.org/composer-stable.phar composer' + 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' ); expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/'); expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); @@ -649,12 +649,12 @@ describe('Tools tests', () => { ); expect(script).toContain( - 'add_tool https://getcomposer.org/composer-1.phar composer' + 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer' ); script = await tools.addTools('composer:preview', '7.4', 'linux'); expect(script).toContain( - 'add_tool https://getcomposer.org/composer-preview.phar composer' + 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer' ); script = await tools.addTools( 'composer:v1, composer:preview, composer:snapshot', @@ -662,7 +662,7 @@ describe('Tools tests', () => { 'linux' ); expect(script).toContain( - 'add_tool https://getcomposer.org/composer.phar composer' + 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer' ); }); }); diff --git a/dist/index.js b/dist/index.js index 99b81b43..c57be4e1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2229,21 +2229,24 @@ exports.addComposer = addComposer; * @param version */ async function getComposerUrl(version) { + const cache_url = 'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + + version.replace('latest', 'stable') + + '.phar,'; const getComposerUrlHelper = async function (version) { const client = new httpm.HttpClient('setup-php'); const response = await client.get('https://getcomposer.org/versions'); const data = JSON.parse(await response.readBody()); - return 'https://getcomposer.org' + data[version][0]['path']; + return cache_url + 'https://getcomposer.org' + data[version][0]['path']; }; switch (version) { case 'snapshot': - return 'https://getcomposer.org/composer.phar'; + return cache_url + 'https://getcomposer.org/composer.phar'; case 'preview': case '1': case '2': return await getComposerUrlHelper(version); default: - return 'https://getcomposer.org/composer-stable.phar'; + return cache_url + 'https://getcomposer.org/composer-stable.phar'; } } exports.getComposerUrl = getComposerUrl; diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index e27c4d59..e95fb321 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -167,7 +167,13 @@ add_tool() { rm -rf "$tool_path" fi - status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url") + if [ "$tool" = "composer" ]; then + IFS="," read -r -a urls <<< "$url" + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") || + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}") + else + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url") + fi if [ "$status_code" = "200" ]; then sudo chmod a+x "$tool_path" if [ "$tool" = "composer" ]; then diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index adcf9f23..f12e06dc 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -261,7 +261,13 @@ add_tool() { if [ ! -e "$tool_path" ]; then rm -rf "$tool_path" fi - status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url") + if [ "$tool" = "composer" ]; then + IFS="," read -r -a urls <<< "$url" + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") || + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}") + else + status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url") + fi if [ "$status_code" = "200" ]; then sudo chmod a+x "$tool_path" if [ "$tool" = "composer" ]; then diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 9731dcbc..8b5509ee 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -187,8 +187,6 @@ Function Add-Tool() { Param ( [Parameter(Position = 0, Mandatory = $true)] [ValidateNotNull()] - [ValidateLength(1, [int]::MaxValue)] - [string] $url, [Parameter(Position = 1, Mandatory = $true)] [ValidateNotNull()] @@ -199,6 +197,7 @@ Function Add-Tool() { if (Test-Path $bin_dir\$tool) { Remove-Item $bin_dir\$tool } + if($url.Count -gt 1) { $url = $url[0] } if ($tool -eq "symfony") { Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool.exe Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.exe" >$null 2>&1 diff --git a/src/tools.ts b/src/tools.ts index 50677a05..ba6ec43c 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -329,23 +329,27 @@ export async function addComposer(tools_list: string[]): Promise { * @param version */ export async function getComposerUrl(version: string): Promise { + const cache_url = + 'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + + version.replace('latest', 'stable') + + '.phar,'; const getComposerUrlHelper = async function ( version: string ): Promise { const client: httpm.HttpClient = new httpm.HttpClient('setup-php'); const response: hcr = await client.get('https://getcomposer.org/versions'); const data = JSON.parse(await response.readBody()); - return 'https://getcomposer.org' + data[version][0]['path']; + return cache_url + 'https://getcomposer.org' + data[version][0]['path']; }; switch (version) { case 'snapshot': - return 'https://getcomposer.org/composer.phar'; + return cache_url + 'https://getcomposer.org/composer.phar'; case 'preview': case '1': case '2': return await getComposerUrlHelper(version); default: - return 'https://getcomposer.org/composer-stable.phar'; + return cache_url + 'https://getcomposer.org/composer-stable.phar'; } } From 15a6402865ae9c48750c641d97a3b5c84c140a83 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 4 Aug 2020 21:16:48 +0530 Subject: [PATCH 2/8] Change cURL opts --- src/scripts/darwin.sh | 2 +- src/scripts/linux.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index e95fb321..2e4f1cd4 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -241,7 +241,7 @@ version=$1 nodot_version=${1/./} old_versions="5.[3-5]" tool_path_dir="/usr/local/bin" -curl_opts=(-sSL --retry 5 --retry-delay 1) +curl_opts=(-sL) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) read_env diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index f12e06dc..e9cd3c72 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -398,7 +398,7 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive" github="https://github.com/shivammathur" apt_install="sudo $debconf_fix apt-fast install -y" tool_path_dir="/usr/local/bin" -curl_opts=(-sSL --retry 5 --retry-delay 1) +curl_opts=(-sL) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) read_env From f8b8d766d5dfdf514ac19bbe60772cbdc0b78af4 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 4 Aug 2020 21:37:52 +0530 Subject: [PATCH 3/8] Fix permissions in protoc setup --- src/scripts/tools/protoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/tools/protoc.sh b/src/scripts/tools/protoc.sh index 545077e6..c604d62d 100644 --- a/src/scripts/tools/protoc.sh +++ b/src/scripts/tools/protoc.sh @@ -19,7 +19,7 @@ add_protoc() { [ "$(uname -s)" = "Darwin" ] && platform='osx' curl -o /tmp/protobuf.zip "${curl_opts[@]:?}" "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip" sudo unzip /tmp/protobuf.zip -d /usr/local/ - sudo chmod a+x /usr/local/bin/protoc + sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google ) >/dev/null 2>&1 add_log "${tick:?}" "protoc" "Added" printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" From 188598ef9d05a71b7f7bcf6deda2579d845fba67 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 6 Aug 2020 15:33:58 +0530 Subject: [PATCH 4/8] Dry custom tools and extension code --- __tests__/extensions.test.ts | 4 +- __tests__/tools.test.ts | 20 ----- __tests__/utils.test.ts | 22 +++++ dist/index.js | 153 ++++++++++++++--------------------- src/extensions.ts | 110 +++++++------------------ src/scripts/ext/oci.ps1 | 2 +- src/tools.ts | 59 ++------------ src/utils.ts | 49 +++++++++++ 8 files changed, 171 insertions(+), 248 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index b5fc8c60..9401795d 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -13,8 +13,8 @@ describe('Extension tests', () => { expect(win32).toContain('Remove-Extension intl'); expect(win32).toContain('Add-Phalcon phalcon4'); expect(win32).toContain('Add-Ioncube'); - expect(win32).toContain('Add-OCI oci8'); - expect(win32).toContain('Add-OCI pdo_oci'); + expect(win32).toContain('Add-Oci oci8'); + expect(win32).toContain('Add-Oci pdo_oci'); expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index abbdb424..1cf9d807 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -17,15 +17,6 @@ httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => { }); describe('Tools tests', () => { - it('checking getCommand', async () => { - expect(await tools.getCommand('linux', 'tool')).toBe('add_tool '); - expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool '); - expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool '); - expect(await tools.getCommand('fedora', 'tool')).toContain( - 'Platform fedora is not supported' - ); - }); - it('checking parseToolVersion', async () => { expect(await tools.getToolVersion('latest')).toBe('latest'); expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3'); @@ -402,17 +393,6 @@ describe('Tools tests', () => { expect(script).toContain('Platform fedora is not supported'); }); - it('checking addCustomTool', async () => { - let script: string = await tools.addCustomTool('tool', '1.2.3', 'linux'); - expect(script).toContain('tool.sh\nadd_tool 1.2.3'); - - script = await tools.addCustomTool('tool', '1.2.3', 'darwin'); - expect(script).toContain('tool.sh\nadd_tool 1.2.3'); - - script = await tools.addCustomTool('tool', '1.2.3', 'win32'); - expect(script).toContain('tool.ps1\nAdd-Tool 1.2.3'); - }); - it('checking addTools on linux', async () => { const script: string = await tools.addTools( 'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli', diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index d137f9b5..79f04a41 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -174,6 +174,15 @@ describe('Utils tests', () => { ); }); + it('checking getCommand', async () => { + expect(await utils.getCommand('linux', 'tool')).toBe('add_tool '); + expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool '); + expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool '); + expect(await utils.getCommand('fedora', 'tool')).toContain( + 'Platform fedora is not supported' + ); + }); + it('checking joins', async () => { expect(await utils.joins('a', 'b', 'c')).toBe('a b c'); }); @@ -186,4 +195,17 @@ describe('Utils tests', () => { 'Platform fedora is not supported' ); }); + + it('checking customPackage', async () => { + const script_path: string = path.join('ext', 'pkg.sh'); + expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain( + script_path + '\nadd_pkg 1.2.3' + ); + expect( + await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux') + ).toContain(script_path + '\nadd_pkg 1.2.3'); + expect( + await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux') + ).toContain(script_path + '\nadd_pkg 1.2.3'); + }); }); diff --git a/dist/index.js b/dist/index.js index c57be4e1..84628966 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1314,7 +1314,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.scriptExtension = exports.joins = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0; +exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0; const fs = __importStar(__webpack_require__(747)); const path = __importStar(__webpack_require__(622)); const core = __importStar(__webpack_require__(470)); @@ -1542,6 +1542,24 @@ async function getUnsupportedLog(extension, version, os_version) { '\n'); } exports.getUnsupportedLog = getUnsupportedLog; +/** + * Function to get command to setup tools + * + * @param os_version + * @param suffix + */ +async function getCommand(os_version, suffix) { + switch (os_version) { + case 'linux': + case 'darwin': + return 'add_' + suffix + ' '; + case 'win32': + return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; + default: + return await log('Platform ' + os_version + ' is not supported', os_version, 'error'); + } +} +exports.getCommand = getCommand; /** * Function to join strings with space * @@ -1568,6 +1586,22 @@ async function scriptExtension(os_version) { } } exports.scriptExtension = scriptExtension; +/** + * Function to get script to add tools with custom support. + * + * @param pkg + * @param type + * @param version + * @param os_version + */ +async function customPackage(pkg, type, version, os_version) { + const pkg_name = pkg.replace(/\d+|pdo[_-]/, ''); + const script_extension = await scriptExtension(os_version); + const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension); + const command = await getCommand(os_version, pkg_name); + return '\n. ' + script + '\n' + command + version; +} +exports.customPackage = customPackage; /***/ }), @@ -1947,28 +1981,9 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.addTools = exports.addCustomTool = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = exports.getCommand = void 0; +exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0; const utils = __importStar(__webpack_require__(163)); const httpm = __importStar(__webpack_require__(539)); -const path = __importStar(__webpack_require__(622)); -/** - * Function to get command to setup tools - * - * @param os_version - * @param suffix - */ -async function getCommand(os_version, suffix) { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_' + suffix + ' '; - case 'win32': - return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; - default: - return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); - } -} -exports.getCommand = getCommand; /** * Function to get tool version * @@ -2116,10 +2131,10 @@ exports.getCodeceptionUri = getCodeceptionUri; async function addPhive(version, os_version) { switch (version) { case 'latest': - return ((await getCommand(os_version, 'tool')) + + return ((await utils.getCommand(os_version, 'tool')) + 'https://phar.io/releases/phive.phar phive'); default: - return ((await getCommand(os_version, 'tool')) + + return ((await utils.getCommand(os_version, 'tool')) + 'https://github.com/phar-io/phive/releases/download/' + version + '/phive-' + @@ -2277,7 +2292,7 @@ exports.getCleanedToolsList = getCleanedToolsList; * @param os_version */ async function addArchive(tool, version, url, os_version) { - return (await getCommand(os_version, 'tool')) + url + ' ' + tool; + return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; } exports.addArchive = addArchive; /** @@ -2310,24 +2325,10 @@ exports.addDevTools = addDevTools; * @param os_version */ async function addPackage(tool, release, prefix, os_version) { - const tool_command = await getCommand(os_version, 'composertool'); + const tool_command = await utils.getCommand(os_version, 'composertool'); return tool_command + tool + ' ' + release + ' ' + prefix; } exports.addPackage = addPackage; -/** - * Function to get script to add tools with custom support. - * - * @param tool - * @param version - * @param os_version - */ -async function addCustomTool(tool, version, os_version) { - const script_extension = await utils.scriptExtension(os_version); - const script = path.join(__dirname, '../src/scripts/tools/' + tool + script_extension); - const command = await getCommand(os_version, tool); - return '. ' + script + '\n' + command + version; -} -exports.addCustomTool = addCustomTool; /** * Setup tools * @@ -2350,7 +2351,7 @@ async function addTools(tools_csv, php_version, os_version) { case 'blackfire': case 'grpc_php_plugin': case 'protoc': - script += await addCustomTool(tool, version, os_version); + script += await utils.customPackage(tool, 'tools', version, os_version); break; case 'blackfire-player': url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); @@ -2401,7 +2402,7 @@ async function addTools(tools_csv, php_version, os_version) { script += await addArchive(tool, version, url, os_version); break; case 'pecl': - script += await getCommand(os_version, 'pecl'); + script += await utils.getCommand(os_version, 'pecl'); break; case 'phan': url = github + 'phan/phan/' + uri; @@ -3628,22 +3629,8 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = exports.customExtension = void 0; -const path = __importStar(__webpack_require__(622)); +exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0; const utils = __importStar(__webpack_require__(163)); -/** - * Function to get script to install custom extensions - * - * @param script - * @param command - */ -async function customExtension(script, ...command) { - return ('\n. ' + - path.join(__dirname, '../src/scripts/ext/' + script) + - '\n' + - (await utils.joins(...command))); -} -exports.customExtension = customExtension; /** * Install and enable extensions for darwin * @@ -3668,20 +3655,14 @@ async function addExtensionDarwin(extension_csv, version, pipe) { return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 - case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): - add_script += await customExtension('blackfire.sh', 'add_blackfire', extension); - return; // match pdo_oci and oci8 - case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.sh', 'add_oci', extension); - return; // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube - case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.sh', 'add_ioncube'); - return; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 + case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): + case /^pdo_oci$|^oci8$/.test(extension): + case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension('phalcon.sh', 'add_phalcon', extension); + add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin'); return; // match pre-release versions. For example - xdebug-beta case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): @@ -3744,23 +3725,17 @@ async function addExtensionWindows(extension_csv, version) { case /^:/.test(ext_name): remove_script += '\nRemove-Extension ' + ext_name.slice(1); break; - // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire - // match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 - case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): - add_script += await customExtension('blackfire.ps1', 'Add-Blackfire', extension); - break; + // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire + // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match pdo_oci and oci8 - case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.ps1', 'Add-OCI', extension); - break; // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube - case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.ps1', 'Add-Ioncube'); - break; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 + case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): + case /^pdo_oci$|^oci8$/.test(extension): + case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension('phalcon.ps1', 'Add-Phalcon', extension); - break; + add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32'); + return; // match pre-release versions. For example - xdebug-beta case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version); @@ -3827,25 +3802,17 @@ async function addExtensionLinux(extension_csv, version, pipe) { remove_script += '\nremove_extension ' + ext_name.slice(1); return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire - // match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver} - case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): - add_script += await customExtension('blackfire.sh', 'add_blackfire', extension); - return; + // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match pdo_oci and oci8 - case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.sh', 'add_oci', extension); - return; // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube - case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.sh', 'add_ioncube'); - return; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 - case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension('phalcon.sh', 'add_phalcon', extension); - return; // match 5.6gearman..7.4gearman + case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): + case /^pdo_oci$|^oci8$/.test(extension): + case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): + case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): - add_script += await customExtension('gearman.sh', 'add_gearman'); + add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux'); return; // match pre-release versions. For example - xdebug-beta case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): diff --git a/src/extensions.ts b/src/extensions.ts index 4870ee60..49c26070 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -1,24 +1,5 @@ -import * as path from 'path'; import * as utils from './utils'; -/** - * Function to get script to install custom extensions - * - * @param script - * @param command - */ -export async function customExtension( - script: string, - ...command: string[] -): Promise { - return ( - '\n. ' + - path.join(__dirname, '../src/scripts/ext/' + script) + - '\n' + - (await utils.joins(...command)) - ); -} - /** * Install and enable extensions for darwin * @@ -47,29 +28,20 @@ export async function addExtensionDarwin( return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match pdo_oci and oci8 + // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube + // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( version_extension ): - add_script += await customExtension( - 'blackfire.sh', - 'add_blackfire', - extension - ); - return; - // match pdo_oci and oci8 case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.sh', 'add_oci', extension); - return; - // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.sh', 'add_ioncube'); - return; - // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension( - 'phalcon.sh', - 'add_phalcon', - extension + add_script += await utils.customPackage( + ext_name, + 'ext', + extension, + 'darwin' ); return; // match pre-release versions. For example - xdebug-beta @@ -154,33 +126,24 @@ export async function addExtensionWindows( case /^:/.test(ext_name): remove_script += '\nRemove-Extension ' + ext_name.slice(1); break; - // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire - // match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 - case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( + // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire + // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match pdo_oci and oci8 + // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube + // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 + case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( version_extension ): - add_script += await customExtension( - 'blackfire.ps1', - 'Add-Blackfire', - extension - ); - break; - // match pdo_oci and oci8 case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.ps1', 'Add-OCI', extension); - break; - // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.ps1', 'Add-Ioncube'); - break; - // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension( - 'phalcon.ps1', - 'Add-Phalcon', - extension + add_script += await utils.customPackage( + ext_name, + 'ext', + extension, + 'win32' ); - break; + return; // match pre-release versions. For example - xdebug-beta case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): add_script += await utils.joins( @@ -269,35 +232,24 @@ export async function addExtensionLinux( remove_script += '\nremove_extension ' + ext_name.slice(1); return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire - // match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver} + // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match pdo_oci and oci8 + // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube + // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 + // match 5.6gearman..7.4gearman case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( version_extension ): - add_script += await customExtension( - 'blackfire.sh', - 'add_blackfire', - extension - ); - return; - // match pdo_oci and oci8 case /^pdo_oci$|^oci8$/.test(extension): - add_script += await customExtension('oci.sh', 'add_oci', extension); - return; - // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): - add_script += await customExtension('ioncube.sh', 'add_ioncube'); - return; - // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - add_script += await customExtension( - 'phalcon.sh', - 'add_phalcon', - extension - ); - return; - // match 5.6gearman..7.4gearman case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): - add_script += await customExtension('gearman.sh', 'add_gearman'); + add_script += await utils.customPackage( + ext_name, + 'ext', + extension, + 'linux' + ); return; // match pre-release versions. For example - xdebug-beta case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): diff --git a/src/scripts/ext/oci.ps1 b/src/scripts/ext/oci.ps1 index 525bdccb..a2e6c404 100644 --- a/src/scripts/ext/oci.ps1 +++ b/src/scripts/ext/oci.ps1 @@ -21,7 +21,7 @@ Function Add-InstantClient() { } # Function to install oci8 and pdo_oci. -Function Add-OCI() { +Function Add-Oci() { Param ( [Parameter(Position = 0, Mandatory = $true)] [ValidateNotNull()] diff --git a/src/tools.ts b/src/tools.ts index ba6ec43c..7471405b 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -1,32 +1,6 @@ import * as utils from './utils'; import * as httpm from '@actions/http-client'; import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces'; -import * as path from 'path'; - -/** - * Function to get command to setup tools - * - * @param os_version - * @param suffix - */ -export async function getCommand( - os_version: string, - suffix: string -): Promise { - switch (os_version) { - case 'linux': - case 'darwin': - return 'add_' + suffix + ' '; - case 'win32': - return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; - default: - return await utils.log( - 'Platform ' + os_version + ' is not supported', - os_version, - 'error' - ); - } -} /** * Function to get tool version @@ -194,12 +168,12 @@ export async function addPhive( switch (version) { case 'latest': return ( - (await getCommand(os_version, 'tool')) + + (await utils.getCommand(os_version, 'tool')) + 'https://phar.io/releases/phive.phar phive' ); default: return ( - (await getCommand(os_version, 'tool')) + + (await utils.getCommand(os_version, 'tool')) + 'https://github.com/phar-io/phive/releases/download/' + version + '/phive-' + @@ -390,7 +364,7 @@ export async function addArchive( url: string, os_version: string ): Promise { - return (await getCommand(os_version, 'tool')) + url + ' ' + tool; + return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; } /** @@ -442,31 +416,10 @@ export async function addPackage( prefix: string, os_version: string ): Promise { - const tool_command = await getCommand(os_version, 'composertool'); + const tool_command = await utils.getCommand(os_version, 'composertool'); return tool_command + tool + ' ' + release + ' ' + prefix; } -/** - * Function to get script to add tools with custom support. - * - * @param tool - * @param version - * @param os_version - */ -export async function addCustomTool( - tool: string, - version: string, - os_version: string -): Promise { - const script_extension: string = await utils.scriptExtension(os_version); - const script: string = path.join( - __dirname, - '../src/scripts/tools/' + tool + script_extension - ); - const command: string = await getCommand(os_version, tool); - return '. ' + script + '\n' + command + version; -} - /** * Setup tools * @@ -500,7 +453,7 @@ export async function addTools( case 'blackfire': case 'grpc_php_plugin': case 'protoc': - script += await addCustomTool(tool, version, os_version); + script += await utils.customPackage(tool, 'tools', version, os_version); break; case 'blackfire-player': url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); @@ -556,7 +509,7 @@ export async function addTools( script += await addArchive(tool, version, url, os_version); break; case 'pecl': - script += await getCommand(os_version, 'pecl'); + script += await utils.getCommand(os_version, 'pecl'); break; case 'phan': url = github + 'phan/phan/' + uri; diff --git a/src/utils.ts b/src/utils.ts index 20c37350..109e9217 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -284,6 +284,31 @@ export async function getUnsupportedLog( ); } +/** + * Function to get command to setup tools + * + * @param os_version + * @param suffix + */ +export async function getCommand( + os_version: string, + suffix: string +): Promise { + switch (os_version) { + case 'linux': + case 'darwin': + return 'add_' + suffix + ' '; + case 'win32': + return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' '; + default: + return await log( + 'Platform ' + os_version + ' is not supported', + os_version, + 'error' + ); + } +} + /** * Function to join strings with space * @@ -313,3 +338,27 @@ export async function scriptExtension(os_version: string): Promise { ); } } + +/** + * Function to get script to add tools with custom support. + * + * @param pkg + * @param type + * @param version + * @param os_version + */ +export async function customPackage( + pkg: string, + type: string, + version: string, + os_version: string +): Promise { + const pkg_name: string = pkg.replace(/\d+|pdo[_-]/, ''); + const script_extension: string = await scriptExtension(os_version); + const script: string = path.join( + __dirname, + '../src/scripts/' + type + '/' + pkg_name + script_extension + ); + const command: string = await getCommand(os_version, pkg_name); + return '\n. ' + script + '\n' + command + version; +} From 3c52e818b1658cb00ccae0351f24b02089f15c34 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sat, 8 Aug 2020 19:02:17 +0530 Subject: [PATCH 5/8] Add support for cubrid and pdo_cubrid on Ubuntu --- __tests__/extensions.test.ts | 5 ++++ dist/index.js | 2 ++ src/extensions.ts | 4 +++ src/scripts/ext/cubrid.sh | 50 ++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 src/scripts/ext/cubrid.sh diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 9401795d..740928a1 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -95,6 +95,11 @@ describe('Extension tests', () => { linux = await extensions.addExtension('gearman', '7.4', 'linux'); expect(linux).toContain('add_gearman'); + linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux'); + expect(linux).toContain('add_cubrid pdo_cubrid'); + linux = await extensions.addExtension('cubrid', '7.4', 'linux'); + expect(linux).toContain('add_cubrid cubrid'); + linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); expect(linux).toContain('Platform fedora is not supported'); diff --git a/dist/index.js b/dist/index.js index 84628966..e017e9a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3803,11 +3803,13 @@ async function addExtensionLinux(extension_csv, version, pipe) { return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 5.6gearman..7.4gearman case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): + case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^pdo_oci$|^oci8$/.test(extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): diff --git a/src/extensions.ts b/src/extensions.ts index 49c26070..cb6ec11a 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -233,6 +233,7 @@ export async function addExtensionLinux( return; // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 + // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match pdo_oci and oci8 // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 @@ -240,6 +241,9 @@ export async function addExtensionLinux( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( version_extension ): + case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test( + version_extension + ): case /^pdo_oci$|^oci8$/.test(extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): diff --git a/src/scripts/ext/cubrid.sh b/src/scripts/ext/cubrid.sh new file mode 100644 index 00000000..b49c7f09 --- /dev/null +++ b/src/scripts/ext/cubrid.sh @@ -0,0 +1,50 @@ +# Function to log license details. +add_license_log() { + printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" + printf "Cubrid CCI package is required for %s extension.\n" "$ext" + printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext" + printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING" + echo "::endgroup::" +} + +# Function to set cubrid repo for the extension. +set_cubrid_repo() { + case "${ext:?}" in + "cubrid") cubrid_repo="cubrid-php";; + "pdo_cubrid") cubrid_repo="cubrid-pdo";; + esac +} + +# Function to set cubrid branch for a PHP version. +set_cubrid_branch() { + case "${version:?}" in + 5.[3-6]) cubrid_branch="RB-9.3.0";; + *) cubrid_branch="develop";; + esac +} + +add_cubrid_helper() { + if ! [ -e "${ext_dir:?}/$ext.so" ]; then + status='Installed and enabled' + set_cubrid_repo + set_cubrid_branch + ( + git clone -b "$cubrid_branch" --recursive "https://github.com/CUBRID/$cubrid_repo" "/tmp/$cubrid_repo" + cd "/tmp/$cubrid_repo" || exit + ! [[ "$version" =~ ${old_versions:?} ]] && add_devtools + phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared + make -j"$(nproc)" + sudo make install + ) + echo "extension=$ext.so" | sudo tee "${scan_dir:?}/$ext.ini" + fi +} + +# Function to add cubrid and pdo_cubrid. +add_cubrid() { + ext=$1 + status='Enabled' + add_cubrid_helper >/dev/null 2>&1 + add_extension_log "$ext" "$status" + check_extension "$ext" && add_license_log +} \ No newline at end of file From d84365cd0365cc7aa6ce5dd7fd80c37ce178e562 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 10 Aug 2020 00:32:30 +0530 Subject: [PATCH 6/8] Add support for oci extensions in PHP 8 on Windows Fix cache support for oci8 on Windows --- src/scripts/ext/oci.ps1 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scripts/ext/oci.ps1 b/src/scripts/ext/oci.ps1 index a2e6c404..b5e3ab50 100644 --- a/src/scripts/ext/oci.ps1 +++ b/src/scripts/ext/oci.ps1 @@ -35,16 +35,19 @@ Function Add-Oci() { if ($extension -eq "pdo_oci") { Enable-PhpExtension pdo_oci -Path $php_dir } else { - $status = 'Installed and enabled' - $ociVersion = '2.2.0' - if ($version -eq '7.0') { - $ociVersion = '2.1.8' - } elseif ($version -lt '7.0') { - $ociVersion = '2.0.12' + if(-not(Test-Path $ext_dir\php_oci8.dll)) { + $status = 'Installed and enabled' + $ociVersion = '2.2.0' + if ($version -eq '7.0') { + $ociVersion = '2.1.8' + } elseif ($version -lt '7.0') { + $ociVersion = '2.0.12' + } + $ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed + Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip + Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force + } - $ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed - Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip - Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini } Add-Log $tick $extension $status From c256f0c9cb2bc2e8cb0edd76bd9baaf238b47e5c Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 10 Aug 2020 13:43:18 +0530 Subject: [PATCH 7/8] Update README --- README.md | 70 ++++++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index da71b113..cd1fb75c 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ with: - Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. -- These extensions have custom support - `gearman` on `Ubuntu`, `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS. +- These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS. ## :wrench: Tools Support @@ -178,7 +178,7 @@ with: ``` **Notes** -- Both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. +- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. - Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted. ## :signal_strength: Coverage Support @@ -455,45 +455,8 @@ To debug any issues, you can use the `verbose` tag instead of `v2`. ### Cache Extensions -You can cache PHP extensions using [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") and [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time. - -```yaml -runs-on: ${{ matrix.operating-system }} -strategy: - matrix: - operating-system: [ubuntu-latest, windows-latest, macos-latest] - php-versions: ['7.2', '7.3', '7.4'] -name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} -env: - extensions: intl, pcov - key: cache-v1 # can be any string, change to clear the extension cache. -steps: -- name: Checkout - uses: actions/checkout@v2 - -- name: Setup cache environment - id: extcache - uses: shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} - -- name: Cache extensions - uses: actions/cache@v2 - with: - path: ${{ steps.extcache.outputs.dir }} - key: ${{ steps.extcache.outputs.key }} - restore-keys: ${{ steps.extcache.outputs.key }} - -- name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} -``` - -**Note:** If you setup both `TS` and `NTS` PHP versions on `windows`, add `${{ env.phpts }}` to `key` and `restore-keys` inputs in `actions/cache` step. +You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time. +Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details. ### Cache Composer Dependencies @@ -646,9 +609,23 @@ Examples of using `setup-php` with various PHP Frameworks and Packages. ## :sparkling_heart: Support This Project -If this action helped you. +**Thanks for supporting this project** -- Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance. +

+ + JetBrains + + spacer + + Tidelift + +

+ +*If this action helped you* + +- Sponsor the project by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon"). +- If you have an open-source support program, please [contact](mailto:contact@shivammathur.com) to sponsor this project. +- This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance. - Please star the project and dependencies. If you blog, please share your experience of using this action with the community. ## :package: Dependencies @@ -658,9 +635,12 @@ If this action helped you. - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows") - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages") - [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions") -- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS") +- [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases") - [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS") -- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package") +- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS") +- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu") +- [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows") +- [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu") - [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin") - [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu") From ee084d31767bf8d0b0d81afb55a6f88308f3c91c Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 10 Aug 2020 14:24:46 +0530 Subject: [PATCH 8/8] Bump version to 2.4.2 --- package-lock.json | 104 +++++++++++++++++++++++----------------------- package.json | 8 ++-- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4732412b..4076e1ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -40,16 +40,16 @@ } }, "@babel/core": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.0.tgz", - "integrity": "sha512-mkLq8nwaXmDtFmRkQ8ED/eA2CnVw4zr7dCztKalZXBvdK5EeNUAesrrwUqjQEzFgomJssayzB0aqlOsP1vGLqg==", + "version": "7.11.1", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.1.tgz", + "integrity": "sha512-XqF7F6FWQdKGGWAzGELL+aCO1p+lRY5Tj5/tbT3St1G8NaH70jhhDIKknIZaDans0OQBG5wRAldROLHSt44BgQ==", "dev": true, "requires": { "@babel/code-frame": "^7.10.4", "@babel/generator": "^7.11.0", "@babel/helper-module-transforms": "^7.11.0", "@babel/helpers": "^7.10.4", - "@babel/parser": "^7.11.0", + "@babel/parser": "^7.11.1", "@babel/template": "^7.10.4", "@babel/traverse": "^7.11.0", "@babel/types": "^7.11.0", @@ -285,9 +285,9 @@ } }, "@babel/parser": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.0.tgz", - "integrity": "sha512-qvRvi4oI8xii8NllyEc4MDJjuZiNaRzyb7Y7lup1NqJV8TZHF4O27CcP+72WPn/k1zkgJ6WJfnIbk4jTsVAZHw==", + "version": "7.11.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.3.tgz", + "integrity": "sha512-REo8xv7+sDxkKvoxEywIdsNFiZLybwdI7hcT5uEPyQrSMB4YQ973BfC9OOrD/81MaIjh6UxdulIQXkjmiH3PcA==", "dev": true }, "@babel/plugin-syntax-async-generators": { @@ -1034,9 +1034,9 @@ } }, "@types/jest": { - "version": "26.0.8", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.8.tgz", - "integrity": "sha512-eo3VX9jGASSuv680D4VQ89UmuLZneNxv2MCZjfwlInav05zXVJTzfc//lavdV0GPwSxsXJTy2jALscB7Acqg0g==", + "version": "26.0.9", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.9.tgz", + "integrity": "sha512-k4qFfJ5AUKrWok5KYXp2EPm89b0P/KZpl7Vg4XuOTVVQEhLDBDBU3iBFrjjdgd8fLw96aAtmnwhXHl63bWeBQQ==", "dev": true, "requires": { "jest-diff": "^25.2.1", @@ -1101,12 +1101,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.1.tgz", - "integrity": "sha512-3DB9JDYkMrc8Au00rGFiJLK2Ja9CoMP6Ut0sHsXp3ZtSugjNxvSSHTnKLfo4o+QmjYBJqEznDqsG1zj4F2xnsg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.8.0.tgz", + "integrity": "sha512-lFb4VCDleFSR+eo4Ew+HvrJ37ZH1Y9ZyE+qyP7EiwBpcCVxwmUc5PAqhShCQ8N8U5vqYydm74nss+a0wrrCErw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "3.7.1", + "@typescript-eslint/experimental-utils": "3.8.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -1115,45 +1115,45 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz", - "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.8.0.tgz", + "integrity": "sha512-o8T1blo1lAJE0QDsW7nSyvZHbiDzQDjINJKyB44Z3sSL39qBy5L10ScI/XwDtaiunoyKGLiY9bzRk4YjsUZl8w==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/typescript-estree": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/typescript-estree": "3.8.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.1.tgz", - "integrity": "sha512-W4QV/gXvfIsccN8225784LNOorcm7ch68Fi3V4Wg7gmkWSQRKevO4RrRqWo6N/Z/myK1QAiGgeaXN57m+R/8iQ==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.8.0.tgz", + "integrity": "sha512-u5vjOBaCsnMVQOvkKCXAmmOhyyMmFFf5dbkM3TIbg3MZ2pyv5peE4gj81UAbTHwTOXEwf7eCQTUMKrDl/+qGnA==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.7.1", - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/typescript-estree": "3.7.1", + "@typescript-eslint/experimental-utils": "3.8.0", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/typescript-estree": "3.8.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/types": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz", - "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.8.0.tgz", + "integrity": "sha512-8kROmEQkv6ss9kdQ44vCN1dTrgu4Qxrd2kXr10kz2NP5T8/7JnEfYNxCpPkArbLIhhkGLZV3aVMplH1RXQRF7Q==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz", - "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.8.0.tgz", + "integrity": "sha512-MTv9nPDhlKfclwnplRNDL44mP2SY96YmPGxmMbMy6x12I+pERcxpIUht7DXZaj4mOKKtet53wYYXU0ABaiXrLw==", "dev": true, "requires": { - "@typescript-eslint/types": "3.7.1", - "@typescript-eslint/visitor-keys": "3.7.1", + "@typescript-eslint/types": "3.8.0", + "@typescript-eslint/visitor-keys": "3.8.0", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -1163,9 +1163,9 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz", - "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.8.0.tgz", + "integrity": "sha512-gfqQWyVPpT9NpLREXNR820AYwgz+Kr1GuF3nf1wxpHD6hdxI62tq03ToomFnDxY0m3pUB39IF7sil7D5TQexLA==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" @@ -1184,9 +1184,9 @@ "dev": true }, "acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, "acorn-globals": { @@ -3409,9 +3409,9 @@ } }, "is-docker": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.0.tgz", - "integrity": "sha512-mB2WygGsSeoXtLKpSYzP6sa0Z9DyU9ZyKlnvuZWxCociaI0qsF8u12sR72DFTX236g1u6oWSWYFuUk09nGQEjg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz", + "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==", "dev": true, "optional": true }, @@ -3470,9 +3470,9 @@ "dev": true }, "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", "dev": true, "requires": { "has-symbols": "^1.0.1" @@ -4914,9 +4914,9 @@ "dev": true }, "jsdom": { - "version": "16.3.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.3.0.tgz", - "integrity": "sha512-zggeX5UuEknpdZzv15+MS1dPYG0J/TftiiNunOeNxSl3qr8Z6cIlQpN0IdJa44z9aFxZRIVqRncvEhQ7X5DtZg==", + "version": "16.4.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.4.0.tgz", + "integrity": "sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w==", "dev": true, "requires": { "abab": "^2.0.3", @@ -5421,9 +5421,9 @@ } }, "onetime": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.1.tgz", - "integrity": "sha512-ZpZpjcJeugQfWsfyQlshVoowIIQ1qBGSVll4rfDq6JJVO//fesjoX808hXWfBjY+ROZgpKDI5TRSRBSoJiZ8eg==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, "requires": { "mimic-fn": "^2.1.0" diff --git a/package.json b/package.json index 479f3034..d9f85e56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "2.4.1", + "version": "2.4.2", "private": false, "description": "Setup PHP for use with GitHub Actions", "main": "dist/index.js", @@ -31,10 +31,10 @@ "fs": "0.0.1-security" }, "devDependencies": { - "@types/jest": "^26.0.8", + "@types/jest": "^26.0.9", "@types/node": "^14.0.27", - "@typescript-eslint/eslint-plugin": "^3.7.1", - "@typescript-eslint/parser": "^3.7.1", + "@typescript-eslint/eslint-plugin": "^3.8.0", + "@typescript-eslint/parser": "^3.8.0", "@zeit/ncc": "^0.22.3", "eslint": "^7.6.0", "eslint-config-prettier": "^6.11.0",