From cca615a2b4197d2f2376805b9a6b7577874a106f Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sun, 12 Jan 2025 00:57:36 +0900 Subject: [PATCH] Do not save/restore opam download cache Signed-off-by: Sora Morimoto --- dist/index.js | 39 ------------------------ dist/post/index.js | 43 ++------------------------- packages/setup-ocaml/src/cache.ts | 43 --------------------------- packages/setup-ocaml/src/installer.ts | 2 -- packages/setup-ocaml/src/post.ts | 3 +- 5 files changed, 3 insertions(+), 127 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8f429c7b..31817da4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -168665,7 +168665,6 @@ async function setupCygwin() { - async function composeCygwinCacheKeys() { const cygwinVersion = await retrieveCygwinVersion(); const key = `${CACHE_PREFIX}-setup-ocaml-cygwin-${CYGWIN_MIRROR_ENCODED_URI}-${cygwinVersion}`; @@ -168707,21 +168706,6 @@ async function composeOpamCacheKeys() { lib_core.debug(`opam cache key: ${plainKey}`); return { key, restoreKeys }; } -async function composeOpamDownloadCacheKeys() { - const isWin = PLATFORM === "windows"; - const ocamlCompiler = await RESOLVED_COMPILER; - const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(); - const { runId, workflow, job } = lib_github.context; - const plainKey = [isWin, job, ocamlCompiler, repositoryUrls, workflow].join(); - const hash = external_node_crypto_.createHash("sha256").update(plainKey).digest("hex"); - const key = `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-${runId}`; - const restoreKeys = [ - key, - `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-`, - `${CACHE_PREFIX}-setup-ocaml-opam-download-`, - ]; - return { key, restoreKeys }; -} function composeCygwinCachePaths() { const cygwinRootSymlinkPath = external_node_path_namespaceObject.posix.join("/cygdrive", "d", "cygwin"); const cygwinLocalPackageDirectory = external_node_path_namespaceObject.join(GITHUB_WORKSPACE, CYGWIN_MIRROR_ENCODED_URI); @@ -168746,13 +168730,6 @@ function composeOpamCachePaths() { } return paths; } -function composeOpamDownloadCachePaths() { - const homeDir = external_node_os_.homedir(); - const opamDownloadCachePath = PLATFORM === "windows" - ? external_node_path_namespaceObject.join("D:", ".opam", "download-cache") - : external_node_path_namespaceObject.join(homeDir, ".opam", "download-cache"); - return [opamDownloadCachePath]; -} async function restoreCache(key, restoreKeys, paths) { if (!cache.isFeatureAvailable()) { lib_core.info("Actions cache service feature is unavailable"); @@ -168819,14 +168796,6 @@ async function restoreOpamCaches() { return { opamCacheHit, cygwinCacheHit }; }); } -async function restoreOpamDownloadCache() { - return await lib_core.group("Retrieve the opam download cache", async () => { - const { key, restoreKeys } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - const cacheKey = await restoreCache(key, restoreKeys, paths); - return cacheKey; - }); -} async function saveCygwinCache() { await lib_core.group("Save the Cygwin cache", async () => { const { key } = await composeCygwinCacheKeys(); @@ -168857,13 +168826,6 @@ async function saveOpamCache() { await saveCache(key, paths); }); } -async function saveOpamDownloadCache() { - await core.group("Save the opam download cache", async () => { - const { key } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - await saveCache(key, paths); - }); -} ;// CONCATENATED MODULE: ./src/dune.ts @@ -168969,7 +168931,6 @@ async function installer() { else { await update(); } - await restoreOpamDownloadCache(); if (DUNE_CACHE) { await restoreDuneCache(); await installDune(); diff --git a/dist/post/index.js b/dist/post/index.js index 667be861..3c1536a2 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -114665,8 +114665,6 @@ var external_node_process_ = __nccwpck_require__(1708); var lib_core = __nccwpck_require__(7184); ;// CONCATENATED MODULE: external "node:crypto" const external_node_crypto_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:crypto"); -// EXTERNAL MODULE: external "node:os" -var external_node_os_ = __nccwpck_require__(48161); ;// CONCATENATED MODULE: external "node:path" const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path"); // EXTERNAL MODULE: ../../node_modules/@actions/cache/lib/cache.js @@ -114677,6 +114675,8 @@ var lib_exec = __nccwpck_require__(19192); var lib_github = __nccwpck_require__(58064); // EXTERNAL MODULE: ../../node_modules/systeminformation/lib/index.js var lib = __nccwpck_require__(8134); +// EXTERNAL MODULE: external "node:os" +var external_node_os_ = __nccwpck_require__(48161); // EXTERNAL MODULE: ../../node_modules/yaml/dist/index.js var dist = __nccwpck_require__(33483); // EXTERNAL MODULE: ../../node_modules/semver/index.js @@ -114863,7 +114863,6 @@ const constants_RESOLVED_COMPILER = (async () => { - async function composeCygwinCacheKeys() { const cygwinVersion = await retrieveCygwinVersion(); const key = `${CACHE_PREFIX}-setup-ocaml-cygwin-${CYGWIN_MIRROR_ENCODED_URI}-${cygwinVersion}`; @@ -114905,21 +114904,6 @@ async function composeOpamCacheKeys() { core.debug(`opam cache key: ${plainKey}`); return { key, restoreKeys }; } -async function composeOpamDownloadCacheKeys() { - const isWin = constants_PLATFORM === "windows"; - const ocamlCompiler = await constants_RESOLVED_COMPILER; - const repositoryUrls = constants_OPAM_REPOSITORIES.map(([_, value]) => value).join(); - const { runId, workflow, job } = lib_github.context; - const plainKey = [isWin, job, ocamlCompiler, repositoryUrls, workflow].join(); - const hash = external_node_crypto_namespaceObject.createHash("sha256").update(plainKey).digest("hex"); - const key = `${constants_CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-${runId}`; - const restoreKeys = [ - key, - `${constants_CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-`, - `${constants_CACHE_PREFIX}-setup-ocaml-opam-download-`, - ]; - return { key, restoreKeys }; -} function composeCygwinCachePaths() { const cygwinRootSymlinkPath = path.posix.join("/cygdrive", "d", "cygwin"); const cygwinLocalPackageDirectory = path.join(GITHUB_WORKSPACE, CYGWIN_MIRROR_ENCODED_URI); @@ -114944,13 +114928,6 @@ function composeOpamCachePaths() { } return paths; } -function composeOpamDownloadCachePaths() { - const homeDir = external_node_os_.homedir(); - const opamDownloadCachePath = constants_PLATFORM === "windows" - ? external_node_path_namespaceObject.join("D:", ".opam", "download-cache") - : external_node_path_namespaceObject.join(homeDir, ".opam", "download-cache"); - return [opamDownloadCachePath]; -} async function restoreCache(key, restoreKeys, paths) { if (!cache.isFeatureAvailable()) { core.info("Actions cache service feature is unavailable"); @@ -115017,14 +114994,6 @@ async function restoreOpamCaches() { return { opamCacheHit, cygwinCacheHit }; }); } -async function restoreOpamDownloadCache() { - return await core.group("Retrieve the opam download cache", async () => { - const { key, restoreKeys } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - const cacheKey = await restoreCache(key, restoreKeys, paths); - return cacheKey; - }); -} async function saveCygwinCache() { await core.group("Save the Cygwin cache", async () => { const { key } = await composeCygwinCacheKeys(); @@ -115055,13 +115024,6 @@ async function saveOpamCache() { await saveCache(key, paths); }); } -async function saveOpamDownloadCache() { - await lib_core.group("Save the opam download cache", async () => { - const { key } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - await saveCache(key, paths); - }); -} ;// CONCATENATED MODULE: ./src/dune.ts @@ -115106,7 +115068,6 @@ async function run() { await trimDuneCache(); await saveDuneCache(); } - await saveOpamDownloadCache(); external_node_process_.exit(0); } catch (error) { diff --git a/packages/setup-ocaml/src/cache.ts b/packages/setup-ocaml/src/cache.ts index 116eca68..5d2d7712 100644 --- a/packages/setup-ocaml/src/cache.ts +++ b/packages/setup-ocaml/src/cache.ts @@ -1,5 +1,4 @@ import * as crypto from "node:crypto"; -import * as os from "node:os"; import * as path from "node:path"; import * as cache from "@actions/cache"; import * as core from "@actions/core"; @@ -66,22 +65,6 @@ async function composeOpamCacheKeys() { return { key, restoreKeys }; } -async function composeOpamDownloadCacheKeys() { - const isWin = PLATFORM === "windows"; - const ocamlCompiler = await RESOLVED_COMPILER; - const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(); - const { runId, workflow, job } = github.context; - const plainKey = [isWin, job, ocamlCompiler, repositoryUrls, workflow].join(); - const hash = crypto.createHash("sha256").update(plainKey).digest("hex"); - const key = `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-${runId}`; - const restoreKeys = [ - key, - `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-`, - `${CACHE_PREFIX}-setup-ocaml-opam-download-`, - ]; - return { key, restoreKeys }; -} - function composeCygwinCachePaths() { const cygwinRootSymlinkPath = path.posix.join("/cygdrive", "d", "cygwin"); const cygwinLocalPackageDirectory = path.join( @@ -121,15 +104,6 @@ function composeOpamCachePaths() { return paths; } -function composeOpamDownloadCachePaths() { - const homeDir = os.homedir(); - const opamDownloadCachePath = - PLATFORM === "windows" - ? path.join("D:", ".opam", "download-cache") - : path.join(homeDir, ".opam", "download-cache"); - return [opamDownloadCachePath]; -} - async function restoreCache( key: string, restoreKeys: string[], @@ -211,15 +185,6 @@ export async function restoreOpamCaches() { }); } -export async function restoreOpamDownloadCache() { - return await core.group("Retrieve the opam download cache", async () => { - const { key, restoreKeys } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - const cacheKey = await restoreCache(key, restoreKeys, paths); - return cacheKey; - }); -} - export async function saveCygwinCache() { await core.group("Save the Cygwin cache", async () => { const { key } = await composeCygwinCacheKeys(); @@ -252,11 +217,3 @@ export async function saveOpamCache() { await saveCache(key, paths); }); } - -export async function saveOpamDownloadCache() { - await core.group("Save the opam download cache", async () => { - const { key } = await composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - await saveCache(key, paths); - }); -} diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 54a0dbe5..d58dd853 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -6,7 +6,6 @@ import { exec } from "@actions/exec"; import { restoreDuneCache, restoreOpamCaches, - restoreOpamDownloadCache, saveCygwinCache, saveOpamCache, } from "./cache.js"; @@ -85,7 +84,6 @@ export async function installer() { } else { await update(); } - await restoreOpamDownloadCache(); if (DUNE_CACHE) { await restoreDuneCache(); await installDune(); diff --git a/packages/setup-ocaml/src/post.ts b/packages/setup-ocaml/src/post.ts index aadcb021..5aa8d51a 100644 --- a/packages/setup-ocaml/src/post.ts +++ b/packages/setup-ocaml/src/post.ts @@ -1,6 +1,6 @@ import * as process from "node:process"; import * as core from "@actions/core"; -import { saveDuneCache, saveOpamDownloadCache } from "./cache.js"; +import { saveDuneCache } from "./cache.js"; import { DUNE_CACHE } from "./constants.js"; import { trimDuneCache } from "./dune.js"; @@ -10,7 +10,6 @@ async function run() { await trimDuneCache(); await saveDuneCache(); } - await saveOpamDownloadCache(); process.exit(0); } catch (error) { if (error instanceof Error) {