From 9e663851ce7614f32ed3401bffa6ce77471ee401 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 5 Oct 2020 06:15:50 +0530 Subject: [PATCH] Move matchers setup to scripts --- __tests__/matchers.test.ts | 41 ---------------------------------- dist/index.js | 45 -------------------------------------- src/install.ts | 2 -- src/matchers.ts | 13 ----------- src/scripts/darwin.sh | 2 ++ src/scripts/linux.sh | 2 ++ src/scripts/win32.ps1 | 3 ++- 7 files changed, 6 insertions(+), 102 deletions(-) delete mode 100644 __tests__/matchers.test.ts delete mode 100644 src/matchers.ts diff --git a/__tests__/matchers.test.ts b/__tests__/matchers.test.ts deleted file mode 100644 index 780ac2bb..00000000 --- a/__tests__/matchers.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as io from '@actions/io'; -import * as matchers from '../src/matchers'; - -jest.mock('@actions/io'); - -describe('Matchers', () => { - it('Add matchers', async () => { - process.env['RUNNER_TOOL_CACHE'] = __dirname; - await matchers.addMatchers(); - const spy = jest.spyOn(io, 'cp'); - expect(spy).toHaveBeenCalledTimes(2); - }); - - it('Test PHPUnit Regex', async () => { - const regex1 = /^\d+\)\s.*$/; - const regex2 = /^(.*Failed\sasserting\sthat.*)$/; - const regex3 = /^\s*$/; - const regex4 = /^(.*):(\d+)$/; - expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true); - expect(regex2.test('Failed asserting that false is true')).toBe(true); - expect(regex3.test('\n')).toBe(true); - expect(regex4.test('/path/to/file.php:42')).toBe(true); - }); - - it('Test PHP Regex', async () => { - const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/; - const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/; - expect( - regex1.test('PHP Parse error: error_message in file.php on line 10') - ).toBe(true); - expect( - regex2.test('PHP Notice: info_message in file.php on line 10') - ).toBe(true); - expect( - regex2.test('PHP Warning: warning_message in file.php on line 10') - ).toBe(true); - expect( - regex2.test('PHP Deprecated: deprecated_message in file.php on line 10') - ).toBe(true); - }); -}); diff --git a/dist/index.js b/dist/index.js index e4755e6f..2d9ed59c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -977,49 +977,6 @@ function toCommandValue(input) { exports.toCommandValue = toCommandValue; //# sourceMappingURL=utils.js.map -/***/ }), - -/***/ 86: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.addMatchers = void 0; -const path = __importStar(__webpack_require__(622)); -const utils = __importStar(__webpack_require__(163)); -const io = __importStar(__webpack_require__(1)); -/** - * Cache json files for problem matchers - */ -async function addMatchers() { - const config_path = path.join(__dirname, '..', 'src', 'configs'); - const runner_dir = await utils.getInput('RUNNER_TOOL_CACHE', false); - await io.cp(path.join(config_path, 'phpunit.json'), runner_dir); - await io.cp(path.join(config_path, 'php.json'), runner_dir); -} -exports.addMatchers = addMatchers; - - /***/ }), /***/ 87: @@ -2578,7 +2535,6 @@ const coverage = __importStar(__webpack_require__(635)); const extensions = __importStar(__webpack_require__(911)); const tools = __importStar(__webpack_require__(534)); const utils = __importStar(__webpack_require__(163)); -const matchers = __importStar(__webpack_require__(86)); /** * Build the script * @@ -2624,7 +2580,6 @@ async function run() { const script = os_version + (await utils.scriptExtension(os_version)); const location = await getScript(script, version, os_version); await exec_1.exec(await utils.joins(tool, location, version, __dirname)); - await matchers.addMatchers(); } catch (error) { core.setFailed(error.message); diff --git a/src/install.ts b/src/install.ts index e0f46eb4..e2af537d 100644 --- a/src/install.ts +++ b/src/install.ts @@ -5,7 +5,6 @@ import * as coverage from './coverage'; import * as extensions from './extensions'; import * as tools from './tools'; import * as utils from './utils'; -import * as matchers from './matchers'; /** * Build the script @@ -62,7 +61,6 @@ export async function run(): Promise { const script = os_version + (await utils.scriptExtension(os_version)); const location = await getScript(script, version, os_version); await exec(await utils.joins(tool, location, version, __dirname)); - await matchers.addMatchers(); } catch (error) { core.setFailed(error.message); } diff --git a/src/matchers.ts b/src/matchers.ts deleted file mode 100644 index 03b1bfd8..00000000 --- a/src/matchers.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as path from 'path'; -import * as utils from './utils'; -import * as io from '@actions/io'; - -/** - * Cache json files for problem matchers - */ -export async function addMatchers(): Promise { - const config_path = path.join(__dirname, '..', 'src', 'configs'); - const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false); - await io.cp(path.join(config_path, 'phpunit.json'), runner_dir); - await io.cp(path.join(config_path, 'php.json'), runner_dir); -} diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index cdd64002..8ea96ebc 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -267,6 +267,7 @@ setup_php() { tick="✓" cross="✗" version=$1 +dist=$2 nodot_version=${1/./} old_versions="5.[3-5]" tool_path_dir="/usr/local/bin" @@ -305,4 +306,5 @@ scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") sudo mkdir -p "$ext_dir" semver=$(php -v | head -n 1 | cut -f 2 -d ' ') if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi +sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/" add_log "$tick" "PHP" "$status PHP $semver" diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index e5305c3f..5cb24ef6 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -422,6 +422,7 @@ tick="✓" cross="✗" pecl_config="false" version=$1 +dist=$2 master_version="8.0" old_versions="5.[3-5]" debconf_fix="DEBIAN_FRONTEND=noninteractive" @@ -477,4 +478,5 @@ pecl_file="$scan_dir"/99-pecl.ini echo '' | sudo tee "$pecl_file" >/dev/null 2>&1 sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1 sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir" +sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/" add_log "$tick" "PHP" "$status PHP $semver" diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 1291e5d7..bca5bb84 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -8,7 +8,7 @@ param ( [ValidateNotNull()] [ValidateLength(1, [int]::MaxValue)] [string] - $dir + $dist ) # Function to log start of a operation. @@ -393,4 +393,5 @@ if($version -lt "5.5") { Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir } Update-PhpCAInfo -Path $php_dir -Source $cert_source +Move-Item -path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"