Skip to content

Commit f2e8d03

Browse files
authored
Merge pull request #440 from ocaml/retry-system-package-installations
Update the package index if the system package installation fails
2 parents 942d5e7 + 79cabf3 commit f2e8d03

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to
88

99
## [unreleased]
1010

11+
### Changed
12+
13+
- Update the package index if the system package installation fails.
14+
1115
## [2.0.0]
1216

1317
### Changed

dist/index.js

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post/index.js

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-ocaml/opam.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function acquireOpamUnix() {
9595
}
9696
}
9797

98-
async function initializeOpamUnix() {
98+
async function installUnixSystemPackages() {
9999
const isGitHubRunner = process.env.ImageOS !== undefined;
100100
const platform = getPlatform();
101101
if (isGitHubRunner) {
@@ -120,6 +120,30 @@ async function initializeOpamUnix() {
120120
await exec("brew", ["install", "darcs", "gpatch", "mercurial"]);
121121
}
122122
}
123+
}
124+
125+
async function updateUnixPackageIndexFiles() {
126+
const isGitHubRunner = process.env.ImageOS !== undefined;
127+
const platform = getPlatform();
128+
if (isGitHubRunner) {
129+
if (platform === Platform.Linux) {
130+
await exec("sudo", ["apt-get", "update"]);
131+
} else if (platform === Platform.MacOS) {
132+
await exec("brew", ["update"]);
133+
}
134+
}
135+
}
136+
137+
async function initializeOpamUnix() {
138+
try {
139+
await installUnixSystemPackages();
140+
} catch (error) {
141+
if (error instanceof Error) {
142+
core.info(error.message);
143+
}
144+
await updateUnixPackageIndexFiles();
145+
await installUnixSystemPackages();
146+
}
123147
const disableSandboxing = [];
124148
if (OPAM_DISABLE_SANDBOXING) {
125149
disableSandboxing.push("--disable-sandboxing");

0 commit comments

Comments
 (0)