Skip to content

Commit ab20e84

Browse files
authored
Merge pull request #905 from ocaml/fix-opam-download-cache-win
Fix opam download cache key on Windows
2 parents 260dbdc + eccf3fc commit ab20e84

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

dist/index.js

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post/index.js

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/setup-ocaml/src/cache.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function composeCygwinCacheKeys() {
3232
async function composeDuneCacheKeys() {
3333
const { workflow, job, runId } = github.context;
3434
const ocamlCompiler = await RESOLVED_COMPILER;
35-
const plainKey = [ocamlCompiler, workflow, job].join(",");
35+
const plainKey = [ocamlCompiler, workflow, job].join();
3636
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
3737
const key = `${CACHE_PREFIX}-setup-ocaml-dune-${PLATFORM}-${ARCHITECTURE}-${hash}-${runId}`;
3838
const restoreKeys = [
@@ -48,7 +48,7 @@ async function composeOpamCacheKeys() {
4848
const { version: opamVersion } = await retrieveLatestOpamRelease();
4949
const sandbox = OPAM_DISABLE_SANDBOXING ? "nosandbox" : "sandbox";
5050
const ocamlCompiler = await RESOLVED_COMPILER;
51-
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(",");
51+
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join();
5252
const osInfo = await system.osInfo();
5353
const plainKey = [
5454
PLATFORM,
@@ -58,7 +58,7 @@ async function composeOpamCacheKeys() {
5858
ocamlCompiler,
5959
repositoryUrls,
6060
sandbox,
61-
].join(",");
61+
].join();
6262
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
6363
const key = `${CACHE_PREFIX}-setup-ocaml-opam-${hash}`;
6464
const restoreKeys = [key];
@@ -67,9 +67,10 @@ async function composeOpamCacheKeys() {
6767
}
6868

6969
async function composeOpamDownloadCacheKeys() {
70+
const isWin = PLATFORM === "windows";
7071
const ocamlCompiler = await RESOLVED_COMPILER;
71-
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join(",");
72-
const plainKey = [ocamlCompiler, repositoryUrls].join(",");
72+
const repositoryUrls = OPAM_REPOSITORIES.map(([_, value]) => value).join();
73+
const plainKey = [isWin, ocamlCompiler, repositoryUrls].join();
7374
const hash = crypto.createHash("sha256").update(plainKey).digest("hex");
7475
const { runId } = github.context;
7576
const key = `${CACHE_PREFIX}-setup-ocaml-opam-download-${hash}-${runId}`;
@@ -121,12 +122,11 @@ function composeOpamCachePaths() {
121122
}
122123

123124
function composeOpamDownloadCachePaths() {
124-
if (PLATFORM === "windows") {
125-
const opamDownloadCachePath = path.join("D:", ".opam", "download-cache");
126-
return [opamDownloadCachePath];
127-
}
128125
const homeDir = os.homedir();
129-
const opamDownloadCachePath = path.join(homeDir, ".opam", "download-cache");
126+
const opamDownloadCachePath =
127+
PLATFORM === "windows"
128+
? path.join("D:", ".opam", "download-cache")
129+
: path.join(homeDir, ".opam", "download-cache");
130130
return [opamDownloadCachePath];
131131
}
132132

0 commit comments

Comments
 (0)