Skip to content

Commit

Permalink
Do not save/restore opam download cache
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Jan 11, 2025
1 parent 24cb118 commit cca615a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 127 deletions.
39 changes: 0 additions & 39 deletions dist/index.js

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

43 changes: 2 additions & 41 deletions dist/post/index.js

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

43 changes: 0 additions & 43 deletions packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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[],
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
});
}
2 changes: 0 additions & 2 deletions packages/setup-ocaml/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { exec } from "@actions/exec";
import {
restoreDuneCache,
restoreOpamCaches,
restoreOpamDownloadCache,
saveCygwinCache,
saveOpamCache,
} from "./cache.js";
Expand Down Expand Up @@ -85,7 +84,6 @@ export async function installer() {
} else {
await update();
}
await restoreOpamDownloadCache();
if (DUNE_CACHE) {
await restoreDuneCache();
await installDune();
Expand Down
3 changes: 1 addition & 2 deletions packages/setup-ocaml/src/post.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -10,7 +10,6 @@ async function run() {
await trimDuneCache();
await saveDuneCache();
}
await saveOpamDownloadCache();
process.exit(0);
} catch (error) {
if (error instanceof Error) {
Expand Down

0 comments on commit cca615a

Please sign in to comment.