Skip to content

Commit

Permalink
Merge pull request #919 from ocaml/revert-918-opam-update-depext
Browse files Browse the repository at this point in the history
Revert "Run `opam update --depext` before installing system dependencies"
  • Loading branch information
smorimoto authored Dec 24, 2024
2 parents 097318b + 4470014 commit fbedf5f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
23 changes: 21 additions & 2 deletions dist/index.js

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

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

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

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

Please sign in to comment.