From 8b4a3e7019684879dc5d242a01aa2201acf4e240 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Fri, 14 Jun 2024 09:37:36 +0900 Subject: [PATCH] faster win setup Signed-off-by: Sora Morimoto --- dist/index.js | 17 +++++++++++------ packages/setup-ocaml/src/installer.ts | 20 ++++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index 52c841bd..d8f29a4e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -110524,6 +110524,12 @@ async function getOpamLocalPackages() { +async function restoreOpamCaches() { + const [opamCacheHit, cygwinCacheHit] = await Promise.all(PLATFORM === "windows" + ? [restoreOpamCache(), restoreCygwinCache()] + : [restoreOpamCache()]); + return { opamCacheHit, cygwinCacheHit }; +} async function installer() { if (lib_core.isDebug()) { lib_core.exportVariable("OPAMVERBOSE", 1); @@ -110551,13 +110557,12 @@ async function installer() { ]); await (0,lib_exec.exec)("fsutil", ["behavior", "query", "SymlinkEvaluation"]); }); - const cygwinCacheHit = await restoreCygwinCache(); - if (!cygwinCacheHit) { - await setupCygwin(); - await saveCygwinCache(); - } } - const opamCacheHit = await restoreOpamCache(); + const { opamCacheHit, cygwinCacheHit } = await restoreOpamCaches(); + if (!cygwinCacheHit && PLATFORM === "windows") { + await setupCygwin(); + await saveCygwinCache(); + } await setupOpam(); await repositoryRemoveAll(); await repositoryAddAll(OPAM_REPOSITORIES); diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 8f029770..2d5c9dbf 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -31,6 +31,15 @@ import { getOpamLocalPackages } from "./packages.js"; import { resolveCompiler } from "./version.js"; import { setupCygwin } from "./windows.js"; +async function restoreOpamCaches() { + const [opamCacheHit, cygwinCacheHit] = await Promise.all( + PLATFORM === "windows" + ? [restoreOpamCache(), restoreCygwinCache()] + : [restoreOpamCache()], + ); + return { opamCacheHit, cygwinCacheHit }; +} + export async function installer() { if (core.isDebug()) { core.exportVariable("OPAMVERBOSE", 1); @@ -58,13 +67,12 @@ export async function installer() { ]); await exec("fsutil", ["behavior", "query", "SymlinkEvaluation"]); }); - const cygwinCacheHit = await restoreCygwinCache(); - if (!cygwinCacheHit) { - await setupCygwin(); - await saveCygwinCache(); - } } - const opamCacheHit = await restoreOpamCache(); + const { opamCacheHit, cygwinCacheHit } = await restoreOpamCaches(); + if (!cygwinCacheHit && PLATFORM === "windows") { + await setupCygwin(); + await saveCygwinCache(); + } await setupOpam(); await repositoryRemoveAll(); await repositoryAddAll(OPAM_REPOSITORIES);