From 9f8231c7bcb0aad18add2ac7b1c882d1e9dbd2fc Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Wed, 23 Sep 2020 12:40:15 -0400 Subject: [PATCH 1/5] update @actions/core to the latest version --- dist/index.js | 123 +++++++++++++++++++++++++++++++++++++++++----- package-lock.json | 6 +-- 2 files changed, 114 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index 68ed4e4..953942a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -941,6 +941,32 @@ module.exports = require("tls"); /***/ }), +/***/ 82: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string + */ +function toCommandValue(input) { + if (input === null || input === undefined) { + return ''; + } + else if (typeof input === 'string' || input instanceof String) { + return input; + } + return JSON.stringify(input); +} +exports.toCommandValue = toCommandValue; +//# sourceMappingURL=utils.js.map + +/***/ }), + /***/ 87: /***/ (function(module) { @@ -948,6 +974,42 @@ module.exports = require("os"); /***/ }), +/***/ 102: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +// For internal use, subject to change. +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +// We use any as a valid input type +/* eslint-disable @typescript-eslint/no-explicit-any */ +const fs = __importStar(__webpack_require__(747)); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +function issueCommand(command, message) { + const filePath = process.env[`GITHUB_${command}`]; + if (!filePath) { + throw new Error(`Unable to find environment variable for file command ${command}`); + } + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } + fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { + encoding: 'utf8' + }); +} +exports.issueCommand = issueCommand; +//# sourceMappingURL=file-command.js.map + +/***/ }), + /***/ 129: /***/ (function(module) { @@ -2986,6 +3048,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); /** * Commands * @@ -3040,13 +3103,13 @@ class Command { } } function escapeData(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A'); } function escapeProperty(s) { - return (s || '') + return utils_1.toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A') @@ -3080,6 +3143,8 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); /** @@ -3102,11 +3167,21 @@ var ExitCode; /** * Sets env variable for this action and future actions in the job * @param name the name of the variable to set - * @param val the value of the variable + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function exportVariable(name, val) { - process.env[name] = val; - command_1.issueCommand('set-env', { name }, val); + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); + } } exports.exportVariable = exportVariable; /** @@ -3122,7 +3197,13 @@ exports.setSecret = setSecret; * @param inputPath */ function addPath(inputPath) { - command_1.issueCommand('add-path', {}, inputPath); + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); + } + else { + command_1.issueCommand('add-path', {}, inputPath); + } process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } exports.addPath = addPath; @@ -3145,12 +3226,22 @@ exports.getInput = getInput; * Sets the value of an output. * * @param name name of the output to set - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); +} +exports.setCommandEcho = setCommandEcho; //----------------------------------------------------------------------- // Results //----------------------------------------------------------------------- @@ -3167,6 +3258,13 @@ exports.setFailed = setFailed; //----------------------------------------------------------------------- // Logging Commands //----------------------------------------------------------------------- +/** + * Gets whether Actions Step Debug is on or not + */ +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; +} +exports.isDebug = isDebug; /** * Writes debug message to user log * @param message debug message @@ -3177,18 +3275,18 @@ function debug(message) { exports.debug = debug; /** * Adds an error issue - * @param message error issue message + * @param message error issue message. Errors will be converted to string via toString() */ function error(message) { - command_1.issue('error', message); + command_1.issue('error', message instanceof Error ? message.toString() : message); } exports.error = error; /** * Adds an warning issue - * @param message warning issue message + * @param message warning issue message. Errors will be converted to string via toString() */ function warning(message) { - command_1.issue('warning', message); + command_1.issue('warning', message instanceof Error ? message.toString() : message); } exports.warning = warning; /** @@ -3246,8 +3344,9 @@ exports.group = group; * Saves state for current action, the state can only be retrieved by this action's post job execution. * * @param name name of the state to store - * @param value value to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { command_1.issueCommand('save-state', { name }, value); } diff --git a/package-lock.json b/package-lock.json index 401a204..62eefc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@actions/core": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.2.tgz", - "integrity": "sha512-IbCx7oefq+Gi6FWbSs2Fnw8VkEI6Y4gvjrYprY3RV//ksq/KPMlClOerJ4jRosyal6zkUIc8R9fS/cpRMlGClg==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz", + "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" }, "@actions/exec": { "version": "1.0.3", From ab08eab6e26e54e68a148172ba0c47ad9d1580ac Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Wed, 23 Sep 2020 12:50:37 -0400 Subject: [PATCH 2/5] update licensed --- .licenses/npm/@actions/core.dep.yml | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/.licenses/npm/@actions/core.dep.yml b/.licenses/npm/@actions/core.dep.yml index 92b8b02..b1152f5 100644 --- a/.licenses/npm/@actions/core.dep.yml +++ b/.licenses/npm/@actions/core.dep.yml @@ -1,30 +1,20 @@ --- name: "@actions/core" -version: 1.2.2 +version: 1.2.6 type: npm summary: Actions core lib -homepage: https://github.com/actions/toolkit/tree/master/packages/core +homepage: https://github.com/actions/toolkit/tree/main/packages/core license: mit licenses: -- sources: Auto-generated MIT license text - text: | - MIT License +- sources: LICENSE.md + text: |- + The MIT License (MIT) - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: + Copyright 2019 GitHub - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. notices: [] From c4c5cecbea52ff0c09d584f4706d7e2c88c2d823 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Wed, 23 Sep 2020 12:55:22 -0400 Subject: [PATCH 3/5] Fix tests on hosted runners --- __tests__/find-ruby.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/__tests__/find-ruby.test.ts b/__tests__/find-ruby.test.ts index 2fa745d..1d59d6c 100644 --- a/__tests__/find-ruby.test.ts +++ b/__tests__/find-ruby.test.ts @@ -11,7 +11,9 @@ describe('find-ruby', () => { let tcSpy: jest.SpyInstance; let cnSpy: jest.SpyInstance; - beforeAll(async () => {}); + beforeAll(async () => { + process.env['GITHUB_PATH'] = ''; + }); beforeEach(() => { tcSpy = jest.spyOn(tc, 'find'); From dd324cc0e98ac26a02395cf2fd6b7d1098d4ae20 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Tue, 29 Sep 2020 18:52:27 -0400 Subject: [PATCH 4/5] disable workflow commands when running in a runner --- __tests__/find-ruby.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/__tests__/find-ruby.test.ts b/__tests__/find-ruby.test.ts index 1d59d6c..0b3301d 100644 --- a/__tests__/find-ruby.test.ts +++ b/__tests__/find-ruby.test.ts @@ -12,7 +12,8 @@ describe('find-ruby', () => { let cnSpy: jest.SpyInstance; beforeAll(async () => { - process.env['GITHUB_PATH'] = ''; + process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out + console.log("::stop-commands::stoptoken"); // Disable executing of runner commands when running tests in actions }); beforeEach(() => { @@ -31,7 +32,9 @@ describe('find-ruby', () => { jest.clearAllMocks(); }); - afterAll(async () => {}, 100000); + afterAll(async () => { + console.log("::stoptoken::"); // Re-enable executing of runner commands when running tests in actions + }, 100000); it('finds a version of ruby already in the cache', async () => { let toolPath = path.normalize('/cache/ruby/2.7.0/x64'); From 2cf4531687672e093ca5cdff003d77db28a71b9f Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Tue, 29 Sep 2020 18:53:21 -0400 Subject: [PATCH 5/5] run lint --- __tests__/find-ruby.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/find-ruby.test.ts b/__tests__/find-ruby.test.ts index 0b3301d..d35112a 100644 --- a/__tests__/find-ruby.test.ts +++ b/__tests__/find-ruby.test.ts @@ -13,7 +13,7 @@ describe('find-ruby', () => { beforeAll(async () => { process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out - console.log("::stop-commands::stoptoken"); // Disable executing of runner commands when running tests in actions + console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions }); beforeEach(() => { @@ -33,7 +33,7 @@ describe('find-ruby', () => { }); afterAll(async () => { - console.log("::stoptoken::"); // Re-enable executing of runner commands when running tests in actions + console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions }, 100000); it('finds a version of ruby already in the cache', async () => {