Skip to content

Commit fbedf5f

Browse files
authored
Merge pull request #919 from ocaml/revert-918-opam-update-depext
Revert "Run `opam update --depext` before installing system dependencies"
2 parents 097318b + 4470014 commit fbedf5f

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

dist/index.js

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

packages/setup-ocaml/src/opam.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import {
1313
OPAM_DISABLE_SANDBOXING,
1414
PLATFORM,
1515
} from "./constants.js";
16-
import { installUnixSystemPackages } from "./unix.js";
16+
import {
17+
installUnixSystemPackages,
18+
updateUnixPackageIndexFiles,
19+
} from "./unix.js";
1720

1821
export async function retrieveLatestOpamRelease() {
1922
const semverRange = ALLOW_PRERELEASE_OPAM ? "*" : "<2.4.0";
@@ -85,9 +88,18 @@ async function acquireOpam() {
8588

8689
async function initializeOpam() {
8790
await core.group("Initialise opam state", async () => {
88-
await exec("opam", ["update", "--depexts"]);
8991
if (PLATFORM !== "windows") {
90-
await installUnixSystemPackages();
92+
try {
93+
await installUnixSystemPackages();
94+
} catch (error) {
95+
if (error instanceof Error) {
96+
core.notice(
97+
`An error has been caught in some system package index files, so the system package index files have been re-synchronised, and the system package installation has been retried: ${error.message.toLocaleLowerCase()}`,
98+
);
99+
}
100+
await updateUnixPackageIndexFiles();
101+
await installUnixSystemPackages();
102+
}
91103
}
92104
const extraOptions = [];
93105
if (PLATFORM === "windows") {

packages/setup-ocaml/src/unix.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,14 @@ export async function installUnixSystemPackages() {
5656
}
5757
}
5858
}
59+
60+
export async function updateUnixPackageIndexFiles() {
61+
const isGitHubRunner = process.env.GITHUB_ACTIONS === "true";
62+
if (isGitHubRunner) {
63+
if (PLATFORM === "linux") {
64+
await exec("sudo", ["apt-get", "update"]);
65+
} else if (PLATFORM === "macos") {
66+
await exec("brew", ["update"]);
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)