Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/dune.mjs → dist/cache.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.mjs

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

22 changes: 0 additions & 22 deletions packages/setup-ocaml/src/dune.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
import * as core from "@actions/core";
import { exec } from "@actions/exec";
import * as github from "@actions/github";
import { octokit } from "./github-client.js";

const DUNE_CACHE_TOTAL_SIZE_MB = 5000;

export async function installDune() {
await core.group("Installing dune", async () => {
await exec("opam", ["install", "dune"]);
});
}

export async function trimDuneCache() {
await core.group("Clearing old dune cache files to save space", async () => {
const {
repo: { owner, repo },
runId: run_id,
} = github.context;
const {
data: { total_count: totalCount },
} = await octokit.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id,
});
const cacheSize = Math.floor(DUNE_CACHE_TOTAL_SIZE_MB / totalCount);
await exec("opam", ["exec", "--", "dune", "cache", "trim", `--size=${cacheSize}MB`]);
});
}
2 changes: 2 additions & 0 deletions packages/setup-ocaml/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export async function installer() {
await restoreDuneCache();
await installDune();
core.exportVariable("DUNE_CACHE_ROOT", DUNE_CACHE_ROOT);
core.exportVariable("DUNE_CACHE", "enabled");
core.exportVariable("DUNE_CACHE_STORAGE_MODE", "copy");
}
core.exportVariable("CLICOLOR_FORCE", "1");
if (OPAM_PIN) {
Expand Down
2 changes: 0 additions & 2 deletions packages/setup-ocaml/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import * as process from "node:process";
import * as core from "@actions/core";
import { saveDuneCache, saveOpamCache } from "./cache.js";
import { DUNE_CACHE, SAVE_OPAM_POST_RUN } from "./constants.js";
import { trimDuneCache } from "./dune.js";

async function run() {
try {
if (DUNE_CACHE) {
await trimDuneCache();
await saveDuneCache();
}
if (SAVE_OPAM_POST_RUN) {
Expand Down
Loading