Skip to content

Commit 4b9e2f8

Browse files
committed
Use core.group instead for more strict grouping
Signed-off-by: Sora Morimoto <sora@morimoto.io>
1 parent 01a0d3d commit 4b9e2f8

File tree

13 files changed

+624
-604
lines changed

13 files changed

+624
-604
lines changed

dist/index.js

+196-196
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post/index.js

+166-166
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lint-doc/dist/index.js

+12-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lint-fmt/dist/index.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lint-opam/dist/index.js

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lint-doc/src/opam.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import * as core from "@actions/core";
22
import { exec } from "@actions/exec";
33

44
export async function installOpamPackages() {
5-
core.startGroup("Install opam packages");
6-
await exec("opam", ["install", ".", "--deps-only", "--with-doc"]);
7-
core.endGroup();
5+
await core.group("Install opam packages", async () => {
6+
await exec("opam", ["install", ".", "--deps-only", "--with-doc"]);
7+
});
88
}
99

1010
export async function installOdoc() {
11-
core.startGroup("Install odoc");
12-
await exec("opam", ["depext", "--install", "conf-m4", "dune", "odoc>=1.5.0"]);
13-
core.endGroup();
11+
await core.group("Install odoc", async () => {
12+
await exec("opam", [
13+
"depext",
14+
"--install",
15+
"conf-m4",
16+
"dune",
17+
"odoc>=1.5.0",
18+
]);
19+
});
1420
}

packages/lint-fmt/src/opam.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as core from "@actions/core";
22
import { exec } from "@actions/exec";
33

44
export async function installOcamlformat(version: string) {
5-
core.startGroup("Install ocamlformat");
6-
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
7-
core.endGroup();
5+
await core.group("Install ocamlformat", async () => {
6+
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
7+
});
88
}

packages/lint-opam/src/opam.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import * as core from "@actions/core";
22
import { exec } from "@actions/exec";
33

44
export async function installOpamPackages() {
5-
core.startGroup("Install opam packages");
6-
await exec("opam", [
7-
"install",
8-
".",
9-
"--deps-only",
10-
"--with-test",
11-
"--with-doc",
12-
]);
13-
core.endGroup();
5+
await core.group("Install opam packages", async () => {
6+
await exec("opam", [
7+
"install",
8+
".",
9+
"--deps-only",
10+
"--with-test",
11+
"--with-doc",
12+
]);
13+
});
1414
}
1515

1616
export async function installOpamDuneLint() {
17-
core.startGroup("Install opam-dune-lint");
18-
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
19-
core.endGroup();
17+
await core.group("Install opam-dune-lint", async () => {
18+
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
19+
});
2020
}

packages/setup-ocaml/src/cache.ts

+50-50
Original file line numberDiff line numberDiff line change
@@ -220,75 +220,75 @@ async function saveCache(key: string, paths: string[]) {
220220
}
221221

222222
export async function restoreCygwinCache() {
223-
core.startGroup("Retrieve the Cygwin cache");
224-
const { key, restoreKeys } = await composeCygwinCacheKeys();
225-
const paths = composeCygwinCachePaths();
226-
await restoreCache(key, restoreKeys, paths);
227-
core.endGroup();
223+
await core.group("Retrieve the Cygwin cache", async () => {
224+
const { key, restoreKeys } = await composeCygwinCacheKeys();
225+
const paths = composeCygwinCachePaths();
226+
await restoreCache(key, restoreKeys, paths);
227+
});
228228
}
229229

230230
export async function saveCygwinCache() {
231-
core.startGroup("Save the Cygwin cache");
232-
const { key } = await composeCygwinCacheKeys();
233-
const paths = composeCygwinCachePaths();
234-
await saveCache(key, paths);
235-
core.endGroup();
231+
await core.group("Save the Cygwin cache", async () => {
232+
const { key } = await composeCygwinCacheKeys();
233+
const paths = composeCygwinCachePaths();
234+
await saveCache(key, paths);
235+
});
236236
}
237237

238238
export async function restoreDuneCache() {
239-
core.startGroup("Retrieve the dune cache");
240-
const { key, restoreKeys } = composeDuneCacheKeys();
241-
const paths = composeDuneCachePaths();
242-
await restoreCache(key, restoreKeys, paths);
243-
core.endGroup();
239+
await core.group("Retrieve the dune cache", async () => {
240+
const { key, restoreKeys } = composeDuneCacheKeys();
241+
const paths = composeDuneCachePaths();
242+
await restoreCache(key, restoreKeys, paths);
243+
});
244244
}
245245

246246
export async function saveDuneCache() {
247-
core.startGroup("Save the dune cache");
248-
const { key } = composeDuneCacheKeys();
249-
const paths = composeDuneCachePaths();
250-
await saveCache(key, paths);
251-
core.endGroup();
247+
await core.group("Save the dune cache", async () => {
248+
const { key } = composeDuneCacheKeys();
249+
const paths = composeDuneCachePaths();
250+
await saveCache(key, paths);
251+
});
252252
}
253253

254254
export async function restoreOpamCache() {
255-
core.startGroup("Retrieve the opam cache");
256-
const { key, restoreKeys } = await composeOpamCacheKeys();
257-
const paths = composeOpamCachePaths();
258-
const cacheKey = await restoreCache(key, restoreKeys, paths);
259-
core.endGroup();
260-
return cacheKey;
255+
return await core.group("Retrieve the opam cache", async () => {
256+
const { key, restoreKeys } = await composeOpamCacheKeys();
257+
const paths = composeOpamCachePaths();
258+
const cacheKey = await restoreCache(key, restoreKeys, paths);
259+
return cacheKey;
260+
});
261261
}
262262

263263
export async function saveOpamCache() {
264-
core.startGroup("Save the opam cache");
265-
await exec("opam", [
266-
"clean",
267-
"--all-switches",
268-
"--download-cache",
269-
"--logs",
270-
"--repo-cache",
271-
"--unused-repositories",
272-
]);
273-
const { key } = await composeOpamCacheKeys();
274-
const paths = composeOpamCachePaths();
275-
await saveCache(key, paths);
276-
core.endGroup();
264+
await core.group("Save the opam cache", async () => {
265+
await exec("opam", [
266+
"clean",
267+
"--all-switches",
268+
"--download-cache",
269+
"--logs",
270+
"--repo-cache",
271+
"--unused-repositories",
272+
]);
273+
const { key } = await composeOpamCacheKeys();
274+
const paths = composeOpamCachePaths();
275+
await saveCache(key, paths);
276+
});
277277
}
278278

279279
export async function restoreOpamDownloadCache() {
280-
core.startGroup("Retrieve the opam download cache");
281-
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
282-
const paths = composeOpamDownloadCachePaths();
283-
const cacheKey = await restoreCache(key, restoreKeys, paths);
284-
core.endGroup();
285-
return cacheKey;
280+
return await core.group("Retrieve the opam download cache", async () => {
281+
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
282+
const paths = composeOpamDownloadCachePaths();
283+
const cacheKey = await restoreCache(key, restoreKeys, paths);
284+
return cacheKey;
285+
});
286286
}
287287

288288
export async function saveOpamDownloadCache() {
289-
core.startGroup("Save the opam download cache");
290-
const { key } = composeOpamDownloadCacheKeys();
291-
const paths = composeOpamDownloadCachePaths();
292-
await saveCache(key, paths);
293-
core.endGroup();
289+
await core.group("Save the opam download cache", async () => {
290+
const { key } = composeOpamDownloadCacheKeys();
291+
const paths = composeOpamDownloadCachePaths();
292+
await saveCache(key, paths);
293+
});
294294
}

packages/setup-ocaml/src/depext.ts

+23-18
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@ import { OPAM_DEPEXT_FLAGS, Platform } from "./constants";
77
import { getPlatform } from "./system";
88

99
export async function installDepext(ocamlVersion: string) {
10-
core.startGroup("Install depext");
11-
const platform = getPlatform();
12-
const depextCygwinports =
13-
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
14-
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
15-
if (platform === Platform.Win32) {
16-
let base = "";
17-
if (ocamlVersion.includes("mingw64")) {
18-
base = "x86_64-w64-mingw32";
19-
} else if (ocamlVersion.includes("mingw32")) {
20-
base = "i686-w64-mingw32";
10+
await core.group("Install depext", async () => {
11+
const platform = getPlatform();
12+
const depextCygwinports =
13+
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
14+
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
15+
if (platform === Platform.Win32) {
16+
let base = "";
17+
if (ocamlVersion.includes("mingw64")) {
18+
base = "x86_64-w64-mingw32";
19+
} else if (ocamlVersion.includes("mingw32")) {
20+
base = "i686-w64-mingw32";
21+
}
22+
core.addPath(
23+
path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"),
24+
);
2125
}
22-
core.addPath(path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"));
23-
}
24-
core.endGroup();
26+
});
2527
}
2628

2729
export async function installDepextPackages(fpaths: string[]) {
28-
core.startGroup("Install system packages required by opam packages");
29-
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
30-
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
31-
core.endGroup();
30+
await core.group(
31+
"Install system packages required by opam packages",
32+
async () => {
33+
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
34+
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
35+
},
36+
);
3237
}

packages/setup-ocaml/src/dune.ts

+26-23
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,33 @@ const {
1010
} = github.context;
1111

1212
export async function installDune() {
13-
core.startGroup("Install dune");
14-
await exec("opam", ["depext", "--install", "dune"]);
15-
core.endGroup();
13+
await core.group("Install dune", async () => {
14+
await exec("opam", ["depext", "--install", "dune"]);
15+
});
1616
}
1717

1818
export async function trimDuneCache() {
19-
core.startGroup("Remove oldest files from the dune cache to free space");
20-
const octokit = github.getOctokit(GITHUB_TOKEN);
21-
const {
22-
data: { total_count: totalCount },
23-
} = await octokit.rest.actions.listJobsForWorkflowRun({
24-
owner,
25-
repo,
26-
run_id,
27-
});
28-
const cacheSize = Math.floor(5000 / totalCount);
29-
await exec("opam", [
30-
"exec",
31-
"--",
32-
"dune",
33-
"cache",
34-
"trim",
35-
"--size",
36-
`${cacheSize}MB`,
37-
]);
38-
core.endGroup();
19+
await core.group(
20+
"Remove oldest files from the dune cache to free space",
21+
async () => {
22+
const octokit = github.getOctokit(GITHUB_TOKEN);
23+
const {
24+
data: { total_count: totalCount },
25+
} = await octokit.rest.actions.listJobsForWorkflowRun({
26+
owner,
27+
repo,
28+
run_id,
29+
});
30+
const cacheSize = Math.floor(5000 / totalCount);
31+
await exec("opam", [
32+
"exec",
33+
"--",
34+
"dune",
35+
"cache",
36+
"trim",
37+
"--size",
38+
`${cacheSize}MB`,
39+
]);
40+
},
41+
);
3942
}

0 commit comments

Comments
 (0)