Skip to content

Commit

Permalink
Merge pull request #905 from ocaml/fix-opam-download-cache-win
Browse files Browse the repository at this point in the history
Fix opam download cache key on Windows
  • Loading branch information
smorimoto authored Dec 5, 2024
2 parents 260dbdc + eccf3fc commit ab20e84
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
19 changes: 9 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions dist/post/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function composeCygwinCacheKeys() {
async function composeDuneCacheKeys() {
const { workflow, job, runId } = github.context;
const ocamlCompiler = await RESOLVED_COMPILER;
const plainKey = [ocamlCompiler, workflow, job].join(",");
const plainKey = [ocamlCompiler, workflow, job].join();
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
const key = `${CACHE_PREFIX}-setup-ocaml-dune-${PLATFORM}-${ARCHITECTURE}-${hash}-${runId}`;
const restoreKeys = [
Expand All @@ -48,7 +48,7 @@ async function composeOpamCacheKeys() {
const { version: opamVersion } = await retrieveLatestOpamRelease();
const sandbox = OPAM_DISABLE_SANDBOXING ? "nosandbox" : "sandbox";
const ocamlCompiler = await RESOLVED_COMPILER;
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(",");
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join();
const osInfo = await system.osInfo();
const plainKey = [
PLATFORM,
Expand All @@ -58,7 +58,7 @@ async function composeOpamCacheKeys() {
ocamlCompiler,
repositoryUrls,
sandbox,
].join(",");
].join();
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
const key = `${CACHE_PREFIX}-setup-ocaml-opam-${hash}`;
const restoreKeys = [key];
Expand All @@ -67,9 +67,10 @@ async function composeOpamCacheKeys() {
}

async function composeOpamDownloadCacheKeys() {
const isWin = PLATFORM === "windows";
const ocamlCompiler = await RESOLVED_COMPILER;
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(",");
const plainKey = [ocamlCompiler, repositoryUrls].join(",");
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join();
const plainKey = [isWin, ocamlCompiler, repositoryUrls].join();
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
const { runId } = github.context;
const key = `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-${runId}`;
Expand Down Expand Up @@ -121,12 +122,11 @@ function composeOpamCachePaths() {
}

function composeOpamDownloadCachePaths() {
if (PLATFORM === "windows") {
const opamDownloadCachePath = path.join("D:", ".opam", "download-cache");
return [opamDownloadCachePath];
}
const homeDir = os.homedir();
const opamDownloadCachePath = path.join(homeDir, ".opam", "download-cache");
const opamDownloadCachePath =
PLATFORM === "windows"
? path.join("D:", ".opam", "download-cache")
: path.join(homeDir, ".opam", "download-cache");
return [opamDownloadCachePath];
}

Expand Down

0 comments on commit ab20e84

Please sign in to comment.