Reverted wrapper changes

pull/1009/head
Sankalp Kotewar 2 years ago committed by GitHub
parent f8717682fb
commit a172494938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3402,7 +3402,7 @@ const http_client_1 = __webpack_require__(425);
const auth_1 = __webpack_require__(554); const auth_1 = __webpack_require__(554);
const crypto = __importStar(__webpack_require__(417)); const crypto = __importStar(__webpack_require__(417));
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const url_1 = __webpack_require__(414); const url_1 = __webpack_require__(835);
const utils = __importStar(__webpack_require__(15)); const utils = __importStar(__webpack_require__(15));
const constants_1 = __webpack_require__(931); const constants_1 = __webpack_require__(931);
const downloadUtils_1 = __webpack_require__(251); const downloadUtils_1 = __webpack_require__(251);
@ -35024,7 +35024,7 @@ exports.Path = Path;
*/ */
const punycode = __webpack_require__(815); const punycode = __webpack_require__(815);
const urlParse = __webpack_require__(414).parse; const urlParse = __webpack_require__(835).parse;
const util = __webpack_require__(669); const util = __webpack_require__(669);
const pubsuffix = __webpack_require__(562); const pubsuffix = __webpack_require__(562);
const Store = __webpack_require__(338).Store; const Store = __webpack_require__(338).Store;
@ -36819,12 +36819,7 @@ module.exports = __webpack_require__(141);
/***/ }), /***/ }),
/* 414 */ /* 414 */,
/***/ (function(module) {
module.exports = require("url");
/***/ }),
/* 415 */, /* 415 */,
/* 416 */, /* 416 */,
/* 417 */ /* 417 */
@ -38624,7 +38619,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var Stream = _interopDefault(__webpack_require__(794)); var Stream = _interopDefault(__webpack_require__(794));
var http = _interopDefault(__webpack_require__(605)); var http = _interopDefault(__webpack_require__(605));
var Url = _interopDefault(__webpack_require__(414)); var Url = _interopDefault(__webpack_require__(835));
var whatwgUrl = _interopDefault(__webpack_require__(70)); var whatwgUrl = _interopDefault(__webpack_require__(70));
var https = _interopDefault(__webpack_require__(211)); var https = _interopDefault(__webpack_require__(211));
var zlib = _interopDefault(__webpack_require__(761)); var zlib = _interopDefault(__webpack_require__(761));
@ -48963,6 +48958,29 @@ module.exports = function(dst, src) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) { return new (P || (P = Promise))(function (resolve, reject) {
@ -48972,17 +48990,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const restoreImpl_1 = __importDefault(__webpack_require__(835)); const cache = __importStar(__webpack_require__(692));
function runRestoreStep() { const core = __importStar(__webpack_require__(470));
const constants_1 = __webpack_require__(196);
const utils = __importStar(__webpack_require__(443));
function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield (0, restoreImpl_1.default)(); try {
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
return;
}
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
return;
}
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
//Check if user wants to save cache despite of failure in any previous job
const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
if (saveCache === "yes") {
core.debug(`save cache input variable is set to yes`);
core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
}
if (!cacheKey) {
if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
}
core.info(`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`);
return;
}
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
}
core.info(`Cache restored from key: ${cacheKey}`);
}
catch (error) {
core.setFailed(error.message);
}
}); });
} }
runRestoreStep(); run();
exports.default = run;
/***/ }), /***/ }),
@ -49424,7 +49488,7 @@ var util = __webpack_require__(669);
var path = __webpack_require__(622); var path = __webpack_require__(622);
var http = __webpack_require__(605); var http = __webpack_require__(605);
var https = __webpack_require__(211); var https = __webpack_require__(211);
var parseUrl = __webpack_require__(414).parse; var parseUrl = __webpack_require__(835).parse;
var fs = __webpack_require__(747); var fs = __webpack_require__(747);
var Stream = __webpack_require__(794).Stream; var Stream = __webpack_require__(794).Stream;
var mime = __webpack_require__(779); var mime = __webpack_require__(779);
@ -50590,99 +50654,9 @@ exports.VERSION = '1.0.4';
/* 833 */, /* 833 */,
/* 834 */, /* 834 */,
/* 835 */ /* 835 */
/***/ (function(__unusedmodule, exports, __webpack_require__) { /***/ (function(module) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const cache = __importStar(__webpack_require__(692));
const core = __importStar(__webpack_require__(470));
const constants_1 = __webpack_require__(196);
const utils = __importStar(__webpack_require__(443));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
return;
}
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);
return;
}
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
//Check if user wants to save cache despite of failure in any previous job
const saveCache = core.getInput(constants_1.Inputs.SaveOnAnyFailure);
if (saveCache === "yes") {
core.debug(`save cache input variable is set to yes`);
core.exportVariable(constants_1.Variables.SaveCacheOnAnyFailure, saveCache);
core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`);
}
if (!cacheKey) {
if (core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
}
core.info(`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`);
return;
}
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
if (!isExactKeyMatch && core.getInput(constants_1.Inputs.StrictRestore) == "yes") {
throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
}
core.info(`Cache restored from key: ${cacheKey}`);
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.default = run;
module.exports = require("url");
/***/ }), /***/ }),
/* 836 */, /* 836 */,
@ -55817,7 +55791,7 @@ var stream = __webpack_require__(794);
var FormData = __webpack_require__(790); var FormData = __webpack_require__(790);
var node_fetch = __webpack_require__(454); var node_fetch = __webpack_require__(454);
var coreTracing = __webpack_require__(263); var coreTracing = __webpack_require__(263);
var url = __webpack_require__(414); var url = __webpack_require__(835);
__webpack_require__(97); __webpack_require__(97);
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

@ -5,7 +5,7 @@
"description": "Cache dependencies and build outputs", "description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js", "main": "dist/restore/index.js",
"scripts": { "scripts": {
"build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restore/restore-only.ts", "build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts",
"test": "tsc --noEmit && jest --coverage", "test": "tsc --noEmit && jest --coverage",
"lint": "eslint **/*.ts --cache", "lint": "eslint **/*.ts --cache",
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",

@ -20,7 +20,8 @@ outputs:
description: 'A boolean value to indicate an exact match was found for the primary key' description: 'A boolean value to indicate an exact match was found for the primary key'
runs: runs:
using: 'node16' using: 'node16'
main: '../dist/restore-only/index.js' main: '../dist/restore/index.js'
branding: branding:
icon: 'archive' icon: 'archive'
color: 'gray-dark' color: 'gray-dark'

@ -1,7 +1,81 @@
import restore from "./restoreImpl"; import * as cache from "@actions/cache";
import * as core from "@actions/core";
async function runRestoreStep(): Promise<void> { import { Events, Inputs, State, Variables } from "./constants";
await restore(); import * as utils from "./utils/actionUtils";
async function run(): Promise<void> {
try {
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
return;
}
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(
`Event Validation Error: The event type ${
process.env[Events.Key]
} is not supported because it's not tied to a branch or tag ref.`
);
return;
}
const primaryKey = core.getInput(Inputs.Key, { required: true });
core.saveState(State.CachePrimaryKey, primaryKey);
const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true
});
const cacheKey = await cache.restoreCache(
cachePaths,
primaryKey,
restoreKeys
);
//Check if user wants to save cache despite of failure in any previous job
const saveCache = core.getInput(Inputs.SaveOnAnyFailure);
if (saveCache === "yes") {
core.debug(`save cache input variable is set to yes`);
core.exportVariable(Variables.SaveCacheOnAnyFailure, saveCache);
core.info(
`Input Variable ${Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`
);
}
if (!cacheKey) {
if (core.getInput(Inputs.StrictRestore) == "yes") {
throw new Error(
`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
);
}
core.info(
`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`
);
return;
}
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
if (!isExactKeyMatch && core.getInput(Inputs.StrictRestore) == "yes") {
throw new Error(
`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`
);
}
core.info(`Cache restored from key: ${cacheKey}`);
} catch (error: unknown) {
core.setFailed((error as Error).message);
}
} }
runRestoreStep(); run();
export default run;

@ -1,26 +0,0 @@
import * as core from "@actions/core";
import { Inputs } from "../constants";
import restore from "../restoreImpl";
async function runRestoreAction(): Promise<void> {
if (core.getInput(Inputs.SaveOnAnyFailure) != "") {
core.warning(
`${Inputs.SaveOnAnyFailure} value is passed in the input, this input is invalid for the restore-only action and hence will be ignored`
);
}
if (core.getInput(Inputs.UploadChunkSize) != "") {
core.warning(
`${Inputs.UploadChunkSize} value is passed in the input, this input is invalid for the restore-only action and hence will be ignored`
);
}
core.info("before run");
await restore();
core.info("after run");
}
core.info("before runRestoreAction");
runRestoreAction();
core.info("after runRestoreAction");
core.info("after export default runRestoreAction");

@ -1,79 +0,0 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import { Events, Inputs, State, Variables } from "./constants";
import * as utils from "./utils/actionUtils";
async function run(): Promise<void> {
try {
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
return;
}
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(
`Event Validation Error: The event type ${
process.env[Events.Key]
} is not supported because it's not tied to a branch or tag ref.`
);
return;
}
const primaryKey = core.getInput(Inputs.Key, { required: true });
core.saveState(State.CachePrimaryKey, primaryKey);
const restoreKeys = utils.getInputAsArray(Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: true
});
const cacheKey = await cache.restoreCache(
cachePaths,
primaryKey,
restoreKeys
);
//Check if user wants to save cache despite of failure in any previous job
const saveCache = core.getInput(Inputs.SaveOnAnyFailure);
if (saveCache === "yes") {
core.debug(`save cache input variable is set to yes`);
core.exportVariable(Variables.SaveCacheOnAnyFailure, saveCache);
core.info(
`Input Variable ${Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`
);
}
if (!cacheKey) {
if (core.getInput(Inputs.StrictRestore) == "yes") {
throw new Error(
`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
);
}
core.info(
`Cache not found for input keys: ${[
primaryKey,
...restoreKeys
].join(", ")}`
);
return;
}
// Store the matched cache key
utils.setCacheState(cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
utils.setCacheHitOutput(isExactKeyMatch);
if (!isExactKeyMatch && core.getInput(Inputs.StrictRestore) == "yes") {
throw new Error(
`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`
);
}
core.info(`Cache restored from key: ${cacheKey}`);
} catch (error: unknown) {
core.setFailed((error as Error).message);
}
}
export default run;
Loading…
Cancel
Save