From 4b9e2f850bb50a92e8d7d0aa0b4120a2bc3b274c Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Sat, 4 Nov 2023 22:28:06 +0900 Subject: [PATCH] Use `core.group` instead for more strict grouping Signed-off-by: Sora Morimoto --- dist/index.js | 392 +++++++++++++------------- dist/post/index.js | 332 +++++++++++----------- lint-doc/dist/index.js | 18 +- lint-fmt/dist/index.js | 6 +- lint-opam/dist/index.js | 24 +- packages/lint-doc/src/opam.ts | 18 +- packages/lint-fmt/src/opam.ts | 6 +- packages/lint-opam/src/opam.ts | 24 +- packages/setup-ocaml/src/cache.ts | 100 +++---- packages/setup-ocaml/src/depext.ts | 41 +-- packages/setup-ocaml/src/dune.ts | 49 ++-- packages/setup-ocaml/src/installer.ts | 24 +- packages/setup-ocaml/src/opam.ts | 194 ++++++------- 13 files changed, 624 insertions(+), 604 deletions(-) diff --git a/dist/index.js b/dist/index.js index 2e0090af..6b8400d0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -144368,12 +144368,12 @@ async function initializeOpamUnix() { ]); } async function setupOpamUnix() { - lib_core.startGroup("Install opam"); - await acquireOpamUnix(); - lib_core.endGroup(); - lib_core.startGroup("Initialise the opam state"); - await initializeOpamUnix(); - lib_core.endGroup(); + await lib_core.group("Install opam", async () => { + await acquireOpamUnix(); + }); + await lib_core.group("Initialise the opam state", async () => { + await initializeOpamUnix(); + }); } async function setupCygwin() { const version = await getCygwinVersion(); @@ -144451,25 +144451,25 @@ async function initializeOpamWindows() { await external_node_fs_namespaceObject.promises.writeFile(opamCmd, data, { mode: 0o755 }); } async function setupOpamWindows() { - lib_core.startGroup("Prepare the Cygwin environment"); - lib_core.exportVariable("CYGWIN", "winsymlinks:native"); - lib_core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); - lib_core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); - lib_core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); - lib_core.addPath(CYGWIN_ROOT_WRAPPERBIN); - await setupCygwin(); - lib_core.endGroup(); + await lib_core.group("Prepare the Cygwin environment", async () => { + lib_core.exportVariable("CYGWIN", "winsymlinks:native"); + lib_core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); + lib_core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); + lib_core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); + lib_core.addPath(CYGWIN_ROOT_WRAPPERBIN); + await setupCygwin(); + }); await saveCygwinCache(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const originalPath = external_node_process_namespaceObject.env.PATH.split(external_node_path_namespaceObject.delimiter); const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; external_node_process_namespaceObject.env.PATH = patchedPath.join(external_node_path_namespaceObject.delimiter); - lib_core.startGroup("Install opam"); - await acquireOpamWindows(); - lib_core.endGroup(); - lib_core.startGroup("Initialise the opam state"); - await initializeOpamWindows(); - lib_core.endGroup(); + await lib_core.group("Install opam", async () => { + await acquireOpamWindows(); + }); + await lib_core.group("Initialise the opam state", async () => { + await initializeOpamWindows(); + }); external_node_process_namespaceObject.env.PATH = originalPath.join(external_node_path_namespaceObject.delimiter); } async function setupOpam() { @@ -144482,46 +144482,46 @@ async function setupOpam() { } } async function installOcaml(ocamlCompiler) { - lib_core.startGroup("Install OCaml"); - const platform = getPlatform(); - if (platform === Platform.Win32) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const originalPath = external_node_process_namespaceObject.env.PATH.split(external_node_path_namespaceObject.delimiter); - const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; - external_node_process_namespaceObject.env.PATH = patchedPath.join(external_node_path_namespaceObject.delimiter); - await (0,lib_exec.exec)("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - external_node_process_namespaceObject.env.PATH = originalPath.join(external_node_path_namespaceObject.delimiter); - } - else { - await (0,lib_exec.exec)("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - } - lib_core.endGroup(); + await lib_core.group("Install OCaml", async () => { + const platform = getPlatform(); + if (platform === Platform.Win32) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const originalPath = external_node_process_namespaceObject.env.PATH.split(external_node_path_namespaceObject.delimiter); + const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; + external_node_process_namespaceObject.env.PATH = patchedPath.join(external_node_path_namespaceObject.delimiter); + await (0,lib_exec.exec)("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + external_node_process_namespaceObject.env.PATH = originalPath.join(external_node_path_namespaceObject.delimiter); + } + else { + await (0,lib_exec.exec)("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + } + }); } async function pin(fpaths) { - lib_core.startGroup("Pin local packages"); - const opam = await findOpam(); - for (const fpath of fpaths) { - const fname = external_node_path_namespaceObject.basename(fpath, ".opam"); - const dname = external_node_path_namespaceObject.dirname(fpath); - await (0,lib_exec.exec)(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { - cwd: dname, - }); - } - lib_core.endGroup(); + await lib_core.group("Pin local packages", async () => { + const opam = await findOpam(); + for (const fpath of fpaths) { + const fname = external_node_path_namespaceObject.basename(fpath, ".opam"); + const dname = external_node_path_namespaceObject.dirname(fpath); + await (0,lib_exec.exec)(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { + cwd: dname, + }); + } + }); } async function repositoryAdd(name, address) { const opam = await findOpam(); @@ -144535,40 +144535,40 @@ async function repositoryAdd(name, address) { ]); } async function repositoryAddAll(repositories) { - const platform = getPlatform(); - let restore_autocrlf; - lib_core.startGroup("Initialise the opam repositories"); - // Works around the lack of https://github.com/ocaml/opam/pull/3882 when - // adding ocaml/opam-repository on Windows. Can be removed when the action - // switches to opam 2.2 - if (platform === Platform.Win32) { - const autocrlf = await (0,lib_exec.getExecOutput)("git", ["config", "--global", "core.autocrlf"], { ignoreReturnCode: true }); - if (autocrlf.stdout.trim() !== "input") { - if (autocrlf.exitCode === 0) { - restore_autocrlf = autocrlf.stdout.trim(); - } - else { - // eslint-disable-next-line unicorn/no-null - restore_autocrlf = null; // Unset the value at the end + await lib_core.group("Initialise the opam repositories", async () => { + const platform = getPlatform(); + let restore_autocrlf; + // Works around the lack of https://github.com/ocaml/opam/pull/3882 when + // adding ocaml/opam-repository on Windows. Can be removed when the action + // switches to opam 2.2 + if (platform === Platform.Win32) { + const autocrlf = await (0,lib_exec.getExecOutput)("git", ["config", "--global", "core.autocrlf"], { ignoreReturnCode: true }); + if (autocrlf.stdout.trim() !== "input") { + if (autocrlf.exitCode === 0) { + restore_autocrlf = autocrlf.stdout.trim(); + } + else { + // eslint-disable-next-line unicorn/no-null + restore_autocrlf = null; // Unset the value at the end + } } + await (0,lib_exec.exec)("git", ["config", "--global", "core.autocrlf", "input"]); } - await (0,lib_exec.exec)("git", ["config", "--global", "core.autocrlf", "input"]); - } - for (const [name, address] of repositories) { - await repositoryAdd(name, address); - } - if (restore_autocrlf === null) { - await (0,lib_exec.exec)("git", ["config", "--global", "--unset", "core.autocrlf"]); - } - else if (restore_autocrlf !== undefined) { - await (0,lib_exec.exec)("git", [ - "config", - "--global", - "core.autocrlf", - restore_autocrlf, - ]); - } - lib_core.endGroup(); + for (const [name, address] of repositories) { + await repositoryAdd(name, address); + } + if (restore_autocrlf === null) { + await (0,lib_exec.exec)("git", ["config", "--global", "--unset", "core.autocrlf"]); + } + else if (restore_autocrlf !== undefined) { + await (0,lib_exec.exec)("git", [ + "config", + "--global", + "core.autocrlf", + restore_autocrlf, + ]); + } + }); } async function repositoryRemove(name) { const opam = await findOpam(); @@ -144588,12 +144588,12 @@ async function repositoryList() { } } async function repositoryRemoveAll() { - lib_core.startGroup("Remove the opam repositories"); - const repositories = await repositoryList(); - for (const repository of repositories) { - await repositoryRemove(repository); - } - lib_core.endGroup(); + await lib_core.group("Remove the opam repositories", async () => { + const repositories = await repositoryList(); + for (const repository of repositories) { + await repositoryRemove(repository); + } + }); } ;// CONCATENATED MODULE: ./src/version.ts @@ -144844,70 +144844,70 @@ async function saveCache(key, paths) { } } async function restoreCygwinCache() { - lib_core.startGroup("Retrieve the Cygwin cache"); - const { key, restoreKeys } = await composeCygwinCacheKeys(); - const paths = composeCygwinCachePaths(); - await restoreCache(key, restoreKeys, paths); - lib_core.endGroup(); + await lib_core.group("Retrieve the Cygwin cache", async () => { + const { key, restoreKeys } = await composeCygwinCacheKeys(); + const paths = composeCygwinCachePaths(); + await restoreCache(key, restoreKeys, paths); + }); } async function saveCygwinCache() { - lib_core.startGroup("Save the Cygwin cache"); - const { key } = await composeCygwinCacheKeys(); - const paths = composeCygwinCachePaths(); - await saveCache(key, paths); - lib_core.endGroup(); + await lib_core.group("Save the Cygwin cache", async () => { + const { key } = await composeCygwinCacheKeys(); + const paths = composeCygwinCachePaths(); + await saveCache(key, paths); + }); } async function restoreDuneCache() { - lib_core.startGroup("Retrieve the dune cache"); - const { key, restoreKeys } = composeDuneCacheKeys(); - const paths = composeDuneCachePaths(); - await restoreCache(key, restoreKeys, paths); - lib_core.endGroup(); + await lib_core.group("Retrieve the dune cache", async () => { + const { key, restoreKeys } = composeDuneCacheKeys(); + const paths = composeDuneCachePaths(); + await restoreCache(key, restoreKeys, paths); + }); } 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); + }); } async function restoreOpamCache() { - lib_core.startGroup("Retrieve the opam cache"); - const { key, restoreKeys } = await composeOpamCacheKeys(); - const paths = composeOpamCachePaths(); - const cacheKey = await restoreCache(key, restoreKeys, paths); - lib_core.endGroup(); - return cacheKey; + return await lib_core.group("Retrieve the opam cache", async () => { + const { key, restoreKeys } = await composeOpamCacheKeys(); + const paths = composeOpamCachePaths(); + const cacheKey = await restoreCache(key, restoreKeys, paths); + return cacheKey; + }); } async function saveOpamCache() { - lib_core.startGroup("Save the opam cache"); - await (0,lib_exec.exec)("opam", [ - "clean", - "--all-switches", - "--download-cache", - "--logs", - "--repo-cache", - "--unused-repositories", - ]); - const { key } = await composeOpamCacheKeys(); - const paths = composeOpamCachePaths(); - await saveCache(key, paths); - lib_core.endGroup(); + await lib_core.group("Save the opam cache", async () => { + await (0,lib_exec.exec)("opam", [ + "clean", + "--all-switches", + "--download-cache", + "--logs", + "--repo-cache", + "--unused-repositories", + ]); + const { key } = await composeOpamCacheKeys(); + const paths = composeOpamCachePaths(); + await saveCache(key, paths); + }); } async function restoreOpamDownloadCache() { - lib_core.startGroup("Retrieve the opam download cache"); - const { key, restoreKeys } = composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - const cacheKey = await restoreCache(key, restoreKeys, paths); - lib_core.endGroup(); - return cacheKey; + return await lib_core.group("Retrieve the opam download cache", async () => { + const { key, restoreKeys } = composeOpamDownloadCacheKeys(); + const paths = composeOpamDownloadCachePaths(); + const cacheKey = await restoreCache(key, restoreKeys, paths); + return cacheKey; + }); } 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); + }); } ;// CONCATENATED MODULE: ./src/depext.ts @@ -144917,27 +144917,27 @@ async function saveOpamDownloadCache() { async function installDepext(ocamlVersion) { - lib_core.startGroup("Install depext"); - const platform = getPlatform(); - const depextCygwinports = platform === Platform.Win32 ? ["depext-cygwinports"] : []; - await (0,lib_exec.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 lib_core.group("Install depext", async () => { + const platform = getPlatform(); + const depextCygwinports = platform === Platform.Win32 ? ["depext-cygwinports"] : []; + await (0,lib_exec.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"; + } + lib_core.addPath(external_node_path_namespaceObject.posix.join("/", "usr", base, "sys-root", "mingw", "bin")); } - lib_core.addPath(external_node_path_namespaceObject.posix.join("/", "usr", base, "sys-root", "mingw", "bin")); - } - lib_core.endGroup(); + }); } async function installDepextPackages(fpaths) { - lib_core.startGroup("Install system packages required by opam packages"); - const fnames = fpaths.map((fpath) => external_node_path_namespaceObject.basename(fpath, ".opam")); - await (0,lib_exec.exec)("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]); - lib_core.endGroup(); + await lib_core.group("Install system packages required by opam packages", async () => { + const fnames = fpaths.map((fpath) => external_node_path_namespaceObject.basename(fpath, ".opam")); + await (0,lib_exec.exec)("opam", ["depext", ...fnames, ...OPAM_DEPEXT_FLAGS]); + }); } ;// CONCATENATED MODULE: ./src/dune.ts @@ -144947,29 +144947,29 @@ async function installDepextPackages(fpaths) { const { repo: { owner, repo }, runId: run_id, } = lib_github.context; async function installDune() { - lib_core.startGroup("Install dune"); - await (0,lib_exec.exec)("opam", ["depext", "--install", "dune"]); - lib_core.endGroup(); + await lib_core.group("Install dune", async () => { + await (0,lib_exec.exec)("opam", ["depext", "--install", "dune"]); + }); } 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, + 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`, + ]); }); - const cacheSize = Math.floor(5000 / totalCount); - await exec("opam", [ - "exec", - "--", - "dune", - "cache", - "trim", - "--size", - `${cacheSize}MB`, - ]); - core.endGroup(); } // EXTERNAL MODULE: ../../node_modules/@actions/glob/lib/glob.js @@ -145017,18 +145017,18 @@ async function installer() { lib_core.exportVariable("OPAMROOT", opamRoot); } if (platform === Platform.Win32) { - lib_core.startGroup("Change the file system behavior parameters"); - await (0,lib_exec.exec)("fsutil", ["behavior", "query", "SymlinkEvaluation"]); - // https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-behavior - await (0,lib_exec.exec)("fsutil", [ - "behavior", - "set", - "symlinkEvaluation", - "R2L:1", - "R2R:1", - ]); - await (0,lib_exec.exec)("fsutil", ["behavior", "query", "SymlinkEvaluation"]); - lib_core.endGroup(); + await lib_core.group("Change the file system behavior parameters", async () => { + await (0,lib_exec.exec)("fsutil", ["behavior", "query", "SymlinkEvaluation"]); + // https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-behavior + await (0,lib_exec.exec)("fsutil", [ + "behavior", + "set", + "symlinkEvaluation", + "R2L:1", + "R2R:1", + ]); + await (0,lib_exec.exec)("fsutil", ["behavior", "query", "SymlinkEvaluation"]); + }); } if (platform === Platform.Win32) { lib_core.exportVariable("HOME", external_node_process_namespaceObject.env.USERPROFILE); diff --git a/dist/post/index.js b/dist/post/index.js index efd59c6c..959ec0c8 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -143176,12 +143176,12 @@ async function initializeOpamUnix() { ]); } async function setupOpamUnix() { - core.startGroup("Install opam"); - await acquireOpamUnix(); - core.endGroup(); - core.startGroup("Initialise the opam state"); - await initializeOpamUnix(); - core.endGroup(); + await core.group("Install opam", async () => { + await acquireOpamUnix(); + }); + await core.group("Initialise the opam state", async () => { + await initializeOpamUnix(); + }); } async function setupCygwin() { const version = await getCygwinVersion(); @@ -143259,25 +143259,25 @@ async function initializeOpamWindows() { await fs.writeFile(opamCmd, data, { mode: 0o755 }); } async function setupOpamWindows() { - core.startGroup("Prepare the Cygwin environment"); - core.exportVariable("CYGWIN", "winsymlinks:native"); - core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); - core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); - core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); - core.addPath(CYGWIN_ROOT_WRAPPERBIN); - await setupCygwin(); - core.endGroup(); + await core.group("Prepare the Cygwin environment", async () => { + core.exportVariable("CYGWIN", "winsymlinks:native"); + core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); + core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); + core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); + core.addPath(CYGWIN_ROOT_WRAPPERBIN); + await setupCygwin(); + }); await saveCygwinCache(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const originalPath = process.env["PATH"].split(path.delimiter); const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; process.env["PATH"] = patchedPath.join(path.delimiter); - core.startGroup("Install opam"); - await acquireOpamWindows(); - core.endGroup(); - core.startGroup("Initialise the opam state"); - await initializeOpamWindows(); - core.endGroup(); + await core.group("Install opam", async () => { + await acquireOpamWindows(); + }); + await core.group("Initialise the opam state", async () => { + await initializeOpamWindows(); + }); process.env["PATH"] = originalPath.join(path.delimiter); } async function setupOpam() { @@ -143290,46 +143290,46 @@ async function setupOpam() { } } async function installOcaml(ocamlCompiler) { - core.startGroup("Install OCaml"); - const platform = getPlatform(); - if (platform === Platform.Win32) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const originalPath = process.env["PATH"].split(path.delimiter); - const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; - process.env["PATH"] = patchedPath.join(path.delimiter); - await exec("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - process.env["PATH"] = originalPath.join(path.delimiter); - } - else { - await exec("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - } - core.endGroup(); + await core.group("Install OCaml", async () => { + const platform = getPlatform(); + if (platform === Platform.Win32) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const originalPath = process.env["PATH"].split(path.delimiter); + const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; + process.env["PATH"] = patchedPath.join(path.delimiter); + await exec("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + process.env["PATH"] = originalPath.join(path.delimiter); + } + else { + await exec("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + } + }); } async function pin(fpaths) { - core.startGroup("Pin local packages"); - const opam = await findOpam(); - for (const fpath of fpaths) { - const fname = path.basename(fpath, ".opam"); - const dname = path.dirname(fpath); - await exec(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { - cwd: dname, - }); - } - core.endGroup(); + await core.group("Pin local packages", async () => { + const opam = await findOpam(); + for (const fpath of fpaths) { + const fname = path.basename(fpath, ".opam"); + const dname = path.dirname(fpath); + await exec(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { + cwd: dname, + }); + } + }); } async function repositoryAdd(name, address) { const opam = await findOpam(); @@ -143343,40 +143343,40 @@ async function repositoryAdd(name, address) { ]); } async function repositoryAddAll(repositories) { - const platform = getPlatform(); - let restore_autocrlf; - core.startGroup("Initialise the opam repositories"); - // Works around the lack of https://github.com/ocaml/opam/pull/3882 when - // adding ocaml/opam-repository on Windows. Can be removed when the action - // switches to opam 2.2 - if (platform === Platform.Win32) { - const autocrlf = await getExecOutput("git", ["config", "--global", "core.autocrlf"], { ignoreReturnCode: true }); - if (autocrlf.stdout.trim() !== "input") { - if (autocrlf.exitCode === 0) { - restore_autocrlf = autocrlf.stdout.trim(); - } - else { - // eslint-disable-next-line unicorn/no-null - restore_autocrlf = null; // Unset the value at the end + await core.group("Initialise the opam repositories", async () => { + const platform = getPlatform(); + let restore_autocrlf; + // Works around the lack of https://github.com/ocaml/opam/pull/3882 when + // adding ocaml/opam-repository on Windows. Can be removed when the action + // switches to opam 2.2 + if (platform === Platform.Win32) { + const autocrlf = await getExecOutput("git", ["config", "--global", "core.autocrlf"], { ignoreReturnCode: true }); + if (autocrlf.stdout.trim() !== "input") { + if (autocrlf.exitCode === 0) { + restore_autocrlf = autocrlf.stdout.trim(); + } + else { + // eslint-disable-next-line unicorn/no-null + restore_autocrlf = null; // Unset the value at the end + } } + await exec("git", ["config", "--global", "core.autocrlf", "input"]); } - await exec("git", ["config", "--global", "core.autocrlf", "input"]); - } - for (const [name, address] of repositories) { - await repositoryAdd(name, address); - } - if (restore_autocrlf === null) { - await exec("git", ["config", "--global", "--unset", "core.autocrlf"]); - } - else if (restore_autocrlf !== undefined) { - await exec("git", [ - "config", - "--global", - "core.autocrlf", - restore_autocrlf, - ]); - } - core.endGroup(); + for (const [name, address] of repositories) { + await repositoryAdd(name, address); + } + if (restore_autocrlf === null) { + await exec("git", ["config", "--global", "--unset", "core.autocrlf"]); + } + else if (restore_autocrlf !== undefined) { + await exec("git", [ + "config", + "--global", + "core.autocrlf", + restore_autocrlf, + ]); + } + }); } async function repositoryRemove(name) { const opam = await findOpam(); @@ -143396,12 +143396,12 @@ async function repositoryList() { } } async function repositoryRemoveAll() { - core.startGroup("Remove the opam repositories"); - const repositories = await repositoryList(); - for (const repository of repositories) { - await repositoryRemove(repository); - } - core.endGroup(); + await core.group("Remove the opam repositories", async () => { + const repositories = await repositoryList(); + for (const repository of repositories) { + await repositoryRemove(repository); + } + }); } ;// CONCATENATED MODULE: ./src/version.ts @@ -143652,70 +143652,70 @@ async function saveCache(key, paths) { } } 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); + }); } async function cache_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); + }); } 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); + }); } async function saveDuneCache() { - lib_core.startGroup("Save the dune cache"); - const { key } = composeDuneCacheKeys(); - const paths = composeDuneCachePaths(); - await saveCache(key, paths); - lib_core.endGroup(); + await lib_core.group("Save the dune cache", async () => { + const { key } = composeDuneCacheKeys(); + const paths = composeDuneCachePaths(); + await saveCache(key, paths); + }); } 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; + }); } 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); + }); } 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; + }); } async function saveOpamDownloadCache() { - lib_core.startGroup("Save the opam download cache"); - const { key } = composeOpamDownloadCacheKeys(); - const paths = composeOpamDownloadCachePaths(); - await saveCache(key, paths); - lib_core.endGroup(); + await lib_core.group("Save the opam download cache", async () => { + const { key } = composeOpamDownloadCacheKeys(); + const paths = composeOpamDownloadCachePaths(); + await saveCache(key, paths); + }); } ;// CONCATENATED MODULE: ./src/dune.ts @@ -143725,29 +143725,29 @@ async function saveOpamDownloadCache() { const { repo: { owner, repo }, runId: run_id, } = lib_github.context; 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"]); + }); } async function trimDuneCache() { - lib_core.startGroup("Remove oldest files from the dune cache to free space"); - const octokit = lib_github.getOctokit(constants_GITHUB_TOKEN); - const { data: { total_count: totalCount }, } = await octokit.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id, + await lib_core.group("Remove oldest files from the dune cache to free space", async () => { + const octokit = lib_github.getOctokit(constants_GITHUB_TOKEN); + const { data: { total_count: totalCount }, } = await octokit.rest.actions.listJobsForWorkflowRun({ + owner, + repo, + run_id, + }); + const cacheSize = Math.floor(5000 / totalCount); + await (0,lib_exec.exec)("opam", [ + "exec", + "--", + "dune", + "cache", + "trim", + "--size", + `${cacheSize}MB`, + ]); }); - const cacheSize = Math.floor(5000 / totalCount); - await (0,lib_exec.exec)("opam", [ - "exec", - "--", - "dune", - "cache", - "trim", - "--size", - `${cacheSize}MB`, - ]); - lib_core.endGroup(); } ;// CONCATENATED MODULE: ./src/post.ts diff --git a/lint-doc/dist/index.js b/lint-doc/dist/index.js index 14cd107d..21994c4a 100644 --- a/lint-doc/dist/index.js +++ b/lint-doc/dist/index.js @@ -27156,14 +27156,20 @@ async function lintOdoc() { async function installOpamPackages() { - core.startGroup("Install opam packages"); - await (0,exec.exec)("opam", ["install", ".", "--deps-only", "--with-doc"]); - core.endGroup(); + await core.group("Install opam packages", async () => { + await (0,exec.exec)("opam", ["install", ".", "--deps-only", "--with-doc"]); + }); } async function installOdoc() { - core.startGroup("Install odoc"); - await (0,exec.exec)("opam", ["depext", "--install", "conf-m4", "dune", "odoc>=1.5.0"]); - core.endGroup(); + await core.group("Install odoc", async () => { + await (0,exec.exec)("opam", [ + "depext", + "--install", + "conf-m4", + "dune", + "odoc>=1.5.0", + ]); + }); } ;// CONCATENATED MODULE: ./src/index.ts diff --git a/lint-fmt/dist/index.js b/lint-fmt/dist/index.js index fc736667..d7cc417c 100644 --- a/lint-fmt/dist/index.js +++ b/lint-fmt/dist/index.js @@ -27186,9 +27186,9 @@ async function getOcamlformatVersion() { async function installOcamlformat(version) { - core.startGroup("Install ocamlformat"); - await (0,exec.exec)("opam", ["depext", "--install", `ocamlformat=${version}`]); - core.endGroup(); + await core.group("Install ocamlformat", async () => { + await (0,exec.exec)("opam", ["depext", "--install", `ocamlformat=${version}`]); + }); } ;// CONCATENATED MODULE: ./src/index.ts diff --git a/lint-opam/dist/index.js b/lint-opam/dist/index.js index 833d029a..376b5a4f 100644 --- a/lint-opam/dist/index.js +++ b/lint-opam/dist/index.js @@ -27149,20 +27149,20 @@ async function opamDuneLint() { async function installOpamPackages() { - core.startGroup("Install opam packages"); - await (0,exec.exec)("opam", [ - "install", - ".", - "--deps-only", - "--with-test", - "--with-doc", - ]); - core.endGroup(); + await core.group("Install opam packages", async () => { + await (0,exec.exec)("opam", [ + "install", + ".", + "--deps-only", + "--with-test", + "--with-doc", + ]); + }); } async function installOpamDuneLint() { - core.startGroup("Install opam-dune-lint"); - await (0,exec.exec)("opam", ["depext", "--install", "opam-dune-lint"]); - core.endGroup(); + await core.group("Install opam-dune-lint", async () => { + await (0,exec.exec)("opam", ["depext", "--install", "opam-dune-lint"]); + }); } ;// CONCATENATED MODULE: ./src/index.ts diff --git a/packages/lint-doc/src/opam.ts b/packages/lint-doc/src/opam.ts index 15eef6de..63b9c447 100644 --- a/packages/lint-doc/src/opam.ts +++ b/packages/lint-doc/src/opam.ts @@ -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", + ]); + }); } diff --git a/packages/lint-fmt/src/opam.ts b/packages/lint-fmt/src/opam.ts index 91bca85f..4572ec21 100644 --- a/packages/lint-fmt/src/opam.ts +++ b/packages/lint-fmt/src/opam.ts @@ -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}`]); + }); } diff --git a/packages/lint-opam/src/opam.ts b/packages/lint-opam/src/opam.ts index 9266334b..55725c1d 100644 --- a/packages/lint-opam/src/opam.ts +++ b/packages/lint-opam/src/opam.ts @@ -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"]); + }); } diff --git a/packages/setup-ocaml/src/cache.ts b/packages/setup-ocaml/src/cache.ts index 8e4bd3a1..28e9b0d7 100644 --- a/packages/setup-ocaml/src/cache.ts +++ b/packages/setup-ocaml/src/cache.ts @@ -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); + }); } diff --git a/packages/setup-ocaml/src/depext.ts b/packages/setup-ocaml/src/depext.ts index 850c6bbd..094ae89d 100644 --- a/packages/setup-ocaml/src/depext.ts +++ b/packages/setup-ocaml/src/depext.ts @@ -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]); + }, + ); } diff --git a/packages/setup-ocaml/src/dune.ts b/packages/setup-ocaml/src/dune.ts index 987bc0b4..8fb28e9e 100644 --- a/packages/setup-ocaml/src/dune.ts +++ b/packages/setup-ocaml/src/dune.ts @@ -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`, + ]); + }, + ); } diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index e3f57fd1..8997762a 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -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"]); diff --git a/packages/setup-ocaml/src/opam.ts b/packages/setup-ocaml/src/opam.ts index d42e7c15..fa51eff0 100644 --- a/packages/setup-ocaml/src/opam.ts +++ b/packages/setup-ocaml/src/opam.ts @@ -157,12 +157,12 @@ async function initializeOpamUnix() { } async function setupOpamUnix() { - core.startGroup("Install opam"); - await acquireOpamUnix(); - core.endGroup(); - core.startGroup("Initialise the opam state"); - await initializeOpamUnix(); - core.endGroup(); + await core.group("Install opam", async () => { + await acquireOpamUnix(); + }); + await core.group("Initialise the opam state", async () => { + await initializeOpamUnix(); + }); } async function setupCygwin() { @@ -252,25 +252,25 @@ async function initializeOpamWindows() { } async function setupOpamWindows() { - core.startGroup("Prepare the Cygwin environment"); - core.exportVariable("CYGWIN", "winsymlinks:native"); - core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); - core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); - core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); - core.addPath(CYGWIN_ROOT_WRAPPERBIN); - await setupCygwin(); - core.endGroup(); + await core.group("Prepare the Cygwin environment", async () => { + core.exportVariable("CYGWIN", "winsymlinks:native"); + core.exportVariable("CYGWIN_ROOT", CYGWIN_ROOT); + core.exportVariable("CYGWIN_ROOT_BIN", CYGWIN_ROOT_BIN); + core.exportVariable("CYGWIN_ROOT_WRAPPERBIN", CYGWIN_ROOT_WRAPPERBIN); + core.addPath(CYGWIN_ROOT_WRAPPERBIN); + await setupCygwin(); + }); await saveCygwinCache(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const originalPath = process.env["PATH"]!.split(path.delimiter); const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; process.env["PATH"] = patchedPath.join(path.delimiter); - core.startGroup("Install opam"); - await acquireOpamWindows(); - core.endGroup(); - core.startGroup("Initialise the opam state"); - await initializeOpamWindows(); - core.endGroup(); + await core.group("Install opam", async () => { + await acquireOpamWindows(); + }); + await core.group("Initialise the opam state", async () => { + await initializeOpamWindows(); + }); process.env["PATH"] = originalPath.join(path.delimiter); } @@ -284,46 +284,46 @@ export async function setupOpam() { } export async function installOcaml(ocamlCompiler: string) { - core.startGroup("Install OCaml"); - const platform = getPlatform(); - if (platform === Platform.Win32) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const originalPath = process.env["PATH"]!.split(path.delimiter); - const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; - process.env["PATH"] = patchedPath.join(path.delimiter); - await exec("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - process.env["PATH"] = originalPath.join(path.delimiter); - } else { - await exec("opam", [ - "switch", - "create", - ".", - "--no-install", - "--packages", - ocamlCompiler, - ]); - } - core.endGroup(); + await core.group("Install OCaml", async () => { + const platform = getPlatform(); + if (platform === Platform.Win32) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const originalPath = process.env["PATH"]!.split(path.delimiter); + const patchedPath = [CYGWIN_ROOT_BIN, ...originalPath]; + process.env["PATH"] = patchedPath.join(path.delimiter); + await exec("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + process.env["PATH"] = originalPath.join(path.delimiter); + } else { + await exec("opam", [ + "switch", + "create", + ".", + "--no-install", + "--packages", + ocamlCompiler, + ]); + } + }); } export async function pin(fpaths: string[]) { - core.startGroup("Pin local packages"); - const opam = await findOpam(); - for (const fpath of fpaths) { - const fname = path.basename(fpath, ".opam"); - const dname = path.dirname(fpath); - await exec(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { - cwd: dname, - }); - } - core.endGroup(); + await core.group("Pin local packages", async () => { + const opam = await findOpam(); + for (const fpath of fpaths) { + const fname = path.basename(fpath, ".opam"); + const dname = path.dirname(fpath); + await exec(opam, ["pin", "add", `${fname}.dev`, ".", "--no-action"], { + cwd: dname, + }); + } + }); } async function repositoryAdd(name: string, address: string) { @@ -339,42 +339,42 @@ async function repositoryAdd(name: string, address: string) { } export async function repositoryAddAll(repositories: [string, string][]) { - const platform = getPlatform(); - let restore_autocrlf; - core.startGroup("Initialise the opam repositories"); - // Works around the lack of https://github.com/ocaml/opam/pull/3882 when - // adding ocaml/opam-repository on Windows. Can be removed when the action - // switches to opam 2.2 - if (platform === Platform.Win32) { - const autocrlf = await getExecOutput( - "git", - ["config", "--global", "core.autocrlf"], - { ignoreReturnCode: true }, - ); - if (autocrlf.stdout.trim() !== "input") { - if (autocrlf.exitCode === 0) { - restore_autocrlf = autocrlf.stdout.trim(); - } else { - // eslint-disable-next-line unicorn/no-null - restore_autocrlf = null; // Unset the value at the end + await core.group("Initialise the opam repositories", async () => { + const platform = getPlatform(); + let restore_autocrlf; + // Works around the lack of https://github.com/ocaml/opam/pull/3882 when + // adding ocaml/opam-repository on Windows. Can be removed when the action + // switches to opam 2.2 + if (platform === Platform.Win32) { + const autocrlf = await getExecOutput( + "git", + ["config", "--global", "core.autocrlf"], + { ignoreReturnCode: true }, + ); + if (autocrlf.stdout.trim() !== "input") { + if (autocrlf.exitCode === 0) { + restore_autocrlf = autocrlf.stdout.trim(); + } else { + // eslint-disable-next-line unicorn/no-null + restore_autocrlf = null; // Unset the value at the end + } } + await exec("git", ["config", "--global", "core.autocrlf", "input"]); } - await exec("git", ["config", "--global", "core.autocrlf", "input"]); - } - for (const [name, address] of repositories) { - await repositoryAdd(name, address); - } - if (restore_autocrlf === null) { - await exec("git", ["config", "--global", "--unset", "core.autocrlf"]); - } else if (restore_autocrlf !== undefined) { - await exec("git", [ - "config", - "--global", - "core.autocrlf", - restore_autocrlf, - ]); - } - core.endGroup(); + for (const [name, address] of repositories) { + await repositoryAdd(name, address); + } + if (restore_autocrlf === null) { + await exec("git", ["config", "--global", "--unset", "core.autocrlf"]); + } else if (restore_autocrlf !== undefined) { + await exec("git", [ + "config", + "--global", + "core.autocrlf", + restore_autocrlf, + ]); + } + }); } async function repositoryRemove(name: string) { @@ -400,10 +400,10 @@ async function repositoryList() { } export async function repositoryRemoveAll() { - core.startGroup("Remove the opam repositories"); - const repositories = await repositoryList(); - for (const repository of repositories) { - await repositoryRemove(repository); - } - core.endGroup(); + await core.group("Remove the opam repositories", async () => { + const repositories = await repositoryList(); + for (const repository of repositories) { + await repositoryRemove(repository); + } + }); }