From 187c4adfcc853be3cf508ca1df4730a927815ee3 Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Fri, 4 Dec 2020 17:10:23 +0100 Subject: [PATCH] refactor: output cache errors with actions core --- build/index.js | 803 +++++++++++++++++++++++++------------------------ src/cache.ts | 8 +- yarn.lock | 2 +- 3 files changed, 410 insertions(+), 403 deletions(-) diff --git a/build/index.js b/build/index.js index 2e4e68c13..e80758c52 100644 --- a/build/index.js +++ b/build/index.js @@ -14080,43 +14080,43 @@ module.exports = ["389-exception","Autoconf-exception-2.0","Autoconf-exception-3 /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -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 }); -exports.run = void 0; -const core_1 = __webpack_require__(470); -const expo_1 = __webpack_require__(265); -const install_1 = __webpack_require__(655); -const system_1 = __webpack_require__(913); -function run() { - return __awaiter(this, void 0, void 0, function* () { - const path = yield install_1.install({ - version: core_1.getInput('expo-version') || 'latest', - packager: core_1.getInput('expo-packager') || 'yarn', - cache: (core_1.getInput('expo-cache') || 'false') === 'true', - cacheKey: core_1.getInput('expo-cache-key') || undefined, - }); - core_1.addPath(path); - yield expo_1.authenticate({ - token: core_1.getInput('expo-token') || undefined, - username: core_1.getInput('expo-username') || undefined, - password: core_1.getInput('expo-password') || undefined, - }); - const shouldPatchWatchers = core_1.getInput('expo-patch-watchers') || 'true'; - if (shouldPatchWatchers !== 'false') { - yield system_1.patchWatchers(); - } - }); -} -exports.run = run; + +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 }); +exports.run = void 0; +const core_1 = __webpack_require__(470); +const expo_1 = __webpack_require__(265); +const install_1 = __webpack_require__(655); +const system_1 = __webpack_require__(913); +function run() { + return __awaiter(this, void 0, void 0, function* () { + const path = yield install_1.install({ + version: core_1.getInput('expo-version') || 'latest', + packager: core_1.getInput('expo-packager') || 'yarn', + cache: (core_1.getInput('expo-cache') || 'false') === 'true', + cacheKey: core_1.getInput('expo-cache-key') || undefined, + }); + core_1.addPath(path); + yield expo_1.authenticate({ + token: core_1.getInput('expo-token') || undefined, + username: core_1.getInput('expo-username') || undefined, + password: core_1.getInput('expo-password') || undefined, + }); + const shouldPatchWatchers = core_1.getInput('expo-patch-watchers') || 'true'; + if (shouldPatchWatchers !== 'false') { + yield system_1.patchWatchers(); + } + }); +} +exports.run = run; /***/ }), @@ -22753,92 +22753,92 @@ exports.TrackerStream = __webpack_require__(235) /***/ (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.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 }); -exports.authenticate = exports.authWithToken = exports.authWithCredentials = void 0; -const core = __importStar(__webpack_require__(470)); -const cli = __importStar(__webpack_require__(986)); -/** - * Authenticate at Expo using `expo login`. - * This step is required for publishing and building new apps. - * It uses the `EXPO_CLI_PASSWORD` environment variable for improved security. - */ -function authWithCredentials(username, password) { - return __awaiter(this, void 0, void 0, function* () { - if (!username || !password) { - return core.info('Skipping authentication: `expo-username` and/or `expo-password` not set...'); - } - // github actions toolkit will handle commands with `.cmd` on windows, we need that - const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo'; - yield cli.exec(bin, ['login', `--username=${username}`], { - env: Object.assign(Object.assign({}, process.env), { EXPO_CLI_PASSWORD: password }), - }); - }); -} -exports.authWithCredentials = authWithCredentials; -/** - * Authenticate with Expo using `EXPO_TOKEN`. - * This exports the EXPO_TOKEN environment variable for all future steps within the workflow. - * It also double-checks if this token is valid and for what user, by running `expo whoami`. - * - * @see https://github.com/actions/toolkit/blob/905b2c7b0681b11056141a60055f1ba77358b7e9/packages/core/src/core.ts#L39 - */ -function authWithToken(token) { - return __awaiter(this, void 0, void 0, function* () { - if (!token) { - return core.info('Skipping authentication: `expo-token` not set...'); - } - // github actions toolkit will handle commands with `.cmd` on windows, we need that - const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo'; - yield cli.exec(bin, ['whoami'], { - env: Object.assign(Object.assign({}, process.env), { EXPO_TOKEN: token }), - }); - core.exportVariable('EXPO_TOKEN', token); - }); -} -exports.authWithToken = authWithToken; -/** - * Authenticate with Expo using either the token or username/password method. - * If both of them are set, token has priority. - */ -function authenticate(options) { - if (options.token) { - return authWithToken(options.token); - } - if (options.username || options.password) { - return authWithCredentials(options.username, options.password); - } - core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...'); -} -exports.authenticate = authenticate; + +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.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 }); +exports.authenticate = exports.authWithToken = exports.authWithCredentials = void 0; +const core = __importStar(__webpack_require__(470)); +const cli = __importStar(__webpack_require__(986)); +/** + * Authenticate at Expo using `expo login`. + * This step is required for publishing and building new apps. + * It uses the `EXPO_CLI_PASSWORD` environment variable for improved security. + */ +function authWithCredentials(username, password) { + return __awaiter(this, void 0, void 0, function* () { + if (!username || !password) { + return core.info('Skipping authentication: `expo-username` and/or `expo-password` not set...'); + } + // github actions toolkit will handle commands with `.cmd` on windows, we need that + const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo'; + yield cli.exec(bin, ['login', `--username=${username}`], { + env: Object.assign(Object.assign({}, process.env), { EXPO_CLI_PASSWORD: password }), + }); + }); +} +exports.authWithCredentials = authWithCredentials; +/** + * Authenticate with Expo using `EXPO_TOKEN`. + * This exports the EXPO_TOKEN environment variable for all future steps within the workflow. + * It also double-checks if this token is valid and for what user, by running `expo whoami`. + * + * @see https://github.com/actions/toolkit/blob/905b2c7b0681b11056141a60055f1ba77358b7e9/packages/core/src/core.ts#L39 + */ +function authWithToken(token) { + return __awaiter(this, void 0, void 0, function* () { + if (!token) { + return core.info('Skipping authentication: `expo-token` not set...'); + } + // github actions toolkit will handle commands with `.cmd` on windows, we need that + const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo'; + yield cli.exec(bin, ['whoami'], { + env: Object.assign(Object.assign({}, process.env), { EXPO_TOKEN: token }), + }); + core.exportVariable('EXPO_TOKEN', token); + }); +} +exports.authWithToken = authWithToken; +/** + * Authenticate with Expo using either the token or username/password method. + * If both of them are set, token has priority. + */ +function authenticate(options) { + if (options.token) { + return authWithToken(options.token); + } + if (options.username || options.password) { + return authWithCredentials(options.username, options.password); + } + core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...'); +} +exports.authenticate = authenticate; /***/ }), @@ -28972,30 +28972,30 @@ Promise._SomePromiseArray = SomePromiseArray; /***/ (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(__webpack_require__(470)); -const run_1 = __webpack_require__(180); -run_1.run().catch(core.setFailed); + +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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const run_1 = __webpack_require__(180); +run_1.run().catch(core.setFailed); /***/ }), @@ -86589,95 +86589,95 @@ if (process.platform === 'linux') { /***/ (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.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 }); -exports.fromPackager = exports.install = exports.resolve = void 0; -const core = __importStar(__webpack_require__(470)); -const cli = __importStar(__webpack_require__(986)); -const io = __importStar(__webpack_require__(1)); -const path = __importStar(__webpack_require__(622)); -const cache_1 = __webpack_require__(722); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const registry = __webpack_require__(52); -/** - * Resolve the provided semver to exact version of `expo-cli`. - * This uses the npm registry and accepts latest, dist-tags or version ranges. - * It's used to determine the cached version of `expo-cli`. - */ -function resolve(version) { - return __awaiter(this, void 0, void 0, function* () { - return (yield registry.manifest(`expo-cli@${version}`)).version; - }); -} -exports.resolve = resolve; -/** - * Install `expo-cli`, by version, using the packager. - * Here you can provide any semver range or dist tag used in the registry. - * It returns the path where Expo is installed. - */ -function install(config) { - return __awaiter(this, void 0, void 0, function* () { - const exact = yield resolve(config.version); - let root = yield cache_1.fromLocalCache(exact); - if (!root && config.cache) { - root = yield cache_1.fromRemoteCache(exact, config.packager, config.cacheKey); - } - else { - core.info('Skipping remote cache, not enabled...'); - } - if (!root) { - root = yield fromPackager(exact, config.packager); - root = yield cache_1.toLocalCache(root, exact); - if (config.cache) { - yield cache_1.toRemoteCache(root, exact, config.packager, config.cacheKey); - } - } - return path.join(root, 'node_modules', '.bin'); - }); -} -exports.install = install; -/** - * Install `expo-cli`, by version, using npm or yarn. - * It creates a temporary directory to store all required files. - */ -function fromPackager(version, packager) { - return __awaiter(this, void 0, void 0, function* () { - const root = process.env['RUNNER_TEMP'] || ''; - const tool = yield io.which(packager); - yield io.mkdirP(root); - yield cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root }); - return root; - }); -} -exports.fromPackager = fromPackager; + +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.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 }); +exports.fromPackager = exports.install = exports.resolve = void 0; +const core = __importStar(__webpack_require__(470)); +const cli = __importStar(__webpack_require__(986)); +const io = __importStar(__webpack_require__(1)); +const path = __importStar(__webpack_require__(622)); +const cache_1 = __webpack_require__(722); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const registry = __webpack_require__(52); +/** + * Resolve the provided semver to exact version of `expo-cli`. + * This uses the npm registry and accepts latest, dist-tags or version ranges. + * It's used to determine the cached version of `expo-cli`. + */ +function resolve(version) { + return __awaiter(this, void 0, void 0, function* () { + return (yield registry.manifest(`expo-cli@${version}`)).version; + }); +} +exports.resolve = resolve; +/** + * Install `expo-cli`, by version, using the packager. + * Here you can provide any semver range or dist tag used in the registry. + * It returns the path where Expo is installed. + */ +function install(config) { + return __awaiter(this, void 0, void 0, function* () { + const exact = yield resolve(config.version); + let root = yield cache_1.fromLocalCache(exact); + if (!root && config.cache) { + root = yield cache_1.fromRemoteCache(exact, config.packager, config.cacheKey); + } + else { + core.info('Skipping remote cache, not enabled...'); + } + if (!root) { + root = yield fromPackager(exact, config.packager); + root = yield cache_1.toLocalCache(root, exact); + if (config.cache) { + yield cache_1.toRemoteCache(root, exact, config.packager, config.cacheKey); + } + } + return path.join(root, 'node_modules', '.bin'); + }); +} +exports.install = install; +/** + * Install `expo-cli`, by version, using npm or yarn. + * It creates a temporary directory to store all required files. + */ +function fromPackager(version, packager) { + return __awaiter(this, void 0, void 0, function* () { + const root = process.env['RUNNER_TEMP'] || ''; + const tool = yield io.which(packager); + yield io.mkdirP(root); + yield cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root }); + return root; + }); +} +exports.fromPackager = fromPackager; /***/ }), @@ -92238,110 +92238,113 @@ module.exports = class Minipass extends EE { /***/ (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.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()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.toRemoteCache = exports.fromRemoteCache = exports.toLocalCache = exports.fromLocalCache = void 0; -const cache_1 = __webpack_require__(692); -const toolCache = __importStar(__webpack_require__(533)); -const path_1 = __importDefault(__webpack_require__(622)); -const os_1 = __importDefault(__webpack_require__(87)); -/** - * Get the path to the `expo-cli` from cache, if any. - * Note, this cache is **NOT** shared between jobs. - * - * @see https://github.com/actions/toolkit/issues/47 - */ -function fromLocalCache(version) { - return __awaiter(this, void 0, void 0, function* () { - return toolCache.find('expo-cli', version); - }); -} -exports.fromLocalCache = fromLocalCache; -/** - * Store the root of `expo-cli` in the cache, for future reuse. - * Note, this cache is **NOT** shared between jobs. - * - * @see https://github.com/actions/toolkit/issues/47 - */ -function toLocalCache(root, version) { - return __awaiter(this, void 0, void 0, function* () { - return toolCache.cacheDir(root, 'expo-cli', version); - }); -} -exports.toLocalCache = toLocalCache; -/** - * Download the remotely stored `expo-cli` from cache, if any. - * Note, this cache is shared between jobs. - */ -function fromRemoteCache(version, packager, customCacheKey) { - return __awaiter(this, void 0, void 0, function* () { - // see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401 - const target = path_1.default.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os_1.default.arch()); - const cacheKey = customCacheKey || getRemoteKey(version, packager); - const hit = yield cache_1.restoreCache([target], cacheKey); - if (hit) { - return target; - } - }); -} -exports.fromRemoteCache = fromRemoteCache; -/** - * Store the root of `expo-cli` in the remote cache, for future reuse. - * Note, this cache is shared between jobs. - */ -function toRemoteCache(source, version, packager, customCacheKey) { - return __awaiter(this, void 0, void 0, function* () { - const cacheKey = customCacheKey || getRemoteKey(version, packager); - try { - yield cache_1.saveCache([source], cacheKey); - } - catch (error) { - if (error instanceof cache_1.ReserveCacheError) { - console.log(`Skipping cache save: ${error.message}`); - } - else - throw error; - } - }); -} -exports.toRemoteCache = toRemoteCache; -/** - * Get the cache key to use when (re)storing the Expo CLI from remote cache. - */ -function getRemoteKey(version, packager) { - return `expo-cli-${process.platform}-${os_1.default.arch()}-${packager}-${version}`; -} + +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.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()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toRemoteCache = exports.fromRemoteCache = exports.toLocalCache = exports.fromLocalCache = void 0; +const cache_1 = __webpack_require__(692); +const core = __importStar(__webpack_require__(470)); +const toolCache = __importStar(__webpack_require__(533)); +const path_1 = __importDefault(__webpack_require__(622)); +const os_1 = __importDefault(__webpack_require__(87)); +/** + * Get the path to the `expo-cli` from cache, if any. + * Note, this cache is **NOT** shared between jobs. + * + * @see https://github.com/actions/toolkit/issues/47 + */ +function fromLocalCache(version) { + return __awaiter(this, void 0, void 0, function* () { + return toolCache.find('expo-cli', version); + }); +} +exports.fromLocalCache = fromLocalCache; +/** + * Store the root of `expo-cli` in the cache, for future reuse. + * Note, this cache is **NOT** shared between jobs. + * + * @see https://github.com/actions/toolkit/issues/47 + */ +function toLocalCache(root, version) { + return __awaiter(this, void 0, void 0, function* () { + return toolCache.cacheDir(root, 'expo-cli', version); + }); +} +exports.toLocalCache = toLocalCache; +/** + * Download the remotely stored `expo-cli` from cache, if any. + * Note, this cache is shared between jobs. + */ +function fromRemoteCache(version, packager, customCacheKey) { + return __awaiter(this, void 0, void 0, function* () { + // see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401 + const target = path_1.default.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os_1.default.arch()); + const cacheKey = customCacheKey || getRemoteKey(version, packager); + const hit = yield cache_1.restoreCache([target], cacheKey); + if (hit) { + return target; + } + }); +} +exports.fromRemoteCache = fromRemoteCache; +/** + * Store the root of `expo-cli` in the remote cache, for future reuse. + * Note, this cache is shared between jobs. + */ +function toRemoteCache(source, version, packager, customCacheKey) { + return __awaiter(this, void 0, void 0, function* () { + const cacheKey = customCacheKey || getRemoteKey(version, packager); + try { + yield cache_1.saveCache([source], cacheKey); + } + catch (error) { + if (error instanceof cache_1.ReserveCacheError) { + core.info('Skipping remote cache storage, encountered error:'); + core.info(error.message); + } + else { + throw error; + } + } + }); +} +exports.toRemoteCache = toRemoteCache; +/** + * Get the cache key to use when (re)storing the Expo CLI from remote cache. + */ +function getRemoteKey(version, packager) { + return `expo-cli-${process.platform}-${os_1.default.arch()}-${packager}-${version}`; +} /***/ }), @@ -107538,66 +107541,66 @@ module.exports = function resolve(x, options, callback) { /***/ (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.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 }); -exports.patchWatchers = void 0; -const core = __importStar(__webpack_require__(470)); -const cli = __importStar(__webpack_require__(986)); -/** - * Try to patch the default watcher/inotify limit. - * This is a limitation from GitHub Actions and might be an issue in some Expo projects. - * It sets the system's `fs.inotify` limits to a more sensible setting. - * - * @see https://github.com/expo/expo-github-action/issues/20 - */ -function patchWatchers() { - return __awaiter(this, void 0, void 0, function* () { - if (process.platform !== 'linux') { - return core.info('Skipping patch for watchers, not running on Linux...'); - } - core.info('Patching system watchers for the `ENOSPC` error...'); - try { - // see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177 - yield cli.exec('sudo sysctl fs.inotify.max_user_instances=524288'); - yield cli.exec('sudo sysctl fs.inotify.max_user_watches=524288'); - yield cli.exec('sudo sysctl fs.inotify.max_queued_events=524288'); - yield cli.exec('sudo sysctl -p'); - } - catch (_a) { - core.warning("Looks like we can't patch watchers/inotify limits, you might encouter the `ENOSPC` error."); - core.warning('For more info, https://github.com/expo/expo-github-action/issues/20'); - } - }); -} -exports.patchWatchers = patchWatchers; + +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.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 }); +exports.patchWatchers = void 0; +const core = __importStar(__webpack_require__(470)); +const cli = __importStar(__webpack_require__(986)); +/** + * Try to patch the default watcher/inotify limit. + * This is a limitation from GitHub Actions and might be an issue in some Expo projects. + * It sets the system's `fs.inotify` limits to a more sensible setting. + * + * @see https://github.com/expo/expo-github-action/issues/20 + */ +function patchWatchers() { + return __awaiter(this, void 0, void 0, function* () { + if (process.platform !== 'linux') { + return core.info('Skipping patch for watchers, not running on Linux...'); + } + core.info('Patching system watchers for the `ENOSPC` error...'); + try { + // see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177 + yield cli.exec('sudo sysctl fs.inotify.max_user_instances=524288'); + yield cli.exec('sudo sysctl fs.inotify.max_user_watches=524288'); + yield cli.exec('sudo sysctl fs.inotify.max_queued_events=524288'); + yield cli.exec('sudo sysctl -p'); + } + catch (_a) { + core.warning("Looks like we can't patch watchers/inotify limits, you might encouter the `ENOSPC` error."); + core.warning('For more info, https://github.com/expo/expo-github-action/issues/20'); + } + }); +} +exports.patchWatchers = patchWatchers; /***/ }), diff --git a/src/cache.ts b/src/cache.ts index be28543ca..5e3f4a904 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -1,4 +1,5 @@ import { ReserveCacheError, restoreCache, saveCache } from '@actions/cache'; +import * as core from '@actions/core'; import * as toolCache from '@actions/tool-cache'; import path from 'path'; import os from 'os'; @@ -49,8 +50,11 @@ export async function toRemoteCache(source: string, version: string, packager: s await saveCache([source], cacheKey); } catch (error) { if (error instanceof ReserveCacheError) { - console.log(`Skipping cache save: ${error.message}`); - } else throw error; + core.info('Skipping remote cache storage, encountered error:'); + core.info(error.message); + } else { + throw error; + } } } diff --git a/yarn.lock b/yarn.lock index 4e259bcb0..4be46efa0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,7 +17,7 @@ semver "^6.1.0" uuid "^3.3.3" -"@actions/core@^1.2.0", "@actions/core@^1.2.3", "@actions/core@^1.2.6": +"@actions/core@^1.2.0", "@actions/core@^1.2.3", "@actions/core@^1.2.4", "@actions/core@^1.2.6": version "1.2.6" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09" integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==