Skip to content

Commit d071987

Browse files
authored
Merge pull request #890 from ocaml/better-opam-repo-handle
Faster set-up when a cache hit occurs
2 parents 01a166b + d67a46f commit d071987

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

dist/index.js

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

packages/setup-ocaml/src/installer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
repositoryAddAll,
2626
repositoryRemoveAll,
2727
setupOpam,
28+
update,
2829
} from "./opam.js";
2930
import { retrieveOpamLocalPackages } from "./packages.js";
3031
import { setupCygwin } from "./windows.js";
@@ -69,12 +70,14 @@ export async function installer() {
6970
core.addPath(CYGWIN_ROOT_BIN);
7071
}
7172
await setupOpam();
72-
await repositoryRemoveAll();
73-
await repositoryAddAll(OPAM_REPOSITORIES);
74-
const ocamlCompiler = await RESOLVED_COMPILER;
7573
if (!opamCacheHit) {
74+
await repositoryRemoveAll();
75+
await repositoryAddAll(OPAM_REPOSITORIES);
76+
const ocamlCompiler = await RESOLVED_COMPILER;
7677
await installOcaml(ocamlCompiler);
7778
await saveOpamCache();
79+
} else {
80+
await update();
7881
}
7982
if (DUNE_CACHE) {
8083
await restoreDuneCache();

packages/setup-ocaml/src/opam.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,9 @@ export async function repositoryRemoveAll() {
194194
}
195195
});
196196
}
197+
198+
export async function update() {
199+
await core.group("Update the list of available opam packages", async () => {
200+
await exec("opam", ["update"]);
201+
});
202+
}

0 commit comments

Comments
 (0)