Skip to content

Commit

Permalink
Use core.group instead for more strict grouping
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <[email protected]>
  • Loading branch information
smorimoto committed Nov 4, 2023
1 parent 01a0d3d commit 6e9652e
Show file tree
Hide file tree
Showing 13 changed files with 1,280 additions and 1,040 deletions.
725 changes: 395 additions & 330 deletions dist/index.js

Large diffs are not rendered by default.

665 changes: 365 additions & 300 deletions dist/post/index.js

Large diffs are not rendered by default.

160 changes: 98 additions & 62 deletions lint-doc/dist/index.js

Large diffs are not rendered by default.

148 changes: 89 additions & 59 deletions lint-fmt/dist/index.js

Large diffs are not rendered by default.

166 changes: 98 additions & 68 deletions lint-opam/dist/index.js

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions packages/lint-doc/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

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

export async function installOdoc() {
core.startGroup("Install odoc");
await exec("opam", ["depext", "--install", "conf-m4", "dune", "odoc>=1.5.0"]);
core.endGroup();
await core.group("Install odoc", async () => {
await exec("opam", [
"depext",
"--install",
"conf-m4",
"dune",
"odoc>=1.5.0",
]);
});
}
6 changes: 3 additions & 3 deletions packages/lint-fmt/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

export async function installOcamlformat(version: string) {
core.startGroup("Install ocamlformat");
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
core.endGroup();
await core.group("Install ocamlformat", async () => {
await exec("opam", ["depext", "--install", `ocamlformat=${version}`]);
});
}
24 changes: 12 additions & 12 deletions packages/lint-opam/src/opam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import * as core from "@actions/core";
import { exec } from "@actions/exec";

export async function installOpamPackages() {
core.startGroup("Install opam packages");
await exec("opam", [
"install",
".",
"--deps-only",
"--with-test",
"--with-doc",
]);
core.endGroup();
await core.group("Install opam packages", async () => {
await exec("opam", [
"install",
".",
"--deps-only",
"--with-test",
"--with-doc",
]);
});
}

export async function installOpamDuneLint() {
core.startGroup("Install opam-dune-lint");
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
core.endGroup();
await core.group("Install opam-dune-lint", async () => {
await exec("opam", ["depext", "--install", "opam-dune-lint"]);
});
}
100 changes: 50 additions & 50 deletions packages/setup-ocaml/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,75 +220,75 @@ async function saveCache(key: string, paths: string[]) {
}

export async function restoreCygwinCache() {
core.startGroup("Retrieve the Cygwin cache");
const { key, restoreKeys } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await restoreCache(key, restoreKeys, paths);
core.endGroup();
await core.group("Retrieve the Cygwin cache", async () => {
const { key, restoreKeys } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await restoreCache(key, restoreKeys, paths);
});
}

export async function saveCygwinCache() {
core.startGroup("Save the Cygwin cache");
const { key } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the Cygwin cache", async () => {
const { key } = await composeCygwinCacheKeys();
const paths = composeCygwinCachePaths();
await saveCache(key, paths);
});
}

export async function restoreDuneCache() {
core.startGroup("Retrieve the dune cache");
const { key, restoreKeys } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await restoreCache(key, restoreKeys, paths);
core.endGroup();
await core.group("Retrieve the dune cache", async () => {
const { key, restoreKeys } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await restoreCache(key, restoreKeys, paths);
});
}

export async function saveDuneCache() {
core.startGroup("Save the dune cache");
const { key } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the dune cache", async () => {
const { key } = composeDuneCacheKeys();
const paths = composeDuneCachePaths();
await saveCache(key, paths);
});
}

export async function restoreOpamCache() {
core.startGroup("Retrieve the opam cache");
const { key, restoreKeys } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
core.endGroup();
return cacheKey;
return await core.group("Retrieve the opam cache", async () => {
const { key, restoreKeys } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
return cacheKey;
});
}

export async function saveOpamCache() {
core.startGroup("Save the opam cache");
await exec("opam", [
"clean",
"--all-switches",
"--download-cache",
"--logs",
"--repo-cache",
"--unused-repositories",
]);
const { key } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the opam cache", async () => {
await exec("opam", [
"clean",
"--all-switches",
"--download-cache",
"--logs",
"--repo-cache",
"--unused-repositories",
]);
const { key } = await composeOpamCacheKeys();
const paths = composeOpamCachePaths();
await saveCache(key, paths);
});
}

export async function restoreOpamDownloadCache() {
core.startGroup("Retrieve the opam download cache");
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
core.endGroup();
return cacheKey;
return await core.group("Retrieve the opam download cache", async () => {
const { key, restoreKeys } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
const cacheKey = await restoreCache(key, restoreKeys, paths);
return cacheKey;
});
}

export async function saveOpamDownloadCache() {
core.startGroup("Save the opam download cache");
const { key } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
await saveCache(key, paths);
core.endGroup();
await core.group("Save the opam download cache", async () => {
const { key } = composeOpamDownloadCacheKeys();
const paths = composeOpamDownloadCachePaths();
await saveCache(key, paths);
});
}
41 changes: 23 additions & 18 deletions packages/setup-ocaml/src/depext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ import { OPAM_DEPEXT_FLAGS, Platform } from "./constants";
import { getPlatform } from "./system";

export async function installDepext(ocamlVersion: string) {
core.startGroup("Install depext");
const platform = getPlatform();
const depextCygwinports =
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
if (platform === Platform.Win32) {
let base = "";
if (ocamlVersion.includes("mingw64")) {
base = "x86_64-w64-mingw32";
} else if (ocamlVersion.includes("mingw32")) {
base = "i686-w64-mingw32";
await core.group("Install depext", async () => {
const platform = getPlatform();
const depextCygwinports =
platform === Platform.Win32 ? ["depext-cygwinports"] : [];
await exec("opam", ["install", "opam-depext", ...depextCygwinports]);
if (platform === Platform.Win32) {
let base = "";
if (ocamlVersion.includes("mingw64")) {
base = "x86_64-w64-mingw32";
} else if (ocamlVersion.includes("mingw32")) {
base = "i686-w64-mingw32";
}
core.addPath(
path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"),
);
}
core.addPath(path.posix.join("/", "usr", base, "sys-root", "mingw", "bin"));
}
core.endGroup();
});
}

export async function installDepextPackages(fpaths: string[]) {
core.startGroup("Install system packages required by opam packages");
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
core.endGroup();
await core.group(
"Install system packages required by opam packages",
async () => {
const fnames = fpaths.map((fpath) => path.basename(fpath, ".opam"));
await exec("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]);
},
);
}
49 changes: 26 additions & 23 deletions packages/setup-ocaml/src/dune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@ const {
} = github.context;

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

export async function trimDuneCache() {
core.startGroup("Remove oldest files from the dune cache to free space");
const octokit = github.getOctokit(GITHUB_TOKEN);
const {
data: { total_count: totalCount },
} = await octokit.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id,
});
const cacheSize = Math.floor(5000 / totalCount);
await exec("opam", [
"exec",
"--",
"dune",
"cache",
"trim",
"--size",
`${cacheSize}MB`,
]);
core.endGroup();
await core.group(
"Remove oldest files from the dune cache to free space",
async () => {
const octokit = github.getOctokit(GITHUB_TOKEN);
const {
data: { total_count: totalCount },
} = await octokit.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id,
});
const cacheSize = Math.floor(5000 / totalCount);
await exec("opam", [
"exec",
"--",
"dune",
"cache",
"trim",
"--size",
`${cacheSize}MB`,
]);
},
);
}
24 changes: 12 additions & 12 deletions packages/setup-ocaml/src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ export async function installer() {
core.exportVariable("OPAMROOT", opamRoot);
}
if (platform === Platform.Win32) {
core.startGroup("Change the file system behavior parameters");
await exec("fsutil", ["behavior", "query", "SymlinkEvaluation"]);
// https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-behavior
await exec("fsutil", [
"behavior",
"set",
"symlinkEvaluation",
"R2L:1",
"R2R:1",
]);
await exec("fsutil", ["behavior", "query", "SymlinkEvaluation"]);
core.endGroup();
await core.group("Change the file system behavior parameters", async () => {
await exec("fsutil", ["behavior", "query", "SymlinkEvaluation"]);
// https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-behavior
await exec("fsutil", [
"behavior",
"set",
"symlinkEvaluation",
"R2L:1",
"R2R:1",
]);
await exec("fsutil", ["behavior", "query", "SymlinkEvaluation"]);
});
}
if (platform === Platform.Win32) {
core.exportVariable("HOME", process.env["USERPROFILE"]);
Expand Down
Loading

0 comments on commit 6e9652e

Please sign in to comment.