Skip to content

Commit

Permalink
Run opam update --depext before installing system dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Dec 24, 2024
1 parent 373b552 commit 582d101
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 47 deletions.
23 changes: 2 additions & 21 deletions dist/index.js

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

18 changes: 3 additions & 15 deletions packages/setup-ocaml/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import {
OPAM_DISABLE_SANDBOXING,
PLATFORM,
} from "./constants.js";
import {
installUnixSystemPackages,
updateUnixPackageIndexFiles,
} from "./unix.js";
import { installUnixSystemPackages } from "./unix.js";

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

async function initializeOpam() {
await core.group("Initialise opam state", async () => {
await exec("opam", ["update", "--depexts"]);
if (PLATFORM !== "windows") {
try {
await installUnixSystemPackages();
} catch (error) {
if (error instanceof Error) {
core.notice(
`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()}`,
);
}
await updateUnixPackageIndexFiles();
await installUnixSystemPackages();
}
await installUnixSystemPackages();
}
const extraOptions = [];
if (PLATFORM === "windows") {
Expand Down
11 changes: 0 additions & 11 deletions packages/setup-ocaml/src/unix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,3 @@ export async function installUnixSystemPackages() {
}
}
}

export async function updateUnixPackageIndexFiles() {
const isGitHubRunner = process.env.GITHUB_ACTIONS === "true";
if (isGitHubRunner) {
if (PLATFORM === "linux") {
await exec("sudo", ["apt-get", "update"]);
} else if (PLATFORM === "macos") {
await exec("brew", ["update"]);
}
}
}

0 comments on commit 582d101

Please sign in to comment.