diff --git a/dist/index.js b/dist/index.js index f9c3efc7f..05401967b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -92818,6 +92818,21 @@ async function setupOpam() { await initializeOpam(); }); } +function setupOpamEnv() { + const githubWorkspace = process.env.GITHUB_WORKSPACE ?? process.cwd(); + const OPAM_SWITCH_PREFIX = external_node_path_namespaceObject.join(githubWorkspace, "_opam"); + const CAML_LD_LIBRARY_PATH = [ + external_node_path_namespaceObject.join(OPAM_SWITCH_PREFIX, "lib", "stublibs"), + external_node_path_namespaceObject.join(OPAM_SWITCH_PREFIX, "lib", "ocaml", "stublibs"), + external_node_path_namespaceObject.join(OPAM_SWITCH_PREFIX, "lib", "ocaml"), + ].join(external_node_path_namespaceObject.delimiter); + const OCAML_TOPLEVEL_PATH = external_node_path_namespaceObject.join(OPAM_SWITCH_PREFIX, "lib", "toplevel"); + const OPAM_SWITCH_BIN = external_node_path_namespaceObject.join(OPAM_SWITCH_PREFIX, "bin"); + lib_core.exportVariable("OPAM_SWITCH_PREFIX", OPAM_SWITCH_PREFIX); + lib_core.exportVariable("CAML_LD_LIBRARY_PATH", CAML_LD_LIBRARY_PATH); + lib_core.exportVariable("OCAML_TOPLEVEL_PATH", OCAML_TOPLEVEL_PATH); + lib_core.addPath(OPAM_SWITCH_BIN); +} async function installOcaml(ocamlCompiler) { await lib_core.group("Install OCaml", async () => { await (0,lib_exec.exec)("opam", [ @@ -110482,14 +110497,7 @@ async function trimDuneCache() { run_id, }); const cacheSize = Math.floor(5000 / totalCount); - await exec("opam", [ - "exec", - "--", - "dune", - "cache", - "trim", - `--size=${cacheSize}MB`, - ]); + await exec("dune", ["dune", "cache", "trim", `--size=${cacheSize}MB`]); }); } @@ -110558,6 +110566,7 @@ async function installer() { await installOcaml(ocamlCompiler); await saveOpamCache(); } + setupOpamEnv(); if (DUNE_CACHE) { await restoreDuneCache(); await installDune(); @@ -110565,7 +110574,6 @@ async function installer() { lib_core.exportVariable("DUNE_CACHE_TRANSPORT", "direct"); lib_core.exportVariable("DUNE_CACHE_STORAGE_MODE", "copy"); } - lib_core.exportVariable("CLICOLOR_FORCE", "1"); const fnames = await getOpamLocalPackages(); if (fnames.length > 0) { if (OPAM_PIN) { @@ -110573,7 +110581,7 @@ async function installer() { } } await (0,lib_exec.exec)("opam", ["--version"]); - await (0,lib_exec.exec)("opam", ["exec", "--", "ocaml", "-version"]); + await (0,lib_exec.exec)("ocaml", ["-version"]); } ;// CONCATENATED MODULE: ./src/index.ts diff --git a/dist/post/index.js b/dist/post/index.js index 3d77ca75c..5be087adf 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -84985,14 +84985,7 @@ async function trimDuneCache() { run_id, }); const cacheSize = Math.floor(5000 / totalCount); - await (0,lib_exec.exec)("opam", [ - "exec", - "--", - "dune", - "cache", - "trim", - `--size=${cacheSize}MB`, - ]); + await (0,lib_exec.exec)("dune", ["dune", "cache", "trim", `--size=${cacheSize}MB`]); }); } diff --git a/lint-doc/dist/index.js b/lint-doc/dist/index.js index ac1c2a254..f2b5e52c1 100644 --- a/lint-doc/dist/index.js +++ b/lint-doc/dist/index.js @@ -27920,7 +27920,7 @@ var exec = __nccwpck_require__(6473); async function lintOdoc() { - const exitCode = await (0,exec.exec)("opam", ["exec", "--", "dune", "build", "@doc"], { + const exitCode = await (0,exec.exec)("dune", ["build", "@doc"], { env: { ...external_node_process_namespaceObject.env, PATH: external_node_process_namespaceObject.env.PATH ?? "", diff --git a/lint-fmt/dist/index.js b/lint-fmt/dist/index.js index 4168291c7..82f2519fc 100644 --- a/lint-fmt/dist/index.js +++ b/lint-fmt/dist/index.js @@ -27919,7 +27919,7 @@ var exec = __nccwpck_require__(6473); ;// CONCATENATED MODULE: ./src/lint.ts async function checkFmt() { - await (0,exec.exec)("opam", ["exec", "--", "dune", "build", "@fmt"]); + await (0,exec.exec)("dune", ["build", "@fmt"]); } ;// CONCATENATED MODULE: external "node:fs" diff --git a/lint-opam/dist/index.js b/lint-opam/dist/index.js index dbb4929b1..8ccfd9f24 100644 --- a/lint-opam/dist/index.js +++ b/lint-opam/dist/index.js @@ -27922,7 +27922,7 @@ async function opamLint() { await (0,exec.exec)("opam", ["lint"]); } async function opamDuneLint() { - await (0,exec.exec)("opam", ["exec", "--", "opam-dune-lint"]); + await (0,exec.exec)("opam-dune-lint"); } ;// CONCATENATED MODULE: ./src/opam.ts diff --git a/packages/lint-doc/src/odoc.ts b/packages/lint-doc/src/odoc.ts index 2514f9161..d11d9acb0 100644 --- a/packages/lint-doc/src/odoc.ts +++ b/packages/lint-doc/src/odoc.ts @@ -2,7 +2,7 @@ import * as process from "node:process"; import { exec } from "@actions/exec"; export async function lintOdoc() { - const exitCode = await exec("opam", ["exec", "--", "dune", "build", "@doc"], { + const exitCode = await exec("dune", ["build", "@doc"], { env: { ...process.env, PATH: process.env.PATH ?? "", diff --git a/packages/lint-fmt/src/lint.ts b/packages/lint-fmt/src/lint.ts index eba1ab5cf..3301eda51 100644 --- a/packages/lint-fmt/src/lint.ts +++ b/packages/lint-fmt/src/lint.ts @@ -1,5 +1,5 @@ import { exec } from "@actions/exec"; export async function checkFmt() { - await exec("opam", ["exec", "--", "dune", "build", "@fmt"]); + await exec("dune", ["build", "@fmt"]); } diff --git a/packages/lint-opam/src/lint.ts b/packages/lint-opam/src/lint.ts index 2ef46e2c6..5c13353f9 100644 --- a/packages/lint-opam/src/lint.ts +++ b/packages/lint-opam/src/lint.ts @@ -5,5 +5,5 @@ export async function opamLint() { } export async function opamDuneLint() { - await exec("opam", ["exec", "--", "opam-dune-lint"]); + await exec("opam-dune-lint"); } diff --git a/packages/setup-ocaml/src/dune.ts b/packages/setup-ocaml/src/dune.ts index 2c3c49bd2..864a4bba7 100644 --- a/packages/setup-ocaml/src/dune.ts +++ b/packages/setup-ocaml/src/dune.ts @@ -27,14 +27,7 @@ export async function trimDuneCache() { run_id, }); const cacheSize = Math.floor(5000 / totalCount); - await exec("opam", [ - "exec", - "--", - "dune", - "cache", - "trim", - `--size=${cacheSize}MB`, - ]); + await exec("dune", ["dune", "cache", "trim", `--size=${cacheSize}MB`]); }, ); } diff --git a/packages/setup-ocaml/src/installer.ts b/packages/setup-ocaml/src/installer.ts index 3e271a0fb..dbe8974f5 100644 --- a/packages/setup-ocaml/src/installer.ts +++ b/packages/setup-ocaml/src/installer.ts @@ -24,6 +24,7 @@ import { repositoryAddAll, repositoryRemoveAll, setupOpam, + setupOpamEnv, } from "./opam.js"; import { getOpamLocalPackages } from "./packages.js"; import { resolveCompiler } from "./version.js"; @@ -71,6 +72,7 @@ export async function installer() { await installOcaml(ocamlCompiler); await saveOpamCache(); } + setupOpamEnv(); if (DUNE_CACHE) { await restoreDuneCache(); await installDune(); @@ -78,7 +80,6 @@ export async function installer() { core.exportVariable("DUNE_CACHE_TRANSPORT", "direct"); core.exportVariable("DUNE_CACHE_STORAGE_MODE", "copy"); } - core.exportVariable("CLICOLOR_FORCE", "1"); const fnames = await getOpamLocalPackages(); if (fnames.length > 0) { if (OPAM_PIN) { @@ -86,5 +87,5 @@ export async function installer() { } } await exec("opam", ["--version"]); - await exec("opam", ["exec", "--", "ocaml", "-version"]); + await exec("ocaml", ["-version"]); } diff --git a/packages/setup-ocaml/src/opam.ts b/packages/setup-ocaml/src/opam.ts index a3e8bdfc2..7b96f08cc 100644 --- a/packages/setup-ocaml/src/opam.ts +++ b/packages/setup-ocaml/src/opam.ts @@ -120,6 +120,22 @@ export async function setupOpam() { }); } +export function setupOpamEnv() { + const githubWorkspace = process.env.GITHUB_WORKSPACE ?? process.cwd(); + const OPAM_SWITCH_PREFIX = path.join(githubWorkspace, "_opam"); + const CAML_LD_LIBRARY_PATH = [ + path.join(OPAM_SWITCH_PREFIX, "lib", "stublibs"), + path.join(OPAM_SWITCH_PREFIX, "lib", "ocaml", "stublibs"), + path.join(OPAM_SWITCH_PREFIX, "lib", "ocaml"), + ].join(path.delimiter); + const OCAML_TOPLEVEL_PATH = path.join(OPAM_SWITCH_PREFIX, "lib", "toplevel"); + const OPAM_SWITCH_BIN = path.join(OPAM_SWITCH_PREFIX, "bin"); + core.exportVariable("OPAM_SWITCH_PREFIX", OPAM_SWITCH_PREFIX); + core.exportVariable("CAML_LD_LIBRARY_PATH", CAML_LD_LIBRARY_PATH); + core.exportVariable("OCAML_TOPLEVEL_PATH", OCAML_TOPLEVEL_PATH); + core.addPath(OPAM_SWITCH_BIN); +} + export async function installOcaml(ocamlCompiler: string) { await core.group("Install OCaml", async () => { await exec("opam", [